aokolnychyi opened a new pull request, #9194:
URL: https://github.com/apache/iceberg/pull/9194
This PR adds `PartitionMap`, a map that uses a pair of spec ID and partition
tuple as keys. It is similar to `PartitionSet`.
The class will simplify places like `DeleteFileIndex` that uses the
following code not related to the main logic.
```
private final Map<Integer, Types.StructType> partitionTypeById;
private final Map<Integer, ThreadLocal<StructLikeWrapper>> wrapperById;
private final Map<Pair<Integer, StructLikeWrapper>, DeleteFileGroup>
deletesByPartition;
// use HashMap with precomputed values instead of thread-safe collections
loaded on demand
// as the cache is being accessed for each data file and the lookup speed is
critical
private Map<Integer, ThreadLocal<StructLikeWrapper>> wrappers(Map<Integer,
PartitionSpec> specs) {
Map<Integer, ThreadLocal<StructLikeWrapper>> wrappers = Maps.newHashMap();
specs.forEach((specId, spec) -> wrappers.put(specId, newWrapper(specId)));
return wrappers;
}
private ThreadLocal<StructLikeWrapper> newWrapper(int specId) {
return ThreadLocal.withInitial(() ->
StructLikeWrapper.forType(partitionTypeById.get(specId)));
}
private Pair<Integer, StructLikeWrapper> partition(int specId, StructLike
struct) {
ThreadLocal<StructLikeWrapper> wrapper = wrapperById.get(specId);
return Pair.of(specId, wrapper.get().set(struct));
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]