This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 5b8e59fd2d7 Get device path from cache (#15290)
5b8e59fd2d7 is described below
commit 5b8e59fd2d782753e20ef97e11a9fa10b0164efe
Author: shuwenwei <[email protected]>
AuthorDate: Mon Apr 14 14:47:30 2025 +0800
Get device path from cache (#15290)
* get device path from cache
* get table name segments from cache
---
.../execute/utils/CompactionPathUtils.java | 20 +++++++++++++++++++-
.../execute/utils/MultiTsFileDeviceIterator.java | 10 +++-------
.../fast/FastAlignedSeriesCompactionExecutor.java | 8 ++------
.../fast/FastNonAlignedSeriesCompactionExecutor.java | 5 +----
.../executor/fast/SeriesCompactionExecutor.java | 7 ++++---
.../dataregion/modification/TreeDeletionEntry.java | 6 ++++--
.../apache/iotdb/commons/path/MeasurementPath.java | 4 ++++
7 files changed, 37 insertions(+), 23 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/CompactionPathUtils.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/CompactionPathUtils.java
index 711effdc3f1..c2ddabfc4d6 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/CompactionPathUtils.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/CompactionPathUtils.java
@@ -20,7 +20,9 @@
package org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils;
import org.apache.iotdb.commons.exception.IllegalPathException;
+import org.apache.iotdb.commons.path.MeasurementPath;
import org.apache.iotdb.commons.path.PartialPath;
+import
org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.DataNodeDevicePathCache;
import org.apache.tsfile.file.metadata.IDeviceID;
@@ -30,6 +32,22 @@ public class CompactionPathUtils {
public static PartialPath getPath(IDeviceID device, String measurement)
throws IllegalPathException {
- return new PartialPath(device).concatAsMeasurementPath(measurement);
+ if (device.isTableModel()) {
+ String[] tableNameSegments =
+
DataNodeDevicePathCache.getInstance().getPartialPath(device.getTableName()).getNodes();
+ String[] nodes = new String[device.segmentNum() +
tableNameSegments.length];
+ System.arraycopy(tableNameSegments, 0, nodes, 0,
tableNameSegments.length);
+ for (int i = 0; i < device.segmentNum() - 1; i++) {
+ nodes[i + tableNameSegments.length] = device.segment(i + 1).toString();
+ }
+ nodes[device.segmentNum() + tableNameSegments.length - 1] = measurement;
+ MeasurementPath path = new MeasurementPath(nodes);
+ path.setDevice(device);
+ return path;
+ } else {
+ return DataNodeDevicePathCache.getInstance()
+ .getPartialPath(device.toString())
+ .concatAsMeasurementPath(measurement);
+ }
}
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/MultiTsFileDeviceIterator.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/MultiTsFileDeviceIterator.java
index 72caefcf15c..ea886aafd78 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/MultiTsFileDeviceIterator.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/MultiTsFileDeviceIterator.java
@@ -22,7 +22,6 @@ package
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils;
import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.exception.IllegalPathException;
import org.apache.iotdb.commons.path.MeasurementPath;
-import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.utils.CommonDateTimeUtils;
import
org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.DataNodeTTLCache;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.io.CompactionTsFileReader;
@@ -464,11 +463,9 @@ public class MultiTsFileDeviceIterator implements
AutoCloseable {
continue;
}
List<ModEntry> modificationList = new ArrayList<>();
- PartialPath path =
- CompactionPathUtils.getPath(
- currentDevice.getLeft(), valueChunkMetadata.getMeasurementUid());
for (ModEntry modification : modifications) {
- if (modification.matches(path)) {
+ if (modification.affects(currentDevice.getLeft())
+ && modification.affects(valueChunkMetadata.getMeasurementUid())) {
modificationList.add(modification);
}
}
@@ -663,7 +660,6 @@ public class MultiTsFileDeviceIterator implements
AutoCloseable {
LinkedList<Pair<TsFileSequenceReader, List<ChunkMetadata>>>
readerAndChunkMetadataForThisSeries = new LinkedList<>();
- PartialPath path = CompactionPathUtils.getPath(device,
currentCompactingSeries);
for (TsFileResource resource : tsFileResourcesSortedByAsc) {
TsFileSequenceReader reader = readerMap.get(resource);
@@ -691,7 +687,7 @@ public class MultiTsFileDeviceIterator implements
AutoCloseable {
LinkedList<ModEntry> modificationForCurrentSeries = new
LinkedList<>();
// collect the modifications for current series
for (ModEntry modification : modificationsInThisResource) {
- if (modification.matches(path)) {
+ if (modification.affects(device) &&
modification.affects(currentCompactingSeries)) {
modificationForCurrentSeries.add(modification);
}
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/FastAlignedSeriesCompactionExecutor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/FastAlignedSeriesCompactionExecutor.java
index b489630894b..7ad78814c5f 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/FastAlignedSeriesCompactionExecutor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/FastAlignedSeriesCompactionExecutor.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.commons.path.AlignedPath;
import org.apache.iotdb.commons.path.PatternTreeMap;
import org.apache.iotdb.db.exception.WriteProcessException;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.task.subtask.FastCompactionTaskSummary;
-import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.CompactionPathUtils;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.executor.ModifiedStatus;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.executor.batch.utils.AlignedSeriesBatchCompactionUtils;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.executor.fast.element.AlignedPageElement;
@@ -241,8 +240,7 @@ public class FastAlignedSeriesCompactionExecutor extends
SeriesCompactionExecuto
// get time modifications of this file
List<ModEntry> timeModifications =
- getModificationsFromCache(
- resource, CompactionPathUtils.getPath(deviceId,
AlignedPath.VECTOR_PLACEHOLDER));
+ getModificationsFromCache(resource, deviceId,
AlignedPath.VECTOR_PLACEHOLDER);
// get value modifications of this file
List<List<ModEntry>> valueModifications = new ArrayList<>();
alignedChunkMetadataList
@@ -255,9 +253,7 @@ public class FastAlignedSeriesCompactionExecutor extends
SeriesCompactionExecuto
valueModifications.add(null);
} else {
valueModifications.add(
- getModificationsFromCache(
- resource,
- CompactionPathUtils.getPath(deviceId,
x.getMeasurementUid())));
+ getModificationsFromCache(resource, deviceId,
x.getMeasurementUid()));
}
} catch (IllegalPathException e) {
throw new RuntimeException(e);
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/FastNonAlignedSeriesCompactionExecutor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/FastNonAlignedSeriesCompactionExecutor.java
index 1c0b5fbf7ae..e2be4be0cc2 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/FastNonAlignedSeriesCompactionExecutor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/FastNonAlignedSeriesCompactionExecutor.java
@@ -23,7 +23,6 @@ import
org.apache.iotdb.commons.exception.IllegalPathException;
import org.apache.iotdb.commons.path.PatternTreeMap;
import org.apache.iotdb.db.exception.WriteProcessException;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.task.subtask.FastCompactionTaskSummary;
-import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.CompactionPathUtils;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.executor.ModifiedStatus;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.executor.fast.element.ChunkMetadataElement;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.executor.fast.element.FileElement;
@@ -147,9 +146,7 @@ public class FastNonAlignedSeriesCompactionExecutor extends
SeriesCompactionExec
ModificationUtils.modifyChunkMetaData(
iChunkMetadataList,
getModificationsFromCache(
- resource,
- CompactionPathUtils.getPath(
- deviceId, iChunkMetadataList.get(0).getMeasurementUid())));
+ resource, deviceId,
iChunkMetadataList.get(0).getMeasurementUid()));
if (iChunkMetadataList.isEmpty()) {
// all chunks has been deleted in this file, just remove it
removeFile(fileElement);
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/SeriesCompactionExecutor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/SeriesCompactionExecutor.java
index d3e469abc30..cff3adb69cf 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/SeriesCompactionExecutor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/SeriesCompactionExecutor.java
@@ -24,6 +24,7 @@ import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.path.PatternTreeMap;
import org.apache.iotdb.db.exception.WriteProcessException;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.task.subtask.FastCompactionTaskSummary;
+import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.CompactionPathUtils;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.executor.ModifiedStatus;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.executor.fast.element.ChunkMetadataElement;
import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.executor.fast.element.FileElement;
@@ -475,16 +476,16 @@ public abstract class SeriesCompactionExecutor {
/**
* Get the modifications of a timeseries in the ModificationFile of a
TsFile. Create ttl
* modification from ttl cache.
- *
- * @param path name of the time series
*/
protected List<ModEntry> getModificationsFromCache(
- TsFileResource tsFileResource, PartialPath path) {
+ TsFileResource tsFileResource, IDeviceID deviceId, String measurement)
+ throws IllegalPathException {
PatternTreeMap<ModEntry, PatternTreeMapFactory.ModsSerializer>
allModifications =
modificationCacheMap.get(tsFileResource.getTsFile().getName());
if (allModifications == null) {
return Collections.emptyList();
}
+ PartialPath path = CompactionPathUtils.getPath(deviceId, measurement);
List<ModEntry> modEntries = allModifications.getOverlapped(path);
if (path.getIDeviceID().isTableModel()) {
modEntries =
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/modification/TreeDeletionEntry.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/modification/TreeDeletionEntry.java
index 1c2feb016b6..02fb95680f5 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/modification/TreeDeletionEntry.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/modification/TreeDeletionEntry.java
@@ -24,6 +24,7 @@ import org.apache.iotdb.commons.path.MeasurementPath;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.path.PathPatternUtil;
import org.apache.iotdb.commons.utils.TestOnly;
+import
org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.DataNodeDevicePathCache;
import org.apache.iotdb.db.storageengine.dataregion.modification.v1.Deletion;
import org.apache.iotdb.db.utils.ModificationUtils;
@@ -133,8 +134,9 @@ public class TreeDeletionEntry extends ModEntry {
@Override
public boolean affects(IDeviceID deviceID) {
try {
+ PartialPath deviceIdPath =
+
DataNodeDevicePathCache.getInstance().getPartialPath(deviceID.toString());
if (pathPattern.endWithMultiLevelWildcard()) {
- PartialPath deviceIdPath = new PartialPath(deviceID);
// pattern: root.db1.d1.**, deviceId: root.db1.d1, match
return pathPattern.getDevicePath().matchFullPath(deviceIdPath)
// pattern: root.db1.**, deviceId: root.db1.d1, match
@@ -142,7 +144,7 @@ public class TreeDeletionEntry extends ModEntry {
} else {
// pattern: root.db1.d1.s1, deviceId: root.db1.d1, match
// pattern: root.db1.d1, deviceId: root.db1.d1, not match
- return pathPattern.getDevicePath().matchFullPath(new
PartialPath(deviceID));
+ return pathPattern.getDevicePath().matchFullPath(deviceIdPath);
}
} catch (IllegalPathException e) {
return false;
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/MeasurementPath.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/MeasurementPath.java
index 084e9bb8b54..f74a29f1815 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/MeasurementPath.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/MeasurementPath.java
@@ -209,6 +209,10 @@ public class MeasurementPath extends PartialPath {
return isUnderAlignedEntity;
}
+ public void setDevice(IDeviceID device) {
+ this.device = device;
+ }
+
public void setUnderAlignedEntity(Boolean underAlignedEntity) {
isUnderAlignedEntity = underAlignedEntity;
}