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

Remove redundant fs metadata ops. #9807

Closed
wants to merge 1 commit into from
Closed

Conversation

rmuir
Copy link
Contributor

@rmuir rmuir commented Feb 22, 2015

Some easy cleanups:
Files.exists(f) && Files.isDirectory(f) -> Files.isDirectory(f)
if (Files.exists(f)) Files.delete(f) -> Files.deleteIfExists(f)
if (!Files.exists(f)) Files.createDirectories(f) -> Files.createDirectories(f)

In a few places where successive i/o ops are done against the same file, convert
to Files.readAttributes().

Files.exists(f) && Files.isDirectory(f) -> Files.exists(f)
if (Files.exists(f)) Files.delete(f) -> Files.deleteIfExists(f)
if (!Files.exists(f)) Files.createDirectories(f) -> Files.createDirectories(f)

In a few places where successive i/o ops are done against the same file, convert
to Files.readAttributes().
@kimchy
Copy link
Member

kimchy commented Feb 22, 2015

LGTM

@kimchy
Copy link
Member

kimchy commented Feb 22, 2015

@rmuir should be also backport to 1.x where applicable?

@rmuir
Copy link
Contributor Author

rmuir commented Feb 22, 2015

These are NIO.2 cleanups, when i look at 1.x its still using java.io.File. This makes things tricky...

@kimchy
Copy link
Member

kimchy commented Feb 22, 2015

I see....

@rmuir
Copy link
Contributor Author

rmuir commented Feb 22, 2015

Lemme look more. we can do a little bit, but it won't be as good.

For example File.isDirectory implies File.exists just like it does for NIO.2

@rmuir rmuir added the 1.x label Feb 22, 2015
@kimchy
Copy link
Member

kimchy commented Feb 22, 2015

yea, make sense. My answer was short since maybe to improve the file system API usage in 1.x, we might need to backport the NIO.2 work, so am on the fence as to what is the best path...

@rmuir
Copy link
Contributor Author

rmuir commented Feb 22, 2015

I think that is somewhat tricky since on 1.x we have lucene 4, which itself is not using NIO.2. But we can at least remove any redundant exists() for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants