Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NewReaderWithOffset #41

Merged
merged 2 commits into from
Mar 22, 2019
Merged

Conversation

jfontan
Copy link
Contributor

@jfontan jfontan commented Feb 27, 2019

This allows opening siva files while they are being modified or opening an old index.

This allows opening siva files while they are being modified or opening an old
index.

Signed-off-by: Javi Fontan <[email protected]>
index.go Outdated
endLastBlock, err := r.Seek(0, io.SeekEnd)
if err != nil {
return nil, err
func readIndex(r io.ReadSeeker, o uint64) (Index, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it'd be worthy write a comment to know why readIndex and readIndexAt are different, right now it's confusing.

// NewReaderWithOffset creates a new Reader giving the position of the index.
// This is useful to open siva files that are being written or reading an
// old index.
func NewReaderWithOffset(r io.ReadSeeker, o uint64) Reader {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if the provided offset is not an index?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling Index function will error. The same way it errors when opening a broken siva file.

@jfontan jfontan changed the title Add NewReaderWithOffset [WIP] Add NewReaderWithOffset Feb 28, 2019
@jfontan
Copy link
Contributor Author

jfontan commented Feb 28, 2019

Found a problem that causes index to be read every time it is accessed. Working on a fix.

@jfontan jfontan changed the title [WIP] Add NewReaderWithOffset Add NewReaderWithOffset Feb 28, 2019
@mcuadros mcuadros merged commit 4cc10f1 into src-d:master Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants