1616
1717package com .netflix .iceberg ;
1818
19+ import com .google .common .cache .CacheBuilder ;
20+ import com .google .common .cache .CacheLoader ;
21+ import com .google .common .cache .LoadingCache ;
1922import com .google .common .collect .ImmutableList ;
2023import com .google .common .collect .Iterables ;
2124import com .google .common .collect .Lists ;
2225import com .google .common .collect .Sets ;
2326import com .netflix .iceberg .expressions .Evaluator ;
2427import com .netflix .iceberg .expressions .Expression ;
2528import com .netflix .iceberg .expressions .Expressions ;
29+ import com .netflix .iceberg .expressions .InclusiveManifestEvaluator ;
2630import com .netflix .iceberg .io .CloseableIterable ;
2731import com .netflix .iceberg .types .Types ;
2832import java .io .Closeable ;
@@ -40,6 +44,16 @@ class ManifestGroup {
4044 private final boolean ignoreDeleted ;
4145 private final List <String > columns ;
4246
47+ private final LoadingCache <Integer , InclusiveManifestEvaluator > EVAL_CACHE = CacheBuilder
48+ .newBuilder ()
49+ .build (new CacheLoader <Integer , InclusiveManifestEvaluator >() {
50+ @ Override
51+ public InclusiveManifestEvaluator load (Integer specId ) {
52+ PartitionSpec spec = ops .current ().spec (specId );
53+ return new InclusiveManifestEvaluator (spec , dataFilter );
54+ }
55+ });
56+
4357 ManifestGroup (TableOperations ops , Iterable <ManifestFile > manifests ) {
4458 this (ops , Sets .newHashSet (manifests ), Expressions .alwaysTrue (), Expressions .alwaysTrue (),
4559 false , ImmutableList .of ("*" ));
@@ -91,7 +105,8 @@ public CloseableIterable<ManifestEntry> entries() {
91105 Evaluator evaluator = new Evaluator (DataFile .getType (EMPTY_STRUCT ), fileFilter );
92106 List <Closeable > toClose = Lists .newArrayList ();
93107
94- Iterable <ManifestFile > matchingManifests = manifests ;
108+ Iterable <ManifestFile > matchingManifests = Iterables .filter (manifests ,
109+ manifest -> EVAL_CACHE .getUnchecked (manifest .partitionSpecId ()).eval (manifest ));
95110
96111 if (ignoreDeleted ) {
97112 // remove any manifests that don't have any existing or added files. if either the added or
0 commit comments