Sh-Zh-7 commented on code in PR #17280:
URL: https://github.com/apache/iotdb/pull/17280#discussion_r2923245031
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/Partition.java:
##########
@@ -27,185 +28,195 @@
import org.apache.tsfile.utils.Binary;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
public class Partition {
- private final List<TsBlock> tsBlocks;
+ private final List<Column[]> segments;
private int cachedPositionCount = -1;
public Partition(List<TsBlock> tsBlocks, int startIndexInFirstBlock, int
endIndexInLastBlock) {
+ this.segments = new ArrayList<>(tsBlocks.size());
if (tsBlocks.size() == 1) {
int length = endIndexInLastBlock - startIndexInFirstBlock;
- this.tsBlocks =
-
Collections.singletonList(tsBlocks.get(0).getRegion(startIndexInFirstBlock,
length));
- return;
+ TsBlock region = tsBlocks.get(0).getRegion(startIndexInFirstBlock,
length);
+ segments.add(region.getValueColumns());
+ } else {
+ TsBlock firstBlock = tsBlocks.get(0).subTsBlock(startIndexInFirstBlock);
+ segments.add(firstBlock.getValueColumns());
+ for (int i = 1; i < tsBlocks.size() - 1; i++) {
+ segments.add(tsBlocks.get(i).getValueColumns());
+ }
+ TsBlock lastBlock = tsBlocks.get(tsBlocks.size() - 1).getRegion(0,
endIndexInLastBlock);
+ segments.add(lastBlock.getValueColumns());
}
+ }
- this.tsBlocks = new ArrayList<>(tsBlocks.size());
- // First TsBlock
- TsBlock firstBlock = tsBlocks.get(0).subTsBlock(startIndexInFirstBlock);
- this.tsBlocks.add(firstBlock);
- // Middle TsBlock
- for (int i = 1; i < tsBlocks.size() - 1; i++) {
- this.tsBlocks.add(tsBlocks.get(i));
+ public Partition(List<Slice> slices) {
+ this.segments = new ArrayList<>(slices.size());
+ for (Slice slice : slices) {
+ segments.add(slice.getRequiredColumns());
}
- // Last TsBlock
- TsBlock lastBlock = tsBlocks.get(tsBlocks.size() - 1).getRegion(0,
endIndexInLastBlock);
- this.tsBlocks.add(lastBlock);
+ }
+
+ private Partition(List<Column[]> segments, boolean directSegments) {
+ this.segments = segments;
}
public int getPositionCount() {
if (cachedPositionCount == -1) {
- // Lazy initialized
cachedPositionCount = 0;
- for (TsBlock block : tsBlocks) {
- cachedPositionCount += block.getPositionCount();
+ for (Column[] segment : segments) {
+ cachedPositionCount += segment[0].getPositionCount();
}
Review Comment:
won't happen.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]