|
@@ -39,6 +39,7 @@ import org.elasticsearch.xpack.searchablesnapshots.store.SearchableSnapshotDirec
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
+import java.io.UncheckedIOException;
|
|
|
import java.nio.ByteBuffer;
|
|
|
import java.nio.channels.FileChannel;
|
|
|
import java.util.Objects;
|
|
@@ -145,6 +146,35 @@ public abstract class MetadataCachingIndexInput extends BlobCacheBufferedIndexIn
|
|
|
assert getBufferSize() <= BlobStoreCacheService.DEFAULT_CACHED_BLOB_SIZE; // must be able to cache at least one buffer's worth
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Clone constructor, will mark this as cloned.
|
|
|
+ */
|
|
|
+ protected MetadataCachingIndexInput(MetadataCachingIndexInput input) {
|
|
|
+ this(
|
|
|
+ input.logger,
|
|
|
+ "(clone of) " + input,
|
|
|
+ input.directory,
|
|
|
+ input.fileInfo,
|
|
|
+ input.context,
|
|
|
+ input.stats,
|
|
|
+ input.offset,
|
|
|
+ input.compoundFileOffset,
|
|
|
+ input.length,
|
|
|
+ input.cacheFileReference,
|
|
|
+ input.defaultRangeSize,
|
|
|
+ input.recoveryRangeSize,
|
|
|
+ input.headerBlobCacheByteRange,
|
|
|
+ input.footerBlobCacheByteRange
|
|
|
+ );
|
|
|
+ this.isClone = true;
|
|
|
+ try {
|
|
|
+ seek(input.getFilePointer());
|
|
|
+ } catch (IOException e) {
|
|
|
+ assert false : e;
|
|
|
+ throw new UncheckedIOException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Detects read operations that are executed on the last 16 bytes of the index input which is where Lucene stores the footer checksum
|
|
|
* of Lucene files. If such a read is detected this method tries to complete the read operation by reading the checksum from the
|