public static List<Integer> translateBitSetToProjIndx(ImmutableBitSet projBitSet) { List<Integer> projIndxLst = new ArrayList<Integer>(); for (int i = 0; i < projBitSet.length(); i++) { if (projBitSet.get(i)) { projIndxLst.add(i); } } return projIndxLst; }
public static List<Integer> translateBitSetToProjIndx(ImmutableBitSet projBitSet) { List<Integer> projIndxLst = new ArrayList<Integer>(); for (int i = 0; i < projBitSet.length(); i++) { if (projBitSet.get(i)) { projIndxLst.add(i); } } return projIndxLst; }
/** Creates a group key with grouping sets, both identified by field positions * in the underlying relational expression. * * <p>This method of creating a group key does not allow you to group on new * expressions, only column projections, but is efficient, especially when you * are coming from an existing {@link Aggregate}. */ public GroupKey groupKey(ImmutableBitSet groupSet, boolean indicator, ImmutableList<ImmutableBitSet> groupSets) { if (groupSet.length() > peek().getRowType().getFieldCount()) { throw new IllegalArgumentException("out of bounds: " + groupSet); } if (groupSets == null) { groupSets = ImmutableList.of(groupSet); } final ImmutableList<RexNode> nodes = fields(ImmutableIntList.of(groupSet.toArray())); final List<ImmutableList<RexNode>> nodeLists = Lists.transform(groupSets, new Function<ImmutableBitSet, ImmutableList<RexNode>>() { public ImmutableList<RexNode> apply(ImmutableBitSet input) { return fields(ImmutableIntList.of(input.toArray())); } }); return groupKey(nodes, indicator, nodeLists); }
public void computePartitionList(HiveConf conf, RexNode pruneNode, Set<Integer> partOrVirtualCols) { try { if (!hiveTblMetadata.isPartitioned() || pruneNode == null || InputFinder.bits(pruneNode).length() == 0) { // there is no predicate on partitioning column, we need all partitions // in this case. partitionList = PartitionPruner.prune(hiveTblMetadata, null, conf, getName(), partitionCache); return; } // We have valid pruning expressions, only retrieve qualifying partitions ExprNodeDesc pruneExpr = pruneNode.accept(new ExprNodeConverter(getName(), getRowType(), partOrVirtualCols, getTypeFactory())); partitionList = PartitionPruner.prune(hiveTblMetadata, pruneExpr, conf, getName(), partitionCache); } catch (HiveException he) { throw new RuntimeException(he); } }
/** Creates a group key with grouping sets, both identified by field positions * in the underlying relational expression. * * <p>This method of creating a group key does not allow you to group on new * expressions, only column projections, but is efficient, especially when you * are coming from an existing {@link Aggregate}. */ public GroupKey groupKey(ImmutableBitSet groupSet, boolean indicator, ImmutableList<ImmutableBitSet> groupSets) { if (groupSet.length() > peek().getRowType().getFieldCount()) { throw new IllegalArgumentException("out of bounds: " + groupSet); } if (groupSets == null) { groupSets = ImmutableList.of(groupSet); } final ImmutableList<RexNode> nodes = fields(ImmutableIntList.of(groupSet.toArray())); final List<ImmutableList<RexNode>> nodeLists = Lists.transform(groupSets, new Function<ImmutableBitSet, ImmutableList<RexNode>>() { public ImmutableList<RexNode> apply(ImmutableBitSet input) { return fields(ImmutableIntList.of(input.toArray())); } }); return groupKey(nodes, indicator, nodeLists); }
public void computePartitionList(HiveConf conf, RexNode pruneNode, Set<Integer> partOrVirtualCols) { try { if (!hiveTblMetadata.isPartitioned() || pruneNode == null || InputFinder.bits(pruneNode).length() == 0) { // there is no predicate on partitioning column, we need all partitions // in this case. partitionList = PartitionPruner.prune(hiveTblMetadata, null, conf, getName(), partitionCache); return; } // We have valid pruning expressions, only retrieve qualifying partitions ExprNodeDesc pruneExpr = pruneNode.accept(new ExprNodeConverter(getName(), getRowType(), partOrVirtualCols, this.getRelOptSchema().getTypeFactory())); partitionList = PartitionPruner.prune(hiveTblMetadata, pruneExpr, conf, getName(), partitionCache); } catch (HiveException he) { throw new RuntimeException(he); } }
for (int i = 0; i < inputs.size(); i++) { final int adjustment = inputsRange[i].nextSetBit(0); for (int j = adjustment; j < inputsRange[i].length(); j++) { adjustments[j] = -adjustment;
for (int i = 0; i < inputs.size(); i++) { final int adjustment = inputsRange[i].nextSetBit(0); for (int j = adjustment; j < inputsRange[i].length(); j++) { adjustments[j] = -adjustment;
public static List<Integer> translateBitSetToProjIndx(ImmutableBitSet projBitSet) { List<Integer> projIndxLst = new ArrayList<Integer>(); for (int i = 0; i < projBitSet.length(); i++) { if (projBitSet.get(i)) { projIndxLst.add(i); } } return projIndxLst; }
/** Computes the closure of a map from integers to bits. * * <p>The input must have an entry for each position. * * <p>Does not modify the input map or its bit sets. */ public static SortedMap<Integer, ImmutableBitSet> closure( SortedMap<Integer, ImmutableBitSet> equivalence) { if (equivalence.isEmpty()) { return ImmutableSortedMap.of(); } int length = equivalence.lastKey(); for (ImmutableBitSet bitSet : equivalence.values()) { length = Math.max(length, bitSet.length()); } if (equivalence.size() < length || equivalence.firstKey() != 0) { SortedMap<Integer, ImmutableBitSet> old = equivalence; equivalence = new TreeMap<>(); for (int i = 0; i < length; i++) { final ImmutableBitSet bitSet = old.get(i); equivalence.put(i, bitSet == null ? ImmutableBitSet.of() : bitSet); } } final Closure closure = new Closure(equivalence); return closure.closure; }
/** Computes the closure of a map from integers to bits. * * <p>The input must have an entry for each position. * * <p>Does not modify the input map or its bit sets. */ public static SortedMap<Integer, ImmutableBitSet> closure( SortedMap<Integer, ImmutableBitSet> equivalence) { if (equivalence.isEmpty()) { return ImmutableSortedMap.of(); } int length = equivalence.lastKey(); for (ImmutableBitSet bitSet : equivalence.values()) { length = Math.max(length, bitSet.length()); } if (equivalence.size() < length || equivalence.firstKey() != 0) { SortedMap<Integer, ImmutableBitSet> old = equivalence; equivalence = new TreeMap<>(); for (int i = 0; i < length; i++) { final ImmutableBitSet bitSet = old.get(i); equivalence.put(i, bitSet == null ? ImmutableBitSet.of() : bitSet); } } final Closure closure = new Closure(equivalence); return closure.closure; }
public static Group induce(ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets) { if (!ImmutableBitSet.ORDERING.isStrictlyOrdered(groupSets)) { throw new IllegalArgumentException("must be sorted: " + groupSets); } if (groupSets.size() == 1 && groupSets.get(0).equals(groupSet)) { return SIMPLE; } if (groupSets.size() == IntMath.pow(2, groupSet.cardinality())) { return CUBE; } checkRollup: if (groupSets.size() == groupSet.cardinality() + 1) { ImmutableBitSet g = groupSet; for (ImmutableBitSet bitSet : groupSets) { if (!bitSet.equals(g)) { break checkRollup; } g = g.clear(g.length() - 1); } assert g.isEmpty(); return ROLLUP; } return OTHER; } }
public static Group induce(ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets) { if (!ImmutableBitSet.ORDERING.isStrictlyOrdered(groupSets)) { throw new IllegalArgumentException("must be sorted: " + groupSets); } if (groupSets.size() == 1 && groupSets.get(0).equals(groupSet)) { return SIMPLE; } if (groupSets.size() == IntMath.pow(2, groupSet.cardinality())) { return CUBE; } checkRollup: if (groupSets.size() == groupSet.cardinality() + 1) { ImmutableBitSet g = groupSet; for (ImmutableBitSet bitSet : groupSets) { if (!bitSet.equals(g)) { break checkRollup; } g = g.clear(g.length() - 1); } assert g.isEmpty(); return ROLLUP; } return OTHER; } }
private GroupKey groupKey_(ImmutableBitSet groupSet, boolean indicator, @Nonnull ImmutableList<ImmutableBitSet> groupSets) { if (groupSet.length() > peek().getRowType().getFieldCount()) { throw new IllegalArgumentException("out of bounds: " + groupSet); } Objects.requireNonNull(groupSets); final ImmutableList<RexNode> nodes = fields(ImmutableIntList.of(groupSet.toArray())); final List<ImmutableList<RexNode>> nodeLists = Util.transform(groupSets, bitSet -> fields(ImmutableIntList.of(bitSet.toArray()))); return groupKey_(nodes, indicator, nodeLists); }
private GroupKey groupKey_(ImmutableBitSet groupSet, boolean indicator, ImmutableList<ImmutableBitSet> groupSets) { if (groupSet.length() > peek().getRowType().getFieldCount()) { throw new IllegalArgumentException("out of bounds: " + groupSet); } if (groupSets == null) { groupSets = ImmutableList.of(groupSet); } final ImmutableList<RexNode> nodes = fields(ImmutableIntList.of(groupSet.toArray())); final List<ImmutableList<RexNode>> nodeLists = Lists.transform(groupSets, bitSet -> fields(ImmutableIntList.of(bitSet.toArray()))); return groupKey(nodes, indicator, nodeLists); }
private static void addWindows( Multimap<WindowKey, RexOver> windowMap, RexOver over, final int inputFieldCount) { final RexWindow aggWindow = over.getWindow(); // Look up or create a window. RelCollation orderKeys = getCollation( Lists.newArrayList( Util.filter(aggWindow.orderKeys, rexFieldCollation -> // If ORDER BY references constant (i.e. RexInputRef), // then we can ignore such ORDER BY key. rexFieldCollation.left instanceof RexLocalRef))); ImmutableBitSet groupSet = ImmutableBitSet.of(getProjectOrdinals(aggWindow.partitionKeys)); final int groupLength = groupSet.length(); if (inputFieldCount < groupLength) { // If PARTITION BY references constant, we can ignore such partition key. // All the inputs after inputFieldCount are literals, thus we can clear. groupSet = groupSet.except(ImmutableBitSet.range(inputFieldCount, groupLength)); } WindowKey windowKey = new WindowKey( groupSet, orderKeys, aggWindow.isRows(), aggWindow.getLowerBound(), aggWindow.getUpperBound()); windowMap.put(windowKey, over); } }
private static void addWindows( Multimap<WindowKey, RexOver> windowMap, RexOver over, final int inputFieldCount) { final RexWindow aggWindow = over.getWindow(); // Look up or create a window. RelCollation orderKeys = getCollation( Lists.newArrayList( Util.filter(aggWindow.orderKeys, rexFieldCollation -> // If ORDER BY references constant (i.e. RexInputRef), // then we can ignore such ORDER BY key. rexFieldCollation.left instanceof RexLocalRef))); ImmutableBitSet groupSet = ImmutableBitSet.of(getProjectOrdinals(aggWindow.partitionKeys)); final int groupLength = groupSet.length(); if (inputFieldCount < groupLength) { // If PARTITION BY references constant, we can ignore such partition key. // All the inputs after inputFieldCount are literals, thus we can clear. groupSet = groupSet.except(ImmutableBitSet.range(inputFieldCount, groupLength)); } WindowKey windowKey = new WindowKey( groupSet, orderKeys, aggWindow.isRows(), aggWindow.getLowerBound(), aggWindow.getUpperBound()); windowMap.put(windowKey, over); } }
public void computePartitionList(HiveConf conf, RexNode pruneNode) { try { if (!hiveTblMetadata.isPartitioned() || pruneNode == null || InputFinder.bits(pruneNode).length() == 0) { // there is no predicate on partitioning column, we need all partitions // in this case. partitionList = PartitionPruner.prune(hiveTblMetadata, null, conf, getName(), partitionCache); return; } // We have valid pruning expressions, only retrieve qualifying partitions ExprNodeDesc pruneExpr = pruneNode.accept(new ExprNodeConverter(getName(), getRowType(), HiveCalciteUtil.getInputRefs(pruneNode), this.getRelOptSchema().getTypeFactory())); partitionList = PartitionPruner.prune(hiveTblMetadata, pruneExpr, conf, getName(), partitionCache); } catch (HiveException he) { throw new RuntimeException(he); } }
equalTo("{65, 66, 67}")); assertThat(ImmutableBitSet.range(65, 65).toString(), equalTo("{}")); assertThat(ImmutableBitSet.range(65, 65).length(), equalTo(0)); assertThat(ImmutableBitSet.range(65, 165).cardinality(), equalTo(100)); assertThat(ImmutableBitSet.builder().set(65, 65).build().toString(), equalTo("{}")); assertThat(ImmutableBitSet.builder().set(65, 65).build().length(), equalTo(0)); assertThat(ImmutableBitSet.builder().set(65, 165).build().cardinality(),
equalTo("{65, 66, 67}")); assertThat(ImmutableBitSet.range(65, 65).toString(), equalTo("{}")); assertThat(ImmutableBitSet.range(65, 65).length(), equalTo(0)); assertThat(ImmutableBitSet.range(65, 165).cardinality(), equalTo(100)); assertThat(ImmutableBitSet.builder().set(65, 65).build().toString(), equalTo("{}")); assertThat(ImmutableBitSet.builder().set(65, 65).build().length(), equalTo(0)); assertThat(ImmutableBitSet.builder().set(65, 165).build().cardinality(),