Skip to content

Commit e319cd9

Browse files
committed
Use specific IOContext class
1 parent 5b98334 commit e319cd9

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/store/input/CachedBlobContainerIndexInput.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
import org.apache.logging.log4j.LogManager;
1111
import org.apache.logging.log4j.Logger;
12+
import org.apache.lucene.store.FlushInfo;
1213
import org.apache.lucene.store.IOContext;
14+
import org.apache.lucene.store.MergeInfo;
1315
import org.apache.lucene.store.ReadAdvice;
1416
import org.elasticsearch.blobcache.BlobCacheUtils;
1517
import org.elasticsearch.blobcache.common.ByteRange;
@@ -21,6 +23,8 @@
2123
import java.io.IOException;
2224
import java.io.InputStream;
2325
import java.nio.ByteBuffer;
26+
import java.util.Optional;
27+
import java.util.Set;
2428
import java.util.concurrent.atomic.AtomicLong;
2529
import java.util.function.Predicate;
2630
import java.util.function.Supplier;
@@ -36,7 +40,42 @@ public class CachedBlobContainerIndexInput extends MetadataCachingIndexInput {
3640
* a complete part of the {@link #fileInfo} at once in the cache and should not be
3741
* used for anything else than what the {@link #prefetchPart(int, Supplier)} method does.
3842
*/
39-
public static final IOContext CACHE_WARMING_CONTEXT = IOContext.DEFAULT.withReadAdvice(ReadAdvice.NORMAL);
43+
public static final IOContext CACHE_WARMING_CONTEXT = new IOContext() {
44+
@Override
45+
public Context context() {
46+
return Context.DEFAULT;
47+
}
48+
49+
@Override
50+
public MergeInfo mergeInfo() {
51+
return null;
52+
}
53+
54+
@Override
55+
public FlushInfo flushInfo() {
56+
return null;
57+
}
58+
59+
@Override
60+
public Set<FileOpenHint> hints() {
61+
return Set.of();
62+
}
63+
64+
@Override
65+
public IOContext withHints(FileOpenHint... hints) {
66+
return this;
67+
}
68+
69+
@Override
70+
public Optional<ReadAdvice> readAdvice() {
71+
return Optional.of(ReadAdvice.NORMAL);
72+
}
73+
74+
@Override
75+
public IOContext withReadAdvice(ReadAdvice advice) {
76+
return this;
77+
}
78+
};
4079

4180
private static final Logger logger = LogManager.getLogger(CachedBlobContainerIndexInput.class);
4281

0 commit comments

Comments
 (0)