JackieTien97 commented on code in PR #15735:
URL: https://github.com/apache/iotdb/pull/15735#discussion_r2176595146
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/source/LastQueryScanNode.java:
##########
@@ -162,84 +222,149 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
LastQueryScanNode that = (LastQueryScanNode) o;
- return Objects.equals(seriesPath, that.seriesPath)
+ return Objects.equals(devicePath, that.devicePath)
+ && Objects.equals(aligned, that.aligned)
+ && Objects.equals(indexOfMeasurementSchemas,
that.indexOfMeasurementSchemas)
&& Objects.equals(outputViewPath, that.outputViewPath)
&& Objects.equals(regionReplicaSet, that.regionReplicaSet);
}
@Override
public int hashCode() {
- return Objects.hash(super.hashCode(), seriesPath, outputViewPath,
regionReplicaSet);
+ return Objects.hash(
+ super.hashCode(),
+ devicePath,
+ aligned,
+ indexOfMeasurementSchemas,
+ outputViewPath,
+ regionReplicaSet);
}
@Override
public String toString() {
if (StringUtil.isNotBlank(outputViewPath)) {
return String.format(
- "LastQueryScanNode-%s:[SeriesPath: %s, ViewPath: %s, DataRegion:
%s]",
+ "LastQueryScanNode-%s:[Device: %s, Aligned: %s, Measurements: %s,
ViewPath: %s, DataRegion: %s]",
this.getPlanNodeId(),
- this.getSeriesPath(),
+ this.getDevicePath(),
+ this.aligned,
+ this.getMeasurementSchemas(),
this.getOutputViewPath(),
PlanNodeUtil.printRegionReplicaSet(getRegionReplicaSet()));
} else {
return String.format(
- "LastQueryScanNode-%s:[SeriesPath: %s, DataRegion: %s]",
+ "LastQueryScanNode-%s:[Device: %s, Aligned: %s, Measurements: %s,
DataRegion: %s]",
this.getPlanNodeId(),
- this.getSeriesPath(),
+ this.getDevicePath(),
+ this.aligned,
+ this.getMeasurementSchemas(),
PlanNodeUtil.printRegionReplicaSet(getRegionReplicaSet()));
}
}
@Override
protected void serializeAttributes(ByteBuffer byteBuffer) {
PlanNodeType.LAST_QUERY_SCAN.serialize(byteBuffer);
- seriesPath.serialize(byteBuffer);
+ devicePath.serialize(byteBuffer);
+ ReadWriteIOUtils.write(aligned, byteBuffer);
+ ReadWriteIOUtils.write(indexOfMeasurementSchemas.size(), byteBuffer);
+ for (Integer measurementSchema : indexOfMeasurementSchemas) {
+ ReadWriteIOUtils.write(measurementSchema, byteBuffer);
+ }
ReadWriteIOUtils.write(getDataNodeSeriesScanNum().get(), byteBuffer);
ReadWriteIOUtils.write(outputViewPath == null, byteBuffer);
if (outputViewPath != null) {
ReadWriteIOUtils.write(outputViewPath, byteBuffer);
}
+ ReadWriteIOUtils.write(deviceInMultiRegion, byteBuffer);
}
@Override
protected void serializeAttributes(DataOutputStream stream) throws
IOException {
PlanNodeType.LAST_QUERY_SCAN.serialize(stream);
- seriesPath.serialize(stream);
+ devicePath.serialize(stream);
+ ReadWriteIOUtils.write(aligned, stream);
+ ReadWriteIOUtils.write(indexOfMeasurementSchemas.size(), stream);
+ for (Integer measurementSchema : indexOfMeasurementSchemas) {
+ ReadWriteIOUtils.write(measurementSchema, stream);
+ }
ReadWriteIOUtils.write(getDataNodeSeriesScanNum().get(), stream);
ReadWriteIOUtils.write(outputViewPath == null, stream);
if (outputViewPath != null) {
ReadWriteIOUtils.write(outputViewPath, stream);
}
+ ReadWriteIOUtils.write(deviceInMultiRegion, stream);
}
public static LastQueryScanNode deserialize(ByteBuffer byteBuffer) {
- MeasurementPath partialPath = (MeasurementPath)
PathDeserializeUtil.deserialize(byteBuffer);
+ PartialPath devicePath = (PartialPath)
PathDeserializeUtil.deserialize(byteBuffer);
+ boolean aligned = ReadWriteIOUtils.readBool(byteBuffer);
+ int measurementSize = ReadWriteIOUtils.readInt(byteBuffer);
+ List<Integer> measurementSchemas = new ArrayList<>(measurementSize);
+ for (int i = 0; i < measurementSize; i++) {
+ measurementSchemas.add(ReadWriteIOUtils.readInt(byteBuffer));
+ }
+
int dataNodeSeriesScanNum = ReadWriteIOUtils.readInt(byteBuffer);
boolean isNull = ReadWriteIOUtils.readBool(byteBuffer);
String outputPathSymbol = isNull ? null :
ReadWriteIOUtils.readString(byteBuffer);
+ boolean deviceInMultiRegion = ReadWriteIOUtils.readBool(byteBuffer);
PlanNodeId planNodeId = PlanNodeId.deserialize(byteBuffer);
return new LastQueryScanNode(
- planNodeId, partialPath, new AtomicInteger(dataNodeSeriesScanNum),
outputPathSymbol);
+ planNodeId,
+ devicePath,
+ aligned,
+ measurementSchemas,
+ new AtomicInteger(dataNodeSeriesScanNum),
+ outputPathSymbol,
+ null,
+ deviceInMultiRegion,
+ null);
}
- @Override
- public PartialPath getPartitionPath() {
- return getSeriesPath();
+ public void setGlobalMeasurementSchemaList(List<IMeasurementSchema>
globalMeasurementSchemaList) {
+ this.globalMeasurementSchemaList = globalMeasurementSchemaList;
}
- public String outputPathSymbol() {
- if (outputViewPath == null) {
- return seriesPath.getFullPath();
- } else {
- return outputViewPath;
- }
+ public IMeasurementSchema getMeasurementSchema(int idx) {
+ int globalIdx = indexOfMeasurementSchemas.get(idx);
+ return globalMeasurementSchemaList.get(globalIdx);
+ }
+
+ public PartialPath getDevicePath() {
+ return this.devicePath;
+ }
+
+ public boolean isDeviceInMultiRegion() {
+ return deviceInMultiRegion;
+ }
+
+ public void setDeviceInMultiRegion(boolean deviceInMultiRegion) {
+ this.deviceInMultiRegion = deviceInMultiRegion;
+ }
+
+ public List<Integer> getIdxOfMeasurementSchemas() {
+ return indexOfMeasurementSchemas;
+ }
+
+ public List<IMeasurementSchema> getMeasurementSchemas() {
+ return indexOfMeasurementSchemas.stream()
+ .map(globalMeasurementSchemaList::get)
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public PartialPath getPartitionPath() {
+ return devicePath;
}
@Override
public long ramBytesUsed() {
return INSTANCE_SIZE
+ MemoryEstimationHelper.getEstimatedSizeOfAccountableObject(id)
- + MemoryEstimationHelper.getEstimatedSizeOfPartialPath(seriesPath)
+ // The memory of each String has been calculated before
+ +
MemoryEstimationHelper.getEstimatedSizeOfCopiedPartialPath(devicePath)
+ + RamUsageEstimator.shallowSizeOfInstance(Integer.class) *
indexOfMeasurementSchemas.size()
Review Comment:
```suggestion
+ RamUsageEstimator.sizeOfCollection(indexOfMeasurementSchemas,
RamUsageEstimator.shallowSizeOfInstance(Integer.class))
```
--
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]