|
20 | 20 | package org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils; |
21 | 21 |
|
22 | 22 | import org.apache.iotdb.commons.exception.IllegalPathException; |
23 | | -import org.apache.iotdb.commons.path.MeasurementPath; |
24 | 23 | import org.apache.iotdb.commons.path.PartialPath; |
25 | 24 | import org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.DataNodeDevicePathCache; |
26 | 25 |
|
| 26 | +import org.apache.tsfile.common.constant.TsFileConstant; |
27 | 27 | import org.apache.tsfile.file.metadata.IDeviceID; |
28 | 28 |
|
29 | 29 | public class CompactionPathUtils { |
30 | 30 |
|
31 | 31 | private CompactionPathUtils() {} |
32 | 32 |
|
33 | | - public static PartialPath getPath(IDeviceID device, String measurement) |
| 33 | + public static PartialPath getPath(final IDeviceID device, final String measurement) |
34 | 34 | throws IllegalPathException { |
| 35 | + return getPath(device).concatAsMeasurementPath(measurement); |
| 36 | + } |
| 37 | + |
| 38 | + public static PartialPath getPath(final IDeviceID device) throws IllegalPathException { |
35 | 39 | if (device.isTableModel()) { |
36 | | - String[] tableNameSegments = |
| 40 | + final String[] tableNameSegments = |
37 | 41 | DataNodeDevicePathCache.getInstance().getPartialPath(device.getTableName()).getNodes(); |
38 | | - String[] nodes = new String[device.segmentNum() + tableNameSegments.length]; |
| 42 | + final String[] nodes = new String[device.segmentNum() + tableNameSegments.length - 1]; |
39 | 43 | System.arraycopy(tableNameSegments, 0, nodes, 0, tableNameSegments.length); |
40 | 44 | for (int i = 0; i < device.segmentNum() - 1; i++) { |
41 | 45 | nodes[i + tableNameSegments.length] = |
42 | 46 | device.segment(i + 1) == null ? null : device.segment(i + 1).toString(); |
43 | 47 | } |
44 | | - nodes[device.segmentNum() + tableNameSegments.length - 1] = measurement; |
45 | | - MeasurementPath path = new MeasurementPath(nodes); |
46 | | - path.setDevice(device); |
47 | | - return path; |
| 48 | + return new PartialPath(nodes); |
48 | 49 | } else { |
49 | | - return DataNodeDevicePathCache.getInstance() |
50 | | - .getPartialPath(device.toString()) |
51 | | - .concatAsMeasurementPath(measurement); |
| 50 | + final String deviceId = device.toString(); |
| 51 | + return deviceId.contains(TsFileConstant.BACK_QUOTE_STRING) |
| 52 | + ? DataNodeDevicePathCache.getInstance().getPartialPath(device.toString()) |
| 53 | + : new PartialPath(deviceId.split(TsFileConstant.PATH_SEPARATER_NO_REGEX)); |
52 | 54 | } |
53 | 55 | } |
54 | 56 | } |
0 commit comments