Interface LucenePrimaryKeySegmentIndex

All Known Implementing Classes:
LucenePrimaryKeySegmentIndexV1, LucenePrimaryKeySegmentIndexV2

public interface LucenePrimaryKeySegmentIndex
Maintain a B-tree index of primary key to segment and doc id. This allows for efficient deleting of a document given that key, such as when doing index maintenance from an update.
  • Method Details

    • readAllEntries

      List<List<Object>> readAllEntries()
    • findSegments

      List<String> findSegments(@Nonnull Tuple primaryKey) throws IOException
      Throws:
      IOException
    • findDocument

      @Nullable LucenePrimaryKeySegmentIndex.DocumentIndexEntry findDocument(@Nonnull org.apache.lucene.index.DirectoryReader directoryReader, @Nonnull Tuple primaryKey) throws IOException
      Find document in index for direct delete.
      Parameters:
      directoryReader - a NRT reader
      primaryKey - the document's record's primary key
      Returns:
      an entry with the leaf reader and document id in that segment or null if not found
      Throws:
      IOException
      See Also:
      • IndexWriter.tryDeleteDocument(org.apache.lucene.index.IndexReader, int)
    • addOrDeletePrimaryKeyEntry

      void addOrDeletePrimaryKeyEntry(@Nonnull byte[] primaryKey, long segmentId, int docId, boolean add, String segmentName)
      Add or delete the primary key/segment/docId from the index.
      Parameters:
      primaryKey - the primary ey of the record
      segmentId - the id of the segment (see FDBDirectory.primaryKeySegmentId(java.lang.String, boolean))
      docId - the document id within the segment
      add - whether to add (true) or delete (false) the entry
      segmentName - name associated with the segment, for logging
    • clearForSegment

      void clearForSegment(String segmentName) throws IOException
      Clears all the primary key entries for a given segment name.
      Parameters:
      segmentName - the name of the segment to clear out
      Throws:
      IOException - if the primary keys cannot be parsed from stored fields