Skip to content

Commit

Permalink
disabling cache and adding loggers
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <[email protected]>
  • Loading branch information
bharath-techie committed Feb 16, 2024
1 parent b9f124d commit e48e60c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion server/src/main/java/org/opensearch/index/IndexModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public Iterator<Setting<?>> settings() {
// whether to use the query cache
public static final Setting<Boolean> INDEX_QUERY_CACHE_ENABLED_SETTING = Setting.boolSetting(
"index.queries.cache.enabled",
true,
false,
Property.IndexScope
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ public class StarTreeFilter {
static class StarTreeResult {
final DocIdSetBuilder _matchedDocIds;
final Set<String> _remainingPredicateColumns;
final int numOfMatchedDocs;

StarTreeResult(DocIdSetBuilder matchedDocIds, Set<String> remainingPredicateColumns) {
StarTreeResult(DocIdSetBuilder matchedDocIds, Set<String> remainingPredicateColumns, int numOfMatchedDocs) {
_matchedDocIds = matchedDocIds;
_remainingPredicateColumns = remainingPredicateColumns;
this.numOfMatchedDocs = numOfMatchedDocs;
}
}

Expand All @@ -63,9 +65,10 @@ static class StarTreeResult {
private final Set<String> _groupByColumns;

DocIdSetBuilder docsWithField;

DocIdSetBuilder.BulkAdder adder;
Map<String, NumericDocValues> dimValueMap;

int docNum;
public StarTreeFilter(
StarTreeAggregatedValues starTreeAggrStructure,
Map<String, List<Predicate<Long>>> predicateEvaluators,
Expand All @@ -79,6 +82,7 @@ public StarTreeFilter(

// TODO : this should be the maximum number of doc values
docsWithField = new DocIdSetBuilder(Integer.MAX_VALUE);
docNum = 0;
}

/**
Expand All @@ -92,30 +96,44 @@ public StarTreeFilter(

// 1706268600 / (60*60*1000) * (60*60*1000)
public DocIdSetIterator getStarTreeResult() throws IOException {
long startTime = System.nanoTime();
StarTreeResult starTreeResult = traverseStarTree();
logger.info("Star tree traversal took : {}", System.nanoTime() - startTime);
startTime = System.nanoTime();
List<DocIdSetIterator> andIterators = new ArrayList<>();
andIterators.add(starTreeResult._matchedDocIds.build().iterator());
DocIdSetIterator docIdSetIterator = andIterators.get(0);
int docCount = 0;
for (String remainingPredicateColumn : starTreeResult._remainingPredicateColumns) {
// TODO : set to max value of doc values
DocIdSetBuilder builder = new DocIdSetBuilder(Integer.MAX_VALUE);
DocIdSetBuilder builder = new DocIdSetBuilder(starTreeResult.numOfMatchedDocs);
List<Predicate<Long>> compositePredicateEvaluators = _predicateEvaluators.get(remainingPredicateColumn);
SortedNumericDocValues ndv = DocValues.singleton(this.dimValueMap.get(remainingPredicateColumn));

long ndvStartTime1 = System.nanoTime();
while (docIdSetIterator.nextDoc() != NO_MORE_DOCS) {
docCount++;
long ndvStartTime = System.nanoTime();
int docID = docIdSetIterator.docID();
ndv.advanceExact(docID);
long value = ndv.nextValue();
logger.info("Advancing took : {}", System.nanoTime() - ndvStartTime);
ndvStartTime = System.nanoTime();
for (Predicate<Long> compositePredicateEvaluator : compositePredicateEvaluators) {
// TODO : this might be expensive as its done against all doc values docs
if (compositePredicateEvaluator.test(value)) {
builder.grow(1).add(docID);
break;
}
}
logger.info("Predicate took : {}", System.nanoTime() - ndvStartTime);
}
logger.info("Overall ndv took : {}", System.nanoTime() - ndvStartTime1);
long buildTime = System.nanoTime();
docIdSetIterator = builder.build().iterator();
logger.info("Builder took : {}", System.nanoTime() - buildTime);
}
logger.info("Doc value num : {}" , docCount);
logger.info("Rest of tree traversal took : {}", System.nanoTime() - startTime);
return docIdSetIterator;
}

Expand All @@ -129,7 +147,7 @@ private StarTreeResult traverseStarTree() throws IOException {

StarTree starTree = _starTree;
List<String> dimensionNames = starTree.getDimensionNames();
logger.info("Dimension names {}", dimensionNames);
//logger.info("Dimension names {}", dimensionNames);
StarTreeNode starTreeRootNode = starTree.getRoot();

// Track whether we have found a leaf node added to the queue. If we have found a leaf node, and
Expand Down Expand Up @@ -166,6 +184,7 @@ private StarTreeResult traverseStarTree() throws IOException {
// If all predicate columns and group-by columns are matched, we can use aggregated document
if (remainingPredicateColumns.isEmpty() && remainingGroupByColumns.isEmpty()) {
adder = docsWithField.grow(1);
docNum++;
adder.add(starTreeNode.getAggregatedDocId());
continue;
}
Expand All @@ -178,6 +197,7 @@ private StarTreeResult traverseStarTree() throws IOException {
if (starTreeNode.isLeaf()) {
for (long i = starTreeNode.getStartDocId(); i < starTreeNode.getEndDocId(); i++) {
adder = docsWithField.grow(1);
docNum++;
adder.add((int) i);
}
continue;
Expand Down Expand Up @@ -270,7 +290,8 @@ private StarTreeResult traverseStarTree() throws IOException {

return new StarTreeResult(
docsWithField,
globalRemainingPredicateColumns != null ? globalRemainingPredicateColumns : Collections.emptySet()
globalRemainingPredicateColumns != null ? globalRemainingPredicateColumns : Collections.emptySet(),
docNum
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ public void collect(int doc, long bucket) throws IOException {
indexMap.put(key, indexMap.size());
sumMap.put(key, dv.longValue());
}
logger.info("Sum : {}" + sumMap.get(key));
collectBucket(sub, doc, subBucketOrdinal(bucket, indexMap.get(key)));
}
}
Expand Down

0 comments on commit e48e60c

Please sign in to comment.