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

@API(EXPERIMENTAL) public class FDBIndexInput extends org.apache.lucene.store.IndexInput
Class that handles reading data cut into blocks (KeyValue) backed by an FDB keyspace.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    FDBIndexInput(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 Type
    Method
    Description
    void
    Close IndexInput (NoOp).
    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.
    long
    The current relative position not including any offsets provided by slices.
    long
    The total length of the input provided by MetaData stored in the metadata keyspace.
    int
    prefetch(int beginBlock, int length)
    Prefetches the blocks from the underlying directory without manipulating the FDBInput.
    byte
    Read a byte based on the current relative position taking into account the absolute position (slice).
    void
    readBytes(byte[] bytes, int offset, int length)
    Read bytes based on the offset and taking into account the absolute position.
    void
    seek(long offset)
    Seeks to the offset provided.
    org.apache.lucene.store.IndexInput
    slice(String sliceDescription, long offset, long length)
    This 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, toString

    Methods inherited from class org.apache.lucene.store.DataInput

    readBytes, readInt, readLELongs, readLong, readMapOfStrings, readSetOfStrings, readShort, readString, readVInt, readVLong, readZInt, readZLong, skipBytes

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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 read
      fdbDirectory - 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 logging
      fileName - opaque description of file; used for logging
      fdbDirectory - FDB directory mapping
      reference - future Reference
      initialOffset - initialOffset
      position - currentBlockPosition
      currentBlock - block
      currentData - future with CurrentData Fetch
      Throws:
      IOException - exception
  • Method Details

    • close

      public void close()
      Close IndexInput (NoOp).
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class org.apache.lucene.store.IndexInput
    • getFilePointer

      public long getFilePointer()
      The current relative position not including any offsets provided by slices.
      Specified by:
      getFilePointer in class org.apache.lucene.store.IndexInput
      Returns:
      current relative position
    • seek

      public void seek(long offset) throws IOException
      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:
      seek in class org.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:
      length in class org.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:
      slice in class org.apache.lucene.store.IndexInput
      Parameters:
      sliceDescription - new resourceDescription of Slice
      offset - offset
      length - length
      Returns:
      indexInput
      Throws:
      IOException - exception
    • readByte

      public byte readByte() throws IOException
      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:
      readByte in class org.apache.lucene.store.DataInput
      Returns:
      byte
      Throws:
      IOException - exception
    • readBytes

      public void readBytes(@Nonnull byte[] bytes, int offset, int length) throws IOException
      Read bytes based on the offset and taking into account the absolute position. Perform asynchronous read aheads when required.
      Specified by:
      readBytes in class org.apache.lucene.store.DataInput
      Parameters:
      bytes - bytes
      offset - offset
      length - 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