Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.utils.AuthUtils;
import org.apache.iotdb.commons.utils.PathUtils;
import org.apache.iotdb.confignode.conf.ConfigNodeConf;
import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
import org.apache.iotdb.confignode.consensus.request.ConfigRequest;
Expand Down Expand Up @@ -281,7 +282,7 @@ public DataSet getSchemaPartition(PathPatternTree patternTree) {
for (String devicePath : devicePaths) {
boolean matchStorageGroup = false;
for (String storageGroup : storageGroups) {
if (devicePath.startsWith(storageGroup + ".")) {
if (PathUtils.isStartWith(devicePath, storageGroup)) {
matchStorageGroup = true;
if (devicePath.contains("*")) {
// Get all SchemaPartitions of this StorageGroup if the devicePath contains "*"
Expand Down Expand Up @@ -342,7 +343,7 @@ public DataSet getOrCreateSchemaPartition(PathPatternTree patternTree) {
if (!devicePath.contains("*")) {
// Only check devicePaths that without "*"
for (String storageGroup : storageGroups) {
if (devicePath.startsWith(storageGroup + ".")) {
if (PathUtils.isStartWith(devicePath, storageGroup)) {
partitionSlotsMap
.computeIfAbsent(storageGroup, key -> new ArrayList<>())
.add(getPartitionManager().getSeriesPartitionSlot(devicePath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
import org.apache.iotdb.common.rpc.thrift.TTimePartitionSlot;
import org.apache.iotdb.commons.utils.PathUtils;

import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -114,7 +115,7 @@ public TRegionReplicaSet getDataRegionReplicaSetForWriting(

private String getStorageGroupByDevice(String deviceName) {
for (String storageGroup : dataPartitionMap.keySet()) {
if (deviceName.startsWith(storageGroup + ".")) {
if (PathUtils.isStartWith(deviceName, storageGroup)) {
return storageGroup;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
import org.apache.iotdb.commons.utils.PathUtils;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -69,7 +70,7 @@ public TRegionReplicaSet getSchemaRegionReplicaSet(String deviceName) {

private String getStorageGroupByDevice(String deviceName) {
for (String storageGroup : schemaPartitionMap.keySet()) {
if (deviceName.startsWith(storageGroup + ".")) {
if (PathUtils.isStartWith(deviceName, storageGroup)) {
return storageGroup;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ public static void isLegalMeasurements(List<String> measurements) throws Illegal
}
}

public static boolean isStartWith(String deviceName, String storageGroup) {
return deviceName.equals(storageGroup) || deviceName.startsWith(storageGroup + ".");
}

private static boolean checkBackQuotes(String src) {
int num = src.length() - src.replace("`", "").length();
if (num % 2 == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.apache.iotdb.db.mpp.common.schematree;

import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.utils.PathUtils;
import org.apache.iotdb.commons.utils.TestOnly;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.metadata.path.MeasurementPath;
Expand Down Expand Up @@ -267,7 +268,7 @@ public static SchemaTree deserialize(ByteBuffer buffer) {
*/
public String getBelongedStorageGroup(String pathName) {
for (String storageGroup : storageGroups) {
if (pathName.startsWith(storageGroup + ".")) {
if (PathUtils.isStartWith(pathName, storageGroup)) {
return storageGroup;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.iotdb.commons.partition.SchemaPartition;
import org.apache.iotdb.commons.partition.executor.SeriesPartitionExecutor;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.utils.PathUtils;
import org.apache.iotdb.confignode.rpc.thrift.TDataPartitionReq;
import org.apache.iotdb.confignode.rpc.thrift.TDataPartitionResp;
import org.apache.iotdb.confignode.rpc.thrift.TSchemaNodeManagementReq;
Expand Down Expand Up @@ -460,7 +461,7 @@ public boolean getStorageGroup(
for (String devicePath : devicePaths) {
boolean hit = false;
for (String storageGroup : storageGroupCache) {
if (devicePath.startsWith(storageGroup + ".")) {
if (PathUtils.isStartWith(devicePath, storageGroup)) {
deviceToStorageGroupMap.put(devicePath, storageGroup);
hit = true;
break;
Expand Down Expand Up @@ -597,7 +598,7 @@ public void updateSchemaPartitionCache(List<String> devices, SchemaPartition sch
if (!device.contains("*")) {
String storageGroup = null;
for (String storageGroupName : storageGroupNames) {
if (device.startsWith(storageGroupName + ".")) {
if (PathUtils.isStartWith(device, storageGroup)) {
storageGroup = storageGroupName;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.iotdb.commons.partition.SchemaPartition;
import org.apache.iotdb.commons.partition.executor.SeriesPartitionExecutor;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.utils.PathUtils;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.engine.StorageEngineV2;
Expand Down Expand Up @@ -169,7 +170,7 @@ private Map<String, String> getDeviceToStorageGroup(
List<PartialPath> allStorageGroups = localConfigNode.getAllStorageGroupPaths();
for (String devicePath : devicePaths) {
for (PartialPath storageGroup : allStorageGroups) {
if (devicePath.startsWith(storageGroup.getFullPath() + ".")) {
if (PathUtils.isStartWith(devicePath, storageGroup.getFullPath())) {
deviceToStorageGroup.put(devicePath, storageGroup.getFullPath());
}
}
Expand Down