tprelle commented on code in PR #4599:
URL: https://github.com/apache/iceberg/pull/4599#discussion_r872961137
##########
api/src/main/java/org/apache/iceberg/types/TypeUtil.java:
##########
@@ -130,15 +131,45 @@ private static Set<Integer> getIdsInternal(Type type,
boolean includeStructIds)
return visit(type, new GetProjectedIds(includeStructIds));
}
+ private static Set<Integer> innerFilter(Set<Integer> filteredIds,
Types.NestedField innerField) {
+ // If it's a struct and if all ids need to be filtered we remove all
+ if (innerField.type().isStructType()) {
+ if (innerField.type().asStructType().fields()
+ .stream().allMatch(f -> filteredIds.contains(f.fieldId()))) {
+
filteredIds.removeAll(innerField.type().asStructType().fields().stream()
+ .map(Types.NestedField::fieldId).collect(Collectors.toSet()));
+ }
+ innerField.type().asStructType().fields().forEach(f ->
innerFilter(filteredIds, f));
+ }
+ return filteredIds;
+ }
+
+ private static void filter(Set<Integer> projectedIds, Types.StructType
struct, Set<Integer> fieldIds,
+ boolean filteredStruct) {
+ Set<Integer> filteredIds = Sets.newHashSet(fieldIds);
+ if (filteredStruct) {
+ struct.fields().forEach(f -> innerFilter(filteredIds, f));
+ }
+ projectedIds.removeAll(filteredIds);
+ }
+
public static Types.StructType selectNot(Types.StructType struct,
Set<Integer> fieldIds) {
+ return selectNot(struct, fieldIds, false);
+ }
+
+ public static Types.StructType selectNot(Types.StructType struct,
Set<Integer> fieldIds, boolean filteredStruct) {
Review Comment:
Hi @kbendick,
Thanks for the review.
I had trouble to name this variable. It's may more
doesNeedToFilteredInnerStruct.
I add this variable because on some cases we need to filtered inner struct
(ORC) in some cases we do not need.
Is doesNeedToFilteredInnerStruct is better ?
--
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]