Class OnDemandBlockSnapshotIndexInput
java.lang.Object
org.apache.lucene.store.DataInput
org.apache.lucene.store.IndexInput
org.opensearch.index.store.remote.file.OnDemandBlockSnapshotIndexInput
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Cloneable
,org.apache.lucene.store.RandomAccessInput
public class OnDemandBlockSnapshotIndexInput
extends org.apache.lucene.store.IndexInput
This is an implementation of
This class rely on
OnDemandBlockIndexInput
where this class provides the main IndexInput using shard snapshot files.
This class rely on
TransferManager
to really fetch the snapshot files from the remote blob store and maybe cache them- Opensearch.internal:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final int
protected final int
protected final int
Variables used for block calculation and fetching.static final String
protected final org.apache.lucene.store.FSDirectory
Underlying lucene directory to open blocks and for cachingprotected final BlobStoreIndexShardSnapshot.FileInfo
FileInfo contains snapshot metadata references for this IndexInputprotected final String
File Nameprotected final boolean
Whether this index input is a clone or otherwise the root file before slicingprotected final long
Length of the virtual file, smaller than actual file size if it's a sliceprotected final long
Start offset of the virtual file : non-zero in the slice caseprotected final long
Size of the file, larger than length if it's a sliceprotected final long
Maximum size in bytes of snapshot file parts. -
Constructor Summary
ConstructorDescriptionOnDemandBlockSnapshotIndexInput
(String resourceDescription, BlobStoreIndexShardSnapshot.FileInfo fileInfo, long offset, long length, boolean isClone, org.apache.lucene.store.FSDirectory directory, TransferManager transferManager) OnDemandBlockSnapshotIndexInput
(BlobStoreIndexShardSnapshot.FileInfo fileInfo, org.apache.lucene.store.FSDirectory directory, TransferManager transferManager) -
Method Summary
Modifier and TypeMethodDescriptionstatic org.opensearch.index.store.remote.file.OnDemandBlockIndexInput.Builder
builder()
protected OnDemandBlockSnapshotIndexInput
buildSlice
(String sliceDescription, long offset, long length) Builds the actual sliced IndexInput (may apply extra offset in subclasses).clone()
protected void
cloneBlock
(org.opensearch.index.store.remote.file.OnDemandBlockIndexInput other) void
close()
protected int
protected long
protected org.apache.lucene.store.IndexInput
fetchBlock
(int blockId) Given a blockId, fetch it's IndexInput which might be partial/split/cloned oneprotected long
getActualBlockSize
(int blockId) protected List
<BlobFetchRequest.BlobPart> getBlobParts
(long blockStart, long blockEnd) Returns list of blob parts/chunks in a file for a given block.protected int
getBlock
(long pos) protected int
getBlockOffset
(long pos) protected long
getBlockStart
(int blockId) long
long
length()
byte
readByte()
final byte
readByte
(long pos) final void
readBytes
(byte[] b, int offset, int len) int
readInt()
int
readInt
(long pos) long
readLong()
long
readLong
(long pos) short
short
readShort
(long pos) final int
readVInt()
final long
void
seek
(long pos) org.apache.lucene.store.IndexInput
Methods inherited from class org.apache.lucene.store.IndexInput
getFullSliceDescription, randomAccessSlice, skipBytes, toString
Methods inherited from class org.apache.lucene.store.DataInput
readBytes, readFloats, readGroupVInt, readGroupVInts, readInts, readLongs, readMapOfStrings, readSetOfStrings, readString, readZInt, readZLong
-
Field Details
-
fileInfo
FileInfo contains snapshot metadata references for this IndexInput -
directory
protected final org.apache.lucene.store.FSDirectory directoryUnderlying lucene directory to open blocks and for caching -
fileName
File Name -
partSize
protected final long partSizeMaximum size in bytes of snapshot file parts. -
originalFileSize
protected final long originalFileSizeSize of the file, larger than length if it's a slice -
CLEANER_THREAD_NAME_PREFIX
- See Also:
-
offset
protected final long offsetStart offset of the virtual file : non-zero in the slice case -
length
protected final long lengthLength of the virtual file, smaller than actual file size if it's a slice -
isClone
protected final boolean isCloneWhether this index input is a clone or otherwise the root file before slicing -
blockSizeShift
protected final int blockSizeShiftVariables used for block calculation and fetching. blockSize must be a power of two, and is defined as 2^blockShiftSize. blockMask is defined as blockSize - 1 and is used to calculate the offset within a block. -
blockSize
protected final int blockSize -
blockMask
protected final int blockMask
-
-
Constructor Details
-
OnDemandBlockSnapshotIndexInput
public OnDemandBlockSnapshotIndexInput(BlobStoreIndexShardSnapshot.FileInfo fileInfo, org.apache.lucene.store.FSDirectory directory, TransferManager transferManager) -
OnDemandBlockSnapshotIndexInput
public OnDemandBlockSnapshotIndexInput(String resourceDescription, BlobStoreIndexShardSnapshot.FileInfo fileInfo, long offset, long length, boolean isClone, org.apache.lucene.store.FSDirectory directory, TransferManager transferManager)
-
-
Method Details
-
buildSlice
protected OnDemandBlockSnapshotIndexInput buildSlice(String sliceDescription, long offset, long length) Builds the actual sliced IndexInput (may apply extra offset in subclasses). -
fetchBlock
Given a blockId, fetch it's IndexInput which might be partial/split/cloned one- Parameters:
blockId
- to fetch for- Returns:
- fetched IndexInput
- Throws:
IOException
-
getBlobParts
Returns list of blob parts/chunks in a file for a given block. -
clone
-
getActualBlockSize
protected long getActualBlockSize(int blockId) -
slice
public org.apache.lucene.store.IndexInput slice(String sliceDescription, long offset, long length) throws IOException - Specified by:
slice
in classorg.apache.lucene.store.IndexInput
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classorg.apache.lucene.store.IndexInput
- Throws:
IOException
-
getFilePointer
public long getFilePointer()- Specified by:
getFilePointer
in classorg.apache.lucene.store.IndexInput
-
length
public long length()- Specified by:
length
in interfaceorg.apache.lucene.store.RandomAccessInput
- Specified by:
length
in classorg.apache.lucene.store.IndexInput
-
readByte
- Specified by:
readByte
in classorg.apache.lucene.store.DataInput
- Throws:
IOException
-
readShort
- Overrides:
readShort
in classorg.apache.lucene.store.DataInput
- Throws:
IOException
-
readInt
- Overrides:
readInt
in classorg.apache.lucene.store.DataInput
- Throws:
IOException
-
readLong
- Overrides:
readLong
in classorg.apache.lucene.store.DataInput
- Throws:
IOException
-
readVInt
- Overrides:
readVInt
in classorg.apache.lucene.store.DataInput
- Throws:
IOException
-
readVLong
- Overrides:
readVLong
in classorg.apache.lucene.store.DataInput
- Throws:
IOException
-
seek
- Specified by:
seek
in classorg.apache.lucene.store.IndexInput
- Throws:
IOException
-
readByte
- Specified by:
readByte
in interfaceorg.apache.lucene.store.RandomAccessInput
- Throws:
IOException
-
readShort
- Specified by:
readShort
in interfaceorg.apache.lucene.store.RandomAccessInput
- Throws:
IOException
-
readInt
- Specified by:
readInt
in interfaceorg.apache.lucene.store.RandomAccessInput
- Throws:
IOException
-
readLong
- Specified by:
readLong
in interfaceorg.apache.lucene.store.RandomAccessInput
- Throws:
IOException
-
readBytes
- Specified by:
readBytes
in classorg.apache.lucene.store.DataInput
- Throws:
IOException
-
cloneBlock
protected void cloneBlock(org.opensearch.index.store.remote.file.OnDemandBlockIndexInput other) -
getBlock
protected int getBlock(long pos) -
getBlockOffset
protected int getBlockOffset(long pos) -
getBlockStart
protected long getBlockStart(int blockId) -
currentBlockStart
protected long currentBlockStart() -
currentBlockPosition
protected int currentBlockPosition() -
builder
public static org.opensearch.index.store.remote.file.OnDemandBlockIndexInput.Builder builder()
-