question: private static PlanningCoCodingGroup [ ] findCocodesBruteForce ( CompressedSizeEstimator sizeEstimator , float numRowsWeight , PlanningCoCodingGroup [ ] singltonGroups ) { PriorityQueue < PlanningGroupMergeAction > q = new PriorityQueue < PlanningGroupMergeAction > ( ) ; for ( int leftIx = 0 ; leftIx < singltonGroups . length ; leftIx ++ ) { PlanningCoCodingGroup leftGrp = singltonGroups [ leftIx ] ; for ( int rightIx = leftIx + 1 ; rightIx < singltonGroups . length ; rightIx ++ ) { PlanningCoCodingGroup rightGrp = singltonGroups [ rightIx ] ; float cardRatio = leftGrp . getCardinalityRatio ( ) + rightGrp . getCardinalityRatio ( ) ; if ( cardRatio < GROUPABILITY_THRESHOLD ) { PlanningGroupMergeAction potentialMerge = new PlanningGroupMergeAction ( sizeEstimator , numRowsWeight , leftGrp , rightGrp ) ; if ( potentialMerge . getChangeInSize ( ) < 0 ) { q . add ( potentialMerge ) ; } } } } PlanningCoCodingGroup [ ] colGroups = singltonGroups ; while ( q . size ( ) > 0 ) { PlanningGroupMergeAction merge = q . poll ( ) ; int leftIx = findInArray ( colGroups , merge . getLeftGrp ( ) ) ; int rightIx = findInArray ( colGroups , merge . getRightGrp ( ) ) ; if ( leftIx < 0 || rightIx < 0 ) { } else { PlanningCoCodingGroup mergedGrp = merge . getMergedGrp ( ) ; PlanningCoCodingGroup [ ] newColGroups = new PlanningCoCodingGroup [ colGroups . length - 1 ] ; int targetIx = 0 ; for ( int i = 0 ; i < colGroups . length ; i ++ ) { if ( i != leftIx && i != rightIx ) { newColGroups [ targetIx ] = colGroups [ i ] ; targetIx ++ ; } } newColGroups [ newColGroups . length - 1 ] = mergedGrp ; for ( int i = 0 ; i < newColGroups . length - 1 ; i ++ ) { PlanningCoCodingGroup newLeftGrp = newColGroups [ i ] ; PlanningCoCodingGroup newRightGrp = mergedGrp ; if ( newLeftGrp . getCardinalityRatio ( ) + newRightGrp . getCardinalityRatio ( ) < GROUPABILITY_THRESHOLD ) { PlanningGroupMergeAction newPotentialMerge = new PlanningGroupMergeAction ( sizeEstimator , numRowsWeight , newLeftGrp , newRightGrp ) ; if ( newPotentialMerge . getChangeInSize ( ) < 0 ) { q . add ( newPotentialMerge ) ; } } } colGroups = newColGroups ; } } return colGroups ; }
target:  Identify columns to code together. Uses a greedy approach that merges pairs of column groups into larger groups. Each phase of the greedy algorithm considers all combinations of pairs to merge.