Skip to content

Commit

Permalink
Pipe: Fix filter issue when both tree extraction and table extraction…
Browse files Browse the repository at this point in the history
… are enabled and one extraction has non default pattern (#14184)
  • Loading branch information
SteveYurongSu authored Nov 22, 2024
1 parent a689726 commit 76066d4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public class PipeHistoricalDataRegionTsFileAndDeletionExtractor
private TreePattern treePattern;
private TablePattern tablePattern;
private boolean isDbNameCoveredByPattern = false;
private boolean isModelDetected = false;

private boolean isHistoricalExtractorEnabled = false;
private long historicalDataExtractionStartTime = Long.MIN_VALUE; // Event time
Expand Down Expand Up @@ -336,10 +337,9 @@ public void customize(
final String databaseName = dataRegion.getDatabaseName();
if (Objects.nonNull(databaseName)) {
isDbNameCoveredByPattern =
treePattern.isTreeModelDataAllowedToBeCaptured() && treePattern.coversDb(databaseName)
treePattern.coversDb(databaseName)
// The database name is prefixed with "root."
|| tablePattern.isTableModelDataAllowedToBeCaptured()
&& tablePattern.coversDb(databaseName.substring(5));
&& tablePattern.coversDb(databaseName.substring(5));
}
}

Expand Down Expand Up @@ -673,6 +673,7 @@ private boolean mayTsFileResourceOverlappedWithPattern(final TsFileResource reso
|| deviceID.getTableName().startsWith(TREE_MODEL_EVENT_TABLE_NAME_PREFIX)
|| deviceID.getTableName().equals(PATH_ROOT)) {
// In case of tree model deviceID
updateIsDbNameCoveredByPattern(resource, false);
if (treePattern.isTreeModelDataAllowedToBeCaptured()
&& treePattern.mayOverlapWithDevice(deviceID)) {
tsfile2IsTableModelMap.computeIfAbsent(
Expand All @@ -681,6 +682,7 @@ private boolean mayTsFileResourceOverlappedWithPattern(final TsFileResource reso
}
} else {
// In case of table model deviceID
updateIsDbNameCoveredByPattern(resource, true);
if (tablePattern.isTableModelDataAllowedToBeCaptured()
// The database name in resource is prefixed with "root."
&& tablePattern.matchesDatabase(resource.getDatabaseName().substring(5))
Expand All @@ -694,6 +696,24 @@ private boolean mayTsFileResourceOverlappedWithPattern(final TsFileResource reso
});
}

private void updateIsDbNameCoveredByPattern(
final TsFileResource resource, final boolean isTableModel) {
if (isModelDetected) {
return;
}

final String databaseName = resource.getDatabaseName();
if (Objects.nonNull(databaseName)) {
isDbNameCoveredByPattern =
isTableModel
? tablePattern.isTableModelDataAllowedToBeCaptured()
&& tablePattern.coversDb(databaseName.substring(5))
: treePattern.isTreeModelDataAllowedToBeCaptured()
&& treePattern.coversDb(databaseName);
isModelDetected = true;
}
}

private boolean isTsFileResourceOverlappedWithTimeRange(final TsFileResource resource) {
return !(resource.getFileEndTime() < historicalDataExtractionStartTime
|| historicalDataExtractionEndTime < resource.getFileStartTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,9 @@ public void customize(
final String databaseName = dataRegion.getDatabaseName();
if (databaseName != null) {
isDbNameCoveredByPattern =
treePattern.isTreeModelDataAllowedToBeCaptured() && treePattern.coversDb(databaseName)
treePattern.coversDb(databaseName)
// The database name is prefixed with "root."
|| tablePattern.isTableModelDataAllowedToBeCaptured()
&& tablePattern.coversDb(databaseName.substring(5));
&& tablePattern.coversDb(databaseName.substring(5));
}
}

Expand Down

0 comments on commit 76066d4

Please sign in to comment.