Skip to content

Commit

Permalink
Optimize the devicePath generation efficiency of PlanNode when deseri…
Browse files Browse the repository at this point in the history
…alizing (#12749)
  • Loading branch information
OneSizeFitsQuorum authored Jun 18, 2024
1 parent 0bb4619 commit a0750b6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ public static CreateAlignedTimeSeriesStatement createStatement(TSCreateAlignedTi
final long startTime = System.nanoTime();
// construct create aligned timeseries statement
CreateAlignedTimeSeriesStatement statement = new CreateAlignedTimeSeriesStatement();
statement.setDevicePath(new PartialPath(req.prefixPath));
statement.setDevicePath(DEVICE_PATH_CACHE.getPartialPath(req.prefixPath));
List<TSDataType> dataTypes = new ArrayList<>();
for (Integer dataType : req.dataTypes) {
dataTypes.add(TSDataType.deserialize(dataType.byteValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.iotdb.commons.exception.IllegalPathException;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.db.queryengine.plan.analyze.IAnalysis;
import org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.DataNodeDevicePathCache;
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNode;
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNodeId;
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNodeType;
Expand Down Expand Up @@ -211,7 +212,7 @@ public static CreateAlignedTimeSeriesNode deserialize(ByteBuffer byteBuffer) {
byte[] bytes = new byte[length];
byteBuffer.get(bytes);
try {
devicePath = new PartialPath(new String(bytes));
devicePath = DataNodeDevicePathCache.getInstance().getPartialPath(new String(bytes));
} catch (IllegalPathException e) {
throw new IllegalArgumentException("Can not deserialize CreateAlignedTimeSeriesNode", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ public static InsertRowNode deserialize(ByteBuffer byteBuffer) {
void subDeserialize(ByteBuffer byteBuffer) {
time = byteBuffer.getLong();
try {
devicePath = new PartialPath(ReadWriteIOUtils.readString(byteBuffer));
devicePath =
DataNodeDevicePathCache.getInstance()
.getPartialPath(ReadWriteIOUtils.readString(byteBuffer));
} catch (IllegalPathException e) {
throw new IllegalArgumentException(DESERIALIZE_ERROR, e);
}
Expand Down Expand Up @@ -741,7 +743,9 @@ protected static InsertRowNode subDeserializeFromWAL(ByteBuffer buffer) {
InsertRowNode insertNode = new InsertRowNode(new PlanNodeId(""));
insertNode.setTime(buffer.getLong());
try {
insertNode.setDevicePath(new PartialPath(ReadWriteIOUtils.readString(buffer)));
insertNode.setDevicePath(
DataNodeDevicePathCache.getInstance()
.getPartialPath(ReadWriteIOUtils.readString(buffer)));
} catch (IllegalPathException e) {
throw new IllegalArgumentException(DESERIALIZE_ERROR, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.iotdb.commons.utils.StatusUtils;
import org.apache.iotdb.commons.utils.TimePartitionUtils;
import org.apache.iotdb.db.queryengine.plan.analyze.IAnalysis;
import org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.DataNodeDevicePathCache;
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNode;
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNodeId;
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNodeType;
Expand Down Expand Up @@ -228,7 +229,9 @@ public static InsertRowsOfOneDeviceNode deserialize(ByteBuffer byteBuffer) {
List<Integer> insertRowNodeIndex = new ArrayList<>();

try {
devicePath = new PartialPath(ReadWriteIOUtils.readString(byteBuffer));
devicePath =
DataNodeDevicePathCache.getInstance()
.getPartialPath((ReadWriteIOUtils.readString(byteBuffer)));
} catch (IllegalPathException e) {
throw new IllegalArgumentException("Cannot deserialize InsertRowsOfOneDeviceNode", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,9 @@ public static InsertTabletNode deserialize(ByteBuffer byteBuffer) {

public void subDeserialize(ByteBuffer buffer) {
try {
devicePath = new PartialPath(ReadWriteIOUtils.readString(buffer));
devicePath =
DataNodeDevicePathCache.getInstance()
.getPartialPath((ReadWriteIOUtils.readString(buffer)));
} catch (IllegalPathException e) {
throw new IllegalArgumentException("Cannot deserialize InsertTabletNode", e);
}
Expand Down Expand Up @@ -929,7 +931,9 @@ public static InsertTabletNode deserializeFromWAL(ByteBuffer buffer) {
private void subDeserializeFromWAL(ByteBuffer buffer) {
searchIndex = buffer.getLong();
try {
devicePath = new PartialPath(ReadWriteIOUtils.readString(buffer));
devicePath =
DataNodeDevicePathCache.getInstance()
.getPartialPath((ReadWriteIOUtils.readString(buffer)));
} catch (IllegalPathException e) {
throw new IllegalArgumentException("Cannot deserialize InsertTabletNode", e);
}
Expand Down

0 comments on commit a0750b6

Please sign in to comment.