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 @@ -539,14 +539,13 @@ private TSStatus loadSchemaSnapShot(
throws IllegalPathException, IOException {
final String databaseName = parameters.get(ColumnHeaderConstant.DATABASE);
final PartialPath databasePath = new PartialPath(databaseName);

final String pathPattern = parameters.get(ColumnHeaderConstant.PATH_PATTERN);
if (!shouldLoadSchemaSnapshotDatabase(pathPattern, databaseName)) {
return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
}
final PipePattern pipePattern =
PipePattern.parsePatternFromString(pathPattern, IoTDBPipePattern::new);

if (!shouldLoadTreeSchemaSnapshotDatabase(pipePattern, databaseName)) {
return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
}
final TSStatus createDatabaseStatus = createSchemaSnapshotDatabaseIfNecessary(databasePath);
if (createDatabaseStatus.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
return createDatabaseStatus;
Expand Down Expand Up @@ -584,10 +583,18 @@ private TSStatus loadSchemaSnapShot(
return PipeReceiverStatusHandler.getPriorStatus(results);
}

static boolean shouldLoadSchemaSnapshotDatabase(
final String pathPattern, final String databaseName) {
return PipePattern.parsePatternFromString(pathPattern, IoTDBPipePattern::new)
.mayOverlapWithDb(databaseName);
static boolean shouldLoadTreeSchemaSnapshotDatabase(
final String pathPattern,
final boolean isTreeModelDataAllowedToBeCaptured,
final String databaseName) {
return isTreeModelDataAllowedToBeCaptured
&& shouldLoadTreeSchemaSnapshotDatabase(
PipePattern.parsePatternFromString(pathPattern, IoTDBPipePattern::new), databaseName);
}

private static boolean shouldLoadTreeSchemaSnapshotDatabase(
final PipePattern pipePattern, final String databaseName) {
return pipePattern.mayOverlapWithDb(databaseName);
}

private TSStatus createSchemaSnapshotDatabaseIfNecessary(final PartialPath databasePath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ public void testRepeatedStatementExceptionLogIsReduced() throws Exception {
}

@Test
public void testSchemaSnapshotDatabaseIsFilteredByPattern() {
public void testTreeSchemaSnapshotDatabaseIsFilteredByPattern() {
Assert.assertTrue(
IoTDBDataNodeReceiver.shouldLoadSchemaSnapshotDatabase("root.ln.**", "root.ln"));
Assert.assertTrue(IoTDBDataNodeReceiver.shouldLoadSchemaSnapshotDatabase("root.**", "root.db"));
IoTDBDataNodeReceiver.shouldLoadTreeSchemaSnapshotDatabase("root.ln.**", true, "root.ln"));
Assert.assertTrue(
IoTDBDataNodeReceiver.shouldLoadTreeSchemaSnapshotDatabase("root.**", true, "root.db"));
Assert.assertFalse(
IoTDBDataNodeReceiver.shouldLoadTreeSchemaSnapshotDatabase("root.ln.**", true, "root.db"));
Assert.assertFalse(
IoTDBDataNodeReceiver.shouldLoadSchemaSnapshotDatabase("root.ln.**", "root.db"));
IoTDBDataNodeReceiver.shouldLoadTreeSchemaSnapshotDatabase("root.ln.**", false, "root.ln"));
}

@Test
Expand Down
Loading