You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/04/14 01:03:25 UTC
[GitHub] [iotdb] JackieTien97 commented on a diff in pull request #5513: [IOTDB-2911][Part 1: Underlying Data Structures] TransformOperator: operator implementation for nested expression evaluation
JackieTien97 commented on code in PR #5513:
URL: https://github.com/apache/iotdb/pull/5513#discussion_r850001225
##########
tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/block/TsBlock.java:
##########
@@ -240,14 +256,44 @@ public TimeValuePair nextTimeValuePair() {
@Override
public TimeValuePair currentTimeValuePair() {
return new TimeValuePair(
- timeColumn.getLong(index), valueColumns[0].getTsPrimitiveType(index));
+ timeColumn.getLong(rowIndex), valueColumns[columnIndex].getTsPrimitiveType(rowIndex));
}
@Override
public void close() {}
}
- private class AlignedTsBlockIterator extends TsBlockIterator {
+ public class TsBlockRowIterator implements Iterator<Object[]> {
+
+ protected int rowIndex;
+ protected int columnCount;
+
+ public TsBlockRowIterator(int rowIndex) {
+ this.rowIndex = rowIndex;
+ columnCount = getValueColumnCount();
+ }
+
+ @Override
+ public boolean hasNext() {
+ return rowIndex < positionCount;
+ }
+
+ @Override
+ public Object[] next() {
+ int columnCount = getValueColumnCount();
+ Object[] row = new Object[columnCount + 1];
+ for (int i = 0; i < columnCount; ++i) {
+ row[i] = valueColumns[i].getObject(rowIndex);
+ }
+ row[columnCount] = timeColumn.getObject(rowIndex);
Review Comment:
Why here putting the time column at last, if you really mean so, you can add java doc about it. Otherwise, intuitively we will think that time column is at the first column.
##########
tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/block/column/LongColumn.java:
##########
@@ -83,6 +83,11 @@ public long getLong(int position) {
return values[position + arrayOffset];
}
+ @Override
+ public Object getObject(int position) {
+ return getLong(position);
Review Comment:
add it for each `Column`
##########
tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/block/TsBlock.java:
##########
@@ -173,26 +174,41 @@ public Column getColumn(int columnIndex) {
return valueColumns[columnIndex];
}
- public TsBlockIterator getTsBlockIterator() {
- return new TsBlockIterator(0);
+ public TsBlockColumnIterator getTsBlockColumnIterator() {
+ return new TsBlockColumnIterator(0);
+ }
+
+ public TsBlockColumnIterator getTsBlockColumnIterator(int columnIndex) {
+ return new TsBlockColumnIterator(0, columnIndex);
+ }
+
+ public TsBlockRowIterator getTsBlockRowIterator() {
+ return new TsBlockRowIterator(0);
}
/** Only used for the batch data of vector time series. */
public IBatchDataIterator getTsBlockIterator(int subIndex) {
return new AlignedTsBlockIterator(0, subIndex);
}
- private class TsBlockIterator implements IPointReader, IBatchDataIterator {
+ private class TsBlockColumnIterator implements IPointReader, IBatchDataIterator {
Review Comment:
This inner class's name is not very clear, it will mislead us to think it's an iterator to traverse all the columns. You can rename it to like `OneColumnIterator` and add some java doc about it, like: it will only return an iterator that will traverse one time column plus one exact column which is at `columnIndex` in a row way.
##########
tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/block/column/LongColumn.java:
##########
@@ -83,6 +83,11 @@ public long getLong(int position) {
return values[position + arrayOffset];
}
+ @Override
+ public Object getObject(int position) {
+ return getLong(position);
Review Comment:
```suggestion
checkReadablePosition(position);
return getLong(position);
```
--
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: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org