Module org.elasticsearch.server
Class PrefixedPartitionsWriter
java.lang.Object
org.elasticsearch.index.codec.tsdb.PrefixedPartitionsWriter
- All Implemented Interfaces:
SortedFieldObserver
Writes prefix-based partition metadata for the primary sort field during segment flush. Terms are grouped by their first
PARTITION_PREFIX_BITS bits, and the starting document for each prefix group is recorded. This enables the query engine
to partition work by prefix without scanning all doc values.
Usage is two-pass: first call onTerm(org.apache.lucene.util.BytesRef, long) for each term during the terms dict write, then call prepareForDocs()
to compact the prefix-to-ordinal mapping, and finally call onDoc(int, long) for each ordinal during the numeric field write.
// Pass 1: track terms during terms dict write
PrefixedPartitionsWriter writer = new PrefixedPartitionsWriter();
for (BytesRef term = termsEnum.next(); term != null; term = termsEnum.next()) {
writer.onTerm(term, termsEnum.ord());
}
// Transition: compact prefix-to-ordinal mapping
writer.prepareForDocs();
// Pass 2: track start docs
for (int doc = values.nextDoc(); doc != NO_MORE_DOCS; doc = values.nextDoc()) {
writer.onDoc(doc, values.ordValue());
}
writer.flush(data, meta);
- See Also:
-
Field Summary
FieldsFields inherited from interface org.elasticsearch.index.codec.tsdb.SortedFieldObserver
NOOP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidflush(org.apache.lucene.store.IndexOutput data, org.apache.lucene.store.IndexOutput meta) Writes accumulated metadata to the segment outputs.voidonDoc(int docId, long ord) Called once per document during the numeric ordinals write.voidonTerm(org.apache.lucene.util.BytesRef term, long ord) Called once per term during the terms dictionary write.voidCalled after all terms have been written and before the document pass begins.
-
Field Details
-
PARTITION_PREFIX_BITS
public static final int PARTITION_PREFIX_BITS- See Also:
-
BE_INT
-
-
Constructor Details
-
PrefixedPartitionsWriter
public PrefixedPartitionsWriter()
-
-
Method Details
-
onTerm
public void onTerm(org.apache.lucene.util.BytesRef term, long ord) Description copied from interface:SortedFieldObserverCalled once per term during the terms dictionary write.- Specified by:
onTermin interfaceSortedFieldObserver- Parameters:
term- the term bytesord- the term ordinal
-
prepareForDocs
public void prepareForDocs()Description copied from interface:SortedFieldObserverCalled after all terms have been written and before the document pass begins.- Specified by:
prepareForDocsin interfaceSortedFieldObserver
-
onDoc
public void onDoc(int docId, long ord) Description copied from interface:SortedFieldObserverCalled once per document during the numeric ordinals write.- Specified by:
onDocin interfaceSortedFieldObserver- Parameters:
docId- the document IDord- the ordinal value for this document
-
flush
public void flush(org.apache.lucene.store.IndexOutput data, org.apache.lucene.store.IndexOutput meta) throws IOException Description copied from interface:SortedFieldObserverWrites accumulated metadata to the segment outputs.- Specified by:
flushin interfaceSortedFieldObserver- Parameters:
data- the data output streammeta- the metadata output stream- Throws:
IOException
-