Java Code Examples for org.apache.kylin.cube.model.RowKeyDesc#getAggrGroupMasks()

The following examples show how to use org.apache.kylin.cube.model.RowKeyDesc#getAggrGroupMasks() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CuboidScheduler.java    From Kylin with Apache License 2.0 6 votes vote down vote up
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;
    }
}
 
Example 2
Source File: CuboidScheduler.java    From Kylin with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: CuboidCLI.java    From Kylin with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: CuboidScheduler.java    From Kylin with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: Cuboid.java    From Kylin with Apache License 2.0 5 votes vote down vote up
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();
}