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

Does IndexedFastaSequenceFile need to reset its channel in every read operation? #1131

Open
magicDGS opened this issue May 28, 2018 · 0 comments

Comments

@magicDGS
Copy link
Member

Concretely in the following codepath:

private static int readFromPosition(final SeekableByteChannel channel, final ByteBuffer buffer, long position) throws IOException {
if (channel instanceof FileChannel) { // special case to take advantage of native code path
return ((FileChannel) channel).read(buffer,position);
} else {
long oldPos = channel.position();
try {
channel.position(position);
return channel.read(buffer);
} finally {
channel.position(oldPos);
}
}
}

The channel is reset to the original position. It looks like a solution to maintain the state of the channel even in the case of failure, as the FileChannel.read does. After #1014, the reset is also done in the compressed reference. This could have performance effects, and it does not look completely necessary.

@magicDGS magicDGS changed the title Is it needed that IndexedFastaSequenceFile resets the channel in every read operation? Does IndexedFastaSequenceFile need to reset its channel in every read operation? May 28, 2018
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

No branches or pull requests

1 participant