Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipe: Fix filter issue when both tree extraction and table extraction are enabled and one extraction has non default pattern #14184

Merged
merged 2 commits into from
Nov 22, 2024
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 @@ -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
Loading