private void generateZeroTailBase(long cuboid, Collection<Long> result) { RowKeyDesc rowkey = cubeDef.getRowkey(); long cuboidWithoutMandatory = cuboid & ~rowkey.getMandatoryColumnMask(); for (AggrGroupMask mask : rowkey.getAggrGroupMasks()) { if ((cuboidWithoutMandatory & mask.groupMask) == mask.groupMask && (cuboidWithoutMandatory & mask.leftoverMask) == mask.leftoverMask) { long zeroTail = rowkey.getMandatoryColumnMask() | mask.groupMask; if (zeroTail > 0 && zeroTail != cuboid) { result.add(zeroTail); } } if ((cuboidWithoutMandatory & mask.uniqueMask) > 0) break; } }
private static boolean checkAggregationGroup(RowKeyDesc rowkey, long cuboidID) { long cuboidWithoutMandatory = cuboidID & ~rowkey.getMandatoryColumnMask(); long leftover; for (AggrGroupMask mask : rowkey.getAggrGroupMasks()) { if ((cuboidWithoutMandatory & mask.uniqueMask) != 0) { leftover = cuboidWithoutMandatory & ~mask.groupMask; return leftover == 0 || leftover == mask.leftoverMask; } } leftover = cuboidWithoutMandatory & rowkey.getTailMask(); return leftover == 0 || leftover == rowkey.getTailMask(); }
public Collection<Long> findSmallerSibling(long cuboid) { if (!Cuboid.isValid(cubeDef, cuboid)) { return Collections.emptyList(); } RowKeyDesc rowkey = cubeDef.getRowkey(); // do combination in all related groups long groupAllBitMask = 0; for (AggrGroupMask mask : rowkey.getAggrGroupMasks()) { if ((mask.groupMask & cuboid) > 0) { groupAllBitMask |= mask.groupMask; } } long groupBitValue = cuboid & groupAllBitMask; long leftBitValue = cuboid & ~groupAllBitMask; long[] groupOneBits = bits(groupAllBitMask); Collection<Long> siblings = new HashSet<Long>(); combination(cuboid, siblings, groupOneBits, 0, leftBitValue, Long.bitCount(groupBitValue)); return siblings; }
public static int mathCalcCuboidCount(CubeDesc cube) { int result = 1; // 1 for base cuboid RowKeyDesc rowkey = cube.getRowkey(); AggrGroupMask[] aggrGroupMasks = rowkey.getAggrGroupMasks(); for (int i = 0; i < aggrGroupMasks.length; i++) { boolean hasTail = i < aggrGroupMasks.length - 1 || rowkey.getTailMask() > 0; result += mathCalcCuboidCount_aggrGroup(rowkey, aggrGroupMasks[i], hasTail); } return result; }
private Collection<Long> generateChildren(long cuboid) { Collection<Long> result = new HashSet<Long>(); // generate zero tail cuboid -- the one with all 1 in the first // aggregation group and all 0 for the rest bits generateZeroTailBase(cuboid, result); RowKeyDesc rowkey = cubeDef.getRowkey(); long cuboidWithoutMandatory = cuboid & ~rowkey.getMandatoryColumnMask(); for (AggrGroupMask mask : rowkey.getAggrGroupMasks()) { if (belongTo(cuboidWithoutMandatory, mask) == false) continue; long[] groupOneBitMasks = mask.groupOneBitMasks; for (int i = 0; i < groupOneBitMasks.length; i++) { long oneBit = groupOneBitMasks[i]; if ((cuboid & oneBit) == 0) continue; long child = cuboid ^ oneBit; if (Cuboid.isValid(cubeDef, child)) { result.add(child); } } if ((cuboidWithoutMandatory & mask.uniqueMask) > 0) break; } return result; }
private void generateZeroTailBase(long cuboid, Collection<Long> result) { RowKeyDesc rowkey = cubeDef.getRowkey(); long cuboidWithoutMandatory = cuboid & ~rowkey.getMandatoryColumnMask(); for (AggrGroupMask mask : rowkey.getAggrGroupMasks()) { if ((cuboidWithoutMandatory & mask.groupMask) == mask.groupMask && (cuboidWithoutMandatory & mask.leftoverMask) == mask.leftoverMask) { long zeroTail = rowkey.getMandatoryColumnMask() | mask.groupMask; if (zeroTail > 0 && zeroTail != cuboid) { result.add(zeroTail); } } if ((cuboidWithoutMandatory & mask.uniqueMask) > 0) break; } }
public Collection<Long> findSmallerSibling(long cuboid) { if (!Cuboid.isValid(cubeDef, cuboid)) { return Collections.emptyList(); } RowKeyDesc rowkey = cubeDef.getRowkey(); // do combination in all related groups long groupAllBitMask = 0; for (AggrGroupMask mask : rowkey.getAggrGroupMasks()) { if ((mask.groupMask & cuboid) > 0) { groupAllBitMask |= mask.groupMask; } } long groupBitValue = cuboid & groupAllBitMask; long leftBitValue = cuboid & ~groupAllBitMask; long[] groupOneBits = bits(groupAllBitMask); Collection<Long> siblings = new HashSet<Long>(); combination(cuboid, siblings, groupOneBits, 0, leftBitValue, Long.bitCount(groupBitValue)); return siblings; }
public static int mathCalcCuboidCount(CubeDesc cube) { int result = 1; // 1 for base cuboid RowKeyDesc rowkey = cube.getRowkey(); AggrGroupMask[] aggrGroupMasks = rowkey.getAggrGroupMasks(); for (int i = 0; i < aggrGroupMasks.length; i++) { boolean hasTail = i < aggrGroupMasks.length - 1 || rowkey.getTailMask() > 0; result += mathCalcCuboidCount_aggrGroup(rowkey, aggrGroupMasks[i], hasTail); } return result; }
private static boolean checkAggregationGroup(RowKeyDesc rowkey, long cuboidID) { long cuboidWithoutMandatory = cuboidID & ~rowkey.getMandatoryColumnMask(); long leftover; for (AggrGroupMask mask : rowkey.getAggrGroupMasks()) { if ((cuboidWithoutMandatory & mask.uniqueMask) != 0) { leftover = cuboidWithoutMandatory & ~mask.groupMask; return leftover == 0 || leftover == mask.leftoverMask; } } leftover = cuboidWithoutMandatory & rowkey.getTailMask(); return leftover == 0 || leftover == rowkey.getTailMask(); }
private Collection<Long> generateChildren(long cuboid) { Collection<Long> result = new HashSet<Long>(); // generate zero tail cuboid -- the one with all 1 in the first // aggregation group and all 0 for the rest bits generateZeroTailBase(cuboid, result); RowKeyDesc rowkey = cubeDef.getRowkey(); long cuboidWithoutMandatory = cuboid & ~rowkey.getMandatoryColumnMask(); for (AggrGroupMask mask : rowkey.getAggrGroupMasks()) { if (belongTo(cuboidWithoutMandatory, mask) == false) continue; long[] groupOneBitMasks = mask.groupOneBitMasks; for (int i = 0; i < groupOneBitMasks.length; i++) { long oneBit = groupOneBitMasks[i]; if ((cuboid & oneBit) == 0) continue; long child = cuboid ^ oneBit; if (Cuboid.isValid(cubeDef, child)) { result.add(child); } } if ((cuboidWithoutMandatory & mask.uniqueMask) > 0) break; } return result; }
for (AggrGroupMask mask : rowkey.getAggrGroupMasks()) { if ((cuboidWithoutMandatory & mask.uniqueMask) > 0) { leftover = cuboidWithoutMandatory & ~mask.groupMask;