Class FDBIndexInput
java.lang.Object
org.apache.lucene.store.DataInput
org.apache.lucene.store.IndexInput
com.apple.foundationdb.record.lucene.directory.FDBIndexInput
- All Implemented Interfaces:
Closeable,AutoCloseable,Cloneable
Class that handles reading data cut into blocks (KeyValue) backed by an FDB keyspace.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionFDBIndexInput(String fileName, FDBDirectory fdbDirectory) Constructor to create an FDBIndexInput from a file referenced in the metadata keyspace.FDBIndexInput(String resourceDescription, String fileName, FDBDirectory fdbDirectory, CompletableFuture<FDBLuceneFileReference> reference, long initialOffset, long position, int currentBlock, CompletableFuture<byte[]> currentData) Constructor that is utilized by splice calls to take into account initial offsets and modifications to length. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close IndexInput (NoOp).intgetBlock(long position) Retrieve the appropriate indexed block taking into account the absolute position (possible splice offsets) and dividing by the block size stored in the metadata keyspace.longThe current relative position not including any offsets provided by slices.longlength()The total length of the input provided by MetaData stored in the metadata keyspace.intprefetch(int beginBlock, int length) Prefetches the blocks from the underlying directory without manipulating the FDBInput.bytereadByte()Read a byte based on the current relative position taking into account the absolute position (slice).voidreadBytes(byte[] bytes, int offset, int length) Read bytes based on the offset and taking into account the absolute position.voidseek(long offset) Seeks to the offset provided.org.apache.lucene.store.IndexInputThis takes an existing FDBIndexInput and provides a new initial offset plus a FDBLuceneFileReference that is not not backed in the metadata keyspace.Methods inherited from class org.apache.lucene.store.IndexInput
clone, getFullSliceDescription, randomAccessSlice, toStringMethods inherited from class org.apache.lucene.store.DataInput
readBytes, readInt, readLELongs, readLong, readMapOfStrings, readSetOfStrings, readShort, readString, readVInt, readVLong, readZInt, readZLong, skipBytes
-
Constructor Details
-
FDBIndexInput
public FDBIndexInput(@Nonnull String fileName, @Nonnull FDBDirectory fdbDirectory) throws IOException Constructor to create an FDBIndexInput from a file referenced in the metadata keyspace.This constructor will begin an asynchronous query (lookahead) to the first block.
- Parameters:
fileName- the name of the file being readfdbDirectory- FDB directory mapping- Throws:
IOException- exception
-
FDBIndexInput
public FDBIndexInput(@Nonnull String resourceDescription, @Nonnull String fileName, @Nonnull FDBDirectory fdbDirectory, @Nonnull CompletableFuture<FDBLuceneFileReference> reference, long initialOffset, long position, int currentBlock, @Nullable CompletableFuture<byte[]> currentData) throws IOException Constructor that is utilized by splice calls to take into account initial offsets and modifications to length.- Parameters:
resourceDescription- opaque description of file; used for loggingfileName- opaque description of file; used for loggingfdbDirectory- FDB directory mappingreference- future ReferenceinitialOffset- initialOffsetposition- currentBlockPositioncurrentBlock- blockcurrentData- future with CurrentData Fetch- Throws:
IOException- exception
-
-
Method Details
-
close
public void close()Close IndexInput (NoOp).- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classorg.apache.lucene.store.IndexInput
-
getFilePointer
public long getFilePointer()The current relative position not including any offsets provided by slices.- Specified by:
getFilePointerin classorg.apache.lucene.store.IndexInput- Returns:
- current relative position
-
seek
Seeks to the offset provided. That actual seek offset will take into account the absolute position taking into account if the IndexInput has been Sliced. If the currentBlock is the same block after the offset, no physical seek will occur.- Specified by:
seekin classorg.apache.lucene.store.IndexInput- Parameters:
offset- positionToSeekTo- Throws:
IOException- exception
-
length
public long length()The total length of the input provided by MetaData stored in the metadata keyspace.- Specified by:
lengthin classorg.apache.lucene.store.IndexInput- Returns:
- length
-
slice
@Nonnull public org.apache.lucene.store.IndexInput slice(@Nonnull String sliceDescription, long offset, long length) throws IOException This takes an existing FDBIndexInput and provides a new initial offset plus a FDBLuceneFileReference that is not not backed in the metadata keyspace.- Specified by:
slicein classorg.apache.lucene.store.IndexInput- Parameters:
sliceDescription- new resourceDescription of Sliceoffset- offsetlength- length- Returns:
- indexInput
- Throws:
IOException- exception
-
readByte
Read a byte based on the current relative position taking into account the absolute position (slice). If the next byte will be on another block, asynchronously call read ahead.- Specified by:
readBytein classorg.apache.lucene.store.DataInput- Returns:
- byte
- Throws:
IOException- exception
-
readBytes
Read bytes based on the offset and taking into account the absolute position. Perform asynchronous read aheads when required.- Specified by:
readBytesin classorg.apache.lucene.store.DataInput- Parameters:
bytes- bytesoffset- offsetlength- length- Throws:
IOException
-
getBlock
public int getBlock(long position) Retrieve the appropriate indexed block taking into account the absolute position (possible splice offsets) and dividing by the block size stored in the metadata keyspace.- Parameters:
position- current position (not counting offset)- Returns:
- block
-
prefetch
public int prefetch(int beginBlock, int length) Prefetches the blocks from the underlying directory without manipulating the FDBInput.- Parameters:
beginBlock- Block to start caching.length- number of blocks to read forward- Returns:
- length supplied
-