Class LucenePrimaryKeySegmentIndexV2
java.lang.Object
com.apple.foundationdb.record.lucene.LucenePrimaryKeySegmentIndexV2
- All Implemented Interfaces:
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 classes/interfaces inherited from interface com.apple.foundationdb.record.lucene.LucenePrimaryKeySegmentIndex
LucenePrimaryKeySegmentIndex.DocumentIndexEntry
-
Constructor Summary
Constructors -
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)
-
Constructor Details
-
LucenePrimaryKeySegmentIndexV2
-
-
Method Details
-
readAllEntries
- Specified by:
readAllEntries
in interfaceLucenePrimaryKeySegmentIndex
-
findSegments
- Specified by:
findSegments
in interfaceLucenePrimaryKeySegmentIndex
- Throws:
IOException
-
findDocument
@Nullable public LucenePrimaryKeySegmentIndex.DocumentIndexEntry findDocument(@Nonnull org.apache.lucene.index.DirectoryReader directoryReader, @Nonnull Tuple primaryKey) throws IOException Description copied from interface:LucenePrimaryKeySegmentIndex
Find document in index for direct delete.- Specified by:
findDocument
in interfaceLucenePrimaryKeySegmentIndex
- 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
public void addOrDeletePrimaryKeyEntry(@Nonnull byte[] primaryKey, long segmentId, int docId, boolean add, String segmentName) Description copied from interface:LucenePrimaryKeySegmentIndex
Add or delete the primary key/segment/docId from the index.- Specified by:
addOrDeletePrimaryKeyEntry
in interfaceLucenePrimaryKeySegmentIndex
- 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
Description copied from interface:LucenePrimaryKeySegmentIndex
Clears all the primary key entries for a given segment name.- Specified by:
clearForSegment
in interfaceLucenePrimaryKeySegmentIndex
- Parameters:
segmentName
- the name of the segment to clear out- Throws:
IOException
- if the primary keys cannot be parsed from stored fields
-