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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addOrDeletePrimaryKeyEntry
(byte[] primaryKey, long segmentId, int docId, boolean add, String segmentName) Add or delete the primary key/segment/docId from the index.void
clearForSegment
(String segmentName) Clears all the primary key entries for a given segment name.findDocument
(org.apache.lucene.index.DirectoryReader directoryReader, Tuple primaryKey) Find document in index for direct delete.findSegments
(Tuple primaryKey)
-
Method Details
-
readAllEntries
-
findSegments
- 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 readerprimaryKey
- 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 recordsegmentId
- the id of the segment (seeFDBDirectory.primaryKeySegmentId(java.lang.String, boolean)
)docId
- the document id within the segmentadd
- whether to add (true
) or delete (false
) the entrysegmentName
- name associated with the segment, for logging
-
clearForSegment
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
-