Jackie-Jiang commented on code in PR #10077: URL: https://github.com/apache/pinot/pull/10077#discussion_r1063842531
########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/startree/CachedStarTreeNode.java: ########## @@ -0,0 +1,114 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.segment.local.startree; + +import java.util.Iterator; +import org.apache.pinot.segment.spi.index.startree.StarTreeNode; + + +/** + * Getting all fields in current StarTree node immediately and cache them, instead of jumping back and forth inside the + * data buffer to read fields from parent and children nodes while doing BFS over the StarTree index tree, making the + * buffer reads a lot more sequential. + */ +public class CachedStarTreeNode implements StarTreeNode { + private final StarTreeNode _delegate; + private final int _dimensionId; + private final int _dimensionValue; + private final int _startDocId; + private final int _endDocId; + private final int _aggregatedDocId; + private final int _numChildren; + + public CachedStarTreeNode(StarTreeNode starTreeNode) { + _delegate = starTreeNode; + _dimensionId = _delegate.getDimensionId(); + _dimensionValue = _delegate.getDimensionValue(); + _startDocId = _delegate.getStartDocId(); + _endDocId = _delegate.getEndDocId(); + _aggregatedDocId = _delegate.getAggregatedDocId(); + _numChildren = _delegate.getNumChildren(); + } + + @Override + public int getDimensionId() { + return _dimensionId; + } + + @Override + public int getDimensionValue() { + return _dimensionValue; + } + + @Override + public int getChildDimensionId() { + return _delegate.getChildDimensionId(); + } + + @Override + public int getStartDocId() { + return _startDocId; + } + + @Override + public int getEndDocId() { + return _endDocId; + } + + @Override + public int getAggregatedDocId() { + return _aggregatedDocId; + } + + @Override + public int getNumChildren() { + return _numChildren; + } + + @Override + public boolean isLeaf() { + return _delegate.isLeaf(); + } + + @Override + public StarTreeNode getChildForDimensionValue(int dimensionValue) { + return new CachedStarTreeNode(_delegate.getChildForDimensionValue(dimensionValue)); Review Comment: Need to check if `_delegate.getChildForDimensionValue(dimensionValue)` is `null` ########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/startree/OffHeapStarTreeNode.java: ########## @@ -39,11 +39,13 @@ public class OffHeapStarTreeNode implements StarTreeNode { private final PinotDataBuffer _dataBuffer; private final int _nodeId; private final int _firstChildId; + private final int _lastChildId; Review Comment: Is this change required? This will add extra memory footprint to the star-tree node ########## pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java: ########## @@ -280,6 +280,7 @@ public static class QueryOptionKey { public static final String SKIP_UPSERT = "skipUpsert"; public static final String USE_STAR_TREE = "useStarTree"; public static final String SCAN_STAR_TREE_NODES = "scanStarTreeNodes"; + public static final String SCAN_STAR_TREE_NODES_ON_HEAP = "scanStarTreeNodesOnHeap"; Review Comment: Should we come up with one single query option for the data locality based optimizations? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org