Skip to content

Create file open hints on IOContext to replace ReadAdvice#14482

Merged
ChrisHegarty merged 14 commits intoapache:mainfrom
thecoop:iocontext-split
Apr 30, 2025
Merged

Create file open hints on IOContext to replace ReadAdvice#14482
ChrisHegarty merged 14 commits intoapache:mainfrom
thecoop:iocontext-split

Conversation

@thecoop
Copy link
Contributor

@thecoop thecoop commented Apr 14, 2025

Refactor IOContext and create FileOpenHint to specify how files are likely to be accessed once opened. This is the first PR of several to move from specifying ReadAdvice directly, to specifying the file usage context as hints and the ReadAdvice being inferred from the hints inside Directory implementations.

Relates #14422

@thecoop thecoop force-pushed the iocontext-split branch 3 times, most recently from 7a36602 to 440ddf1 Compare April 14, 2025 16:30
Copy link
Contributor

@ChrisHegarty ChrisHegarty left a comment

Choose a reason for hiding this comment

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

I like this change. I can see how the usage sites withHints(... are very convenient and readable. This comes at the cost of validateIOContext, which I think is ok.

@thecoop
Copy link
Contributor Author

thecoop commented Apr 15, 2025

To stop this PR getting too big, I suggest merging this here (which doesn't change any existing behaviour), and work on updating uses of IOContext to use hints rather than ReadAdvice in another PR

@thecoop thecoop marked this pull request as ready for review April 15, 2025 13:12
@thecoop
Copy link
Contributor Author

thecoop commented Apr 22, 2025

@jpountz @rmuir What are your thoughts? Dependent PRs using this functionality are linked in

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

I like the general idea of tracking more information about what is being read on IOContext and transferring the ownership of computing the appropriate read advice from codecs to directories. I left some comments on some implementation details that confused me a bit (in addition to the validation logic like Robert).

@thecoop thecoop requested review from ChrisHegarty and jpountz April 28, 2025 09:39
Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

I left some small comments but the change otherwise looks good to me!

Copy link
Contributor

@ChrisHegarty ChrisHegarty left a comment

Choose a reason for hiding this comment

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

LGTM

@ChrisHegarty ChrisHegarty merged commit bb76f0a into apache:main Apr 30, 2025
7 checks passed
ChrisHegarty pushed a commit that referenced this pull request Apr 30, 2025
Refactor IOContext and create FileOpenHint to specify how files are likely to be accessed once opened. This is the first PR of several to move from specifying ReadAdvice directly, to specifying the file usage context as hints and the ReadAdvice being inferred from the hints inside Directory implementations.

Relates #14422
@thecoop thecoop deleted the iocontext-split branch April 30, 2025 08:25
weizijun added a commit to weizijun/lucene that referenced this pull request Apr 30, 2025
* main: (51 commits)
  Fix ECJ compiler config for Java 24 (also affects Eclipse IDE)
  Correct shebang in gradlew. apache#14592
  Overwrite gradlew scripts with up-to-date ones and apply Lucene customizations. (apache#14592)
  Remove abstractions of MMapDirectory and its "fake" MR-JAR support and move it to main sourceSet (vectors untouched) (apache#14564)
  deps(java): bump org.gradle.toolchains.foojay-resolver-convention (apache#14573)
  deps(java): bump com.gradle.develocity from 3.18.2 to 4.0.1 (apache#14585)
  deps(java): bump nl.littlerobots.version-catalog-update (apache#14568)
  Bump expected base Java version to 24. apache#14533
  Create file open hints on IOContext to replace ReadAdvice (apache#14482)
  deps(java): bump com.github.ben-manes.versions from 0.51.0 to 0.52.0 (apache#14574)
  deps(java): bump org.owasp.dependencycheck from 7.2.0 to 12.1.1 (apache#14584)
  deps(java): bump org.eclipse.jgit:org.eclipse.jgit (apache#14579)
  deps(java): bump com.diffplug.spotless from 6.9.1 to 7.0.3 (apache#14588)
  deps(java): bump com.gradle.common-custom-user-data-gradle-plugin (apache#14587)
  deps(java): bump net.ltgt.errorprone from 4.1.0 to 4.2.0 (apache#14567)
  deps(java): bump org.locationtech.jts:jts-core from 1.17.0 to 1.20.0 (apache#14586)
  deps(java): bump org.apache.opennlp:opennlp-tools from 2.5.3 to 2.5.4 (apache#14580)
  deps(java): bump asm from 9.6 to 9.8 (apache#14578)
  deps(java): bump commons-codec:commons-codec from 1.17.2 to 1.18.0 (apache#14581)
  deps(java): bump net.java.dev.javacc:javacc from 7.0.12 to 7.0.13 (apache#14576)
  ...

# Conflicts:
#	lucene/CHANGES.txt
ChrisHegarty pushed a commit that referenced this pull request May 9, 2025
Followon from #14482.

ReadAdvice is now only really used by MMapDirectory, no longer part of Directory.

This PR doesn't change any behaviour, it just replicates the ReadAdvice that would be used using hints + MMapDirectory.toReadAdvice.
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.

4 participants