Skip to content

Commit

Permalink
[hotfix] Minor refactor for datafile filter in KeyValueFileStoreScan
Browse files Browse the repository at this point in the history
  • Loading branch information
JingsongLi authored and guanshi committed Nov 7, 2024
1 parent 5841756 commit b2e4fe5
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public class KeyValueFileStoreScan extends AbstractFileStoreScan {
private final ChangelogProducer changelogProducer;

private final boolean fileIndexReadEnabled;
// just cache.
private final Map<Long, Predicate> dataFilterMapping = new HashMap<>();
private final Map<Long, Predicate> schemaId2DataFilter = new HashMap<>();

public KeyValueFileStoreScan(
ManifestsReader manifestsReader,
Expand Down Expand Up @@ -137,19 +136,17 @@ private boolean filterByFileIndex(@Nullable byte[] embeddedIndexBytes, ManifestE
}

RowType dataRowType = scanTableSchema(entry.file().schemaId()).logicalRowType();

Predicate dataPredicate =
dataFilterMapping.computeIfAbsent(
entry.file().schemaId(),
id ->
fieldValueStatsConverters.convertFilter(
entry.file().schemaId(), valueFilter));

try (FileIndexPredicate predicate =
new FileIndexPredicate(embeddedIndexBytes, dataRowType)) {
Predicate dataPredicate =
schemaId2DataFilter.computeIfAbsent(
entry.file().schemaId(),
id ->
fieldValueStatsConverters.convertFilter(
entry.file().schemaId(), valueFilter));
return predicate.testPredicate(dataPredicate);
} catch (IOException e) {
throw new RuntimeException("Exception happens while checking predicate.", e);
throw new RuntimeException("Exception happens while checking fileIndex predicate.", e);
}
}

Expand Down

0 comments on commit b2e4fe5

Please sign in to comment.