Class MergePostingList
java.lang.Object
org.apache.cassandra.index.sai.disk.v1.postings.MergePostingList
- All Implemented Interfaces:
Closeable,AutoCloseable,PostingList
Merges multiple
PostingList which individually contain unique items into a single list.
While the individual lists contain unique items, there can be duplicate items between lists so
the class also checks for duplicates and only returns unique items in sorted order.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.cassandra.index.sai.postings.PostingList
PostingList.EmptyPostingList -
Field Summary
Fields inherited from interface org.apache.cassandra.index.sai.postings.PostingList
EMPTY, END_OF_STREAM, OFFSET_NOT_FOUND -
Method Summary
Modifier and TypeMethodDescriptionlongadvance(long targetRowID) Advances to the first row ID beyond the current that is greater than or equal to the target, and returns that row ID.voidclose()longmaximum()static PostingListmerge(List<PostingList> postings) static PostingListmerge(PriorityQueue<PeekablePostingList> postings) static PostingListmerge(PriorityQueue<PeekablePostingList> postings, Closeable onClose) longminimum()longRetrieves the next segment row ID, not including row IDs that have been returned byPostingList.advance(long).longsize()Returns the upper bound of postings in the list.
-
Method Details
-
merge
-
merge
-
merge
-
minimum
public long minimum()- Specified by:
minimumin interfacePostingList
-
maximum
public long maximum()- Specified by:
maximumin interfacePostingList
-
nextPosting
Description copied from interface:PostingListRetrieves the next segment row ID, not including row IDs that have been returned byPostingList.advance(long).- Specified by:
nextPostingin interfacePostingList- Returns:
- next segment row ID
- Throws:
IOException
-
advance
Description copied from interface:PostingListAdvances to the first row ID beyond the current that is greater than or equal to the target, and returns that row ID. Exhausts the iterator and returnsPostingList.END_OF_STREAMif the target is greater than the highest row ID.Note: Callers must use the return value of this method before calling
PostingList.nextPosting(), as calling that method will return the next posting, not the one to which we have just advanced.- Specified by:
advancein interfacePostingList- Parameters:
targetRowID- target row ID to advance to- Returns:
- first segment row ID which is >= the target row ID or
PostingList.END_OF_STREAMif one does not exist - Throws:
IOException
-
size
public long size()Description copied from interface:PostingListReturns the upper bound of postings in the list. During a merge individual postings may be de-duplicated, so we can't return the exact size only the upper bound of the size.- Specified by:
sizein interfacePostingList
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfacePostingList
-