@Beta public class PredicateIndexBuilder extends Object
PredicateIndex
.
When creating a PredicateIndexBuilder, you must specify an arity. This is used for range features, and is a trade-off of index size vs. query speed. Higher arities gives larger index but faster search.
indexDocument(int, Predicate)
takes a document id and a predicate to insert into the index.
Predicates should be specified using the predicate syntax described in the documentation.
Create the Predicate
objects using Predicate.fromString(String)
.
Use build()
to create an instance of PredicateIndex
.
Modifier and Type | Class and Description |
---|---|
static class |
PredicateIndexBuilder.PredicateIndexStats
A collection of metrics about the currently built
PredicateIndex . |
Modifier and Type | Field and Description |
---|---|
private com.yahoo.search.predicate.index.SimpleIndex.Builder |
boundsIndexBuilder |
private Config |
config |
private com.yahoo.search.predicate.index.conjunction.ConjunctionIndexBuilder |
conjunctionIndexBuilder |
private com.yahoo.search.predicate.index.SimpleIndex.Builder |
conjunctionIntervalIndexBuilder |
private int |
documentIdCounter |
private int |
highestIntervalEnd |
private List<Short> |
intervalEndsBuilder |
private com.yahoo.search.predicate.index.SimpleIndex.Builder |
intervalIndexBuilder |
private com.yahoo.search.predicate.index.PredicateIntervalStore.Builder |
intervalStoreBuilder |
private List<Byte> |
minFeatureIndexBuilder |
private int |
nZStarDocuments |
private int |
nZStarIntervals |
private com.yahoo.search.predicate.index.PredicateOptimizer |
optimizer |
private Set<Integer> |
seenIds |
private List<Integer> |
zeroConstraintDocuments |
Constructor and Description |
---|
PredicateIndexBuilder(Config config)
Creates a PredicateIndexBuilder based on a Config object.
|
PredicateIndexBuilder(int arity)
Creates a PredicateIndexBuilder with default upper and lower bounds.
|
PredicateIndexBuilder(int arity,
long lowerBound,
long upperBound)
Creates a PredicateIndexBuilder.
|
Modifier and Type | Method and Description |
---|---|
private void |
aggregateZStarStatistics(Map<Long,List<Integer>> intervalMap) |
PredicateIndex |
build() |
PredicateIndexBuilder.PredicateIndexStats |
getStats()
Retrieve metrics about the current index.
|
int |
getZeroConstraintDocCount() |
void |
indexDocument(int docId,
com.yahoo.document.predicate.Predicate predicate)
Indexes a predicate with the given id.
|
private void |
indexDocument(int docId,
com.yahoo.search.predicate.annotator.PredicateTreeAnnotations annotations) |
private void |
indexDocumentBoundsFeatures(int docId,
Map<Long,List<com.yahoo.search.predicate.index.IntervalWithBounds>> boundsMap) |
private void |
indexDocumentConjunctions(int docId,
Map<com.yahoo.search.predicate.index.conjunction.IndexableFeatureConjunction,List<Integer>> featureConjunctions) |
private void |
indexDocumentFeatures(int docId,
Map<Long,List<Integer>> intervalMap) |
private void |
indexZeroConstraintDocument(int docId) |
private static boolean |
isAlwaysMatchingDocument(com.yahoo.document.predicate.Predicate p) |
private static boolean |
isNeverMatchingDocument(com.yahoo.document.predicate.Predicate p) |
private final com.yahoo.search.predicate.index.SimpleIndex.Builder intervalIndexBuilder
private final com.yahoo.search.predicate.index.SimpleIndex.Builder boundsIndexBuilder
private final com.yahoo.search.predicate.index.SimpleIndex.Builder conjunctionIntervalIndexBuilder
private final com.yahoo.search.predicate.index.conjunction.ConjunctionIndexBuilder conjunctionIndexBuilder
private final com.yahoo.search.predicate.index.PredicateIntervalStore.Builder intervalStoreBuilder
private final com.yahoo.search.predicate.index.PredicateOptimizer optimizer
private final Config config
private int documentIdCounter
private int nZStarDocuments
private int nZStarIntervals
private int highestIntervalEnd
public PredicateIndexBuilder(int arity)
arity
- The arity to use when indexing range predicates.
Small arity gives smaller index, but more expensive searches.public PredicateIndexBuilder(int arity, long lowerBound, long upperBound)
arity
- The arity to use when indexing range predicates.
Small arity gives smaller index, but more expensive searches.lowerBound
- The lower bound for the range of values used by range predicates.upperBound
- The upper bound for the range of values used by range predicates.public PredicateIndexBuilder(Config config)
config
- Configuration for the PredicateIndexBuilder.public void indexDocument(int docId, com.yahoo.document.predicate.Predicate predicate)
docId
- A 32-bit document id, returned in the Hit objects when the predicate matches.predicate
- The predicate to index.private static boolean isAlwaysMatchingDocument(com.yahoo.document.predicate.Predicate p)
private static boolean isNeverMatchingDocument(com.yahoo.document.predicate.Predicate p)
private void indexZeroConstraintDocument(int docId)
private void indexDocument(int docId, com.yahoo.search.predicate.annotator.PredicateTreeAnnotations annotations)
private void indexDocumentFeatures(int docId, Map<Long,List<Integer>> intervalMap)
private void indexDocumentBoundsFeatures(int docId, Map<Long,List<com.yahoo.search.predicate.index.IntervalWithBounds>> boundsMap)
private void indexDocumentConjunctions(int docId, Map<com.yahoo.search.predicate.index.conjunction.IndexableFeatureConjunction,List<Integer>> featureConjunctions)
public PredicateIndex build()
public int getZeroConstraintDocCount()
public PredicateIndexBuilder.PredicateIndexStats getStats()
Copyright © 2018. All rights reserved.