@@ -650,53 +650,40 @@ protected ASTJexlScript pushdownLargeFieldedLists(ShardQueryConfiguration config
650
650
}
651
651
652
652
if (termCount - capacitySum <= config .getFinalMaxTermThreshold ()) {
653
- // preserve the original config and set minimum thresholds for creating Value and Range ivarators
654
- int originalMaxOrExpansionThreshold = config .getMaxOrExpansionThreshold ();
655
- int originalMaxOrRangeThreshold = config .getMaxOrRangeThreshold ();
656
-
657
- config .setMaxOrExpansionThreshold (2 );
658
- config .setMaxOrRangeThreshold (2 );
653
+ // invert pushdownCapacity to get the largest payoffs first
654
+ SortedMap <Integer ,List <String >> sortedMap = new TreeMap <>();
655
+ for (String fieldName : pushdownCapacity .keySet ()) {
656
+ Integer reduction = pushdownCapacity .get (fieldName );
657
+ List <String > fields = sortedMap .computeIfAbsent (reduction , k -> new ArrayList <>());
658
+ fields .add (fieldName );
659
+ }
659
660
660
- try {
661
- // invert pushdownCapacity to get the largest payoffs first
662
- SortedMap <Integer ,List <String >> sortedMap = new TreeMap <>();
663
- for (String fieldName : pushdownCapacity .keySet ()) {
664
- Integer reduction = pushdownCapacity .get (fieldName );
665
- List <String > fields = sortedMap .computeIfAbsent (reduction , k -> new ArrayList <>());
666
- fields .add (fieldName );
667
- }
668
-
669
- // sort from largest to smallest reductions and make reductions until under the threshold
670
- Set <String > fieldsToReduce = new HashSet <>();
671
- int toReduce = termCount - config .getFinalMaxTermThreshold ();
672
- while (toReduce > 0 ) {
673
- // get the highest value field out of the map
674
- Integer reduction = sortedMap .lastKey ();
675
- List <String > fields = sortedMap .get (reduction );
676
-
677
- // take the first field
678
- String field = fields .remove (0 );
679
- fieldsToReduce .add (field );
680
- toReduce -= reduction ;
681
-
682
- // if there are no more reductions of this size remove the reduction from pushdown capacity
683
- if (fields .size () == 0 ) {
684
- sortedMap .remove (reduction );
685
- }
661
+ // sort from largest to smallest reductions and make reductions until under the threshold
662
+ Set <String > fieldsToReduce = new HashSet <>();
663
+ int toReduce = termCount - config .getFinalMaxTermThreshold ();
664
+ while (toReduce > 0 ) {
665
+ // get the highest value field out of the map
666
+ Integer reduction = sortedMap .lastKey ();
667
+ List <String > fields = sortedMap .get (reduction );
668
+
669
+ // take the first field
670
+ String field = fields .remove (0 );
671
+ fieldsToReduce .add (field );
672
+ toReduce -= reduction ;
673
+
674
+ // if there are no more reductions of this size remove the reduction from pushdown capacity
675
+ if (fields .size () == 0 ) {
676
+ sortedMap .remove (reduction );
686
677
}
678
+ }
687
679
688
- // execute the reduction
689
- if (hdfsQueryCacheUri != null ) {
690
- FileSystem fs = VisitorFunction .fileSystemCache .getFileSystem (hdfsQueryCacheUri );
691
- // Find large lists of values against the same field and push down into an Ivarator
692
- script = PushdownLargeFieldedListsVisitor .pushdown (config , script , fs , hdfsQueryCacheUri .toString (), null , fieldsToReduce );
693
- } else {
694
- script = PushdownLargeFieldedListsVisitor .pushdown (config , script , null , null , null , fieldsToReduce );
695
- }
696
- } finally {
697
- // reset config thresholds
698
- config .setMaxOrExpansionThreshold (originalMaxOrExpansionThreshold );
699
- config .setMaxOrRangeThreshold (originalMaxOrRangeThreshold );
680
+ // execute the reduction
681
+ if (hdfsQueryCacheUri != null ) {
682
+ FileSystem fs = VisitorFunction .fileSystemCache .getFileSystem (hdfsQueryCacheUri );
683
+ // Find large lists of values against the same field and push down into an Ivarator
684
+ script = PushdownLargeFieldedListsVisitor .pushdown (config , script , fs , hdfsQueryCacheUri .toString (), null , fieldsToReduce );
685
+ } else {
686
+ script = PushdownLargeFieldedListsVisitor .pushdown (config , script , null , null , null , fieldsToReduce );
700
687
}
701
688
}
702
689
}
0 commit comments