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

Use Directory#fileLength() less during calculating checksums #9689

Merged
merged 2 commits into from Feb 13, 2015

Conversation

s1monw
Copy link
Contributor

@s1monw s1monw commented Feb 13, 2015

No description provided.

@s1monw
Copy link
Contributor Author

s1monw commented Feb 13, 2015

@rmuir can you take a look

final long length;
try (final IndexInput in = directory.openInput(segmentsFile, IOContext.READONCE)) {
length = in.length();
hashFile(fileHash, new InputStreamIndexInput(in, length), length);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think its awkward we wrap these files in InputStreamIndexInput here, and have the method take InputStream, when it could just take DataInput?

The one lone other usage of it, in a separate file (BlobStoreIndexShardRepository), could just wrap its InputStream with a o.a.l.util.InputStreamDataInput. and then the hashFile() would just be a simple readBytes() call into the byte array.

I know this isn't new in the patch, but this path adds more indexinput-wrapping since its not calling hashFile(String) anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will refactor this in a different PR

@rmuir
Copy link
Contributor

rmuir commented Feb 13, 2015

looks good. i added a cosmetic comment, maybe for the future.

@s1monw s1monw merged commit 616d0c0 into elastic:master Feb 13, 2015
@clintongormley clintongormley added :Distributed/Store Issues around managing unopened Lucene indices. If it touches Store.java, this is a likely label. and removed review labels Mar 19, 2015
@clintongormley clintongormley changed the title [STORE] use Directory#fileLength() less during calculating checksums Use Directory#fileLength() less during calculating checksums Jun 7, 2015
@clintongormley clintongormley added :Distributed/Engine Anything around managing Lucene and the Translog in an open shard. and removed :Distributed/Store Issues around managing unopened Lucene indices. If it touches Store.java, this is a likely label. labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Engine Anything around managing Lucene and the Translog in an open shard. >enhancement v1.5.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants