if (agg.getIncludes() == null) { context.addResult(ResultLevel.ERROR, AGGREGATION_GROUP + index + " 'includes' field not set"); continue; if (agg.getSelectRule() == null) { context.addResult(ResultLevel.ERROR, AGGREGATION_GROUP + index + " 'select rule' field not set"); continue; if (agg.getIncludes() != null) { for (String include : agg.getIncludes()) { includeDims.add(include); if (agg.getSelectRule().mandatoryDims != null) { for (String m : agg.getSelectRule().mandatoryDims) { mandatoryDims.add(m); if (agg.getSelectRule().hierarchyDims != null) { for (String[] ss : agg.getSelectRule().hierarchyDims) { for (String s : ss) { hierarchyDims.add(s); if (agg.getSelectRule().jointDims != null) { for (String[] ss : agg.getSelectRule().jointDims) { for (String s : ss) { jointDims.add(s); if (agg.getSelectRule().jointDims != null) { for (String[] joints : agg.getSelectRule().jointDims) {
selectRule.jointDims = new String[0][0]; AggregationGroup aggGroup = new AggregationGroup(); aggGroup.setIncludes(refineColumnWithTable(tableName, dimensions)); aggGroup.setSelectRule(selectRule);
private void buildNormalDimsMask() { //no joint, no hierarchy, no mandatory long leftover = partialCubeFullMask & ~mandatoryColumnMask; leftover &= ~this.jointDimsMask; for (HierarchyMask hierarchyMask : this.hierarchyMasks) { leftover &= ~hierarchyMask.fullMask; } this.normalDimsMask = leftover; this.normalDims = bits(leftover); }
public void init(CubeDesc cubeDesc, RowKeyDesc rowKeyDesc) { this.cubeDesc = cubeDesc; this.isMandatoryOnlyValid = cubeDesc.getConfig().getCubeAggrGroupIsMandatoryOnlyValid(); if (this.includes == null || this.includes.length == 0 || this.selectRule == null) { throw new IllegalStateException("AggregationGroup incomplete"); } normalizeColumnNames(); buildPartialCubeFullMask(rowKeyDesc); buildMandatoryColumnMask(rowKeyDesc); buildJointColumnMask(rowKeyDesc); buildJointDimsMask(); buildHierarchyMasks(rowKeyDesc); buildHierarchyDimsMask(); buildNormalDimsMask(); }
if (agg.getIncludes() == null) { logger.error("Aggregation group " + index + " 'includes' field not set"); throw new IllegalStateException("Aggregation group " + index + " includes field not set"); if (agg.getSelectRule() == null) { logger.error("Aggregation group " + index + " 'select_rule' field not set"); throw new IllegalStateException("Aggregation group " + index + " select rule field not set"); getDims(includeDims, agg.getIncludes()); getDims(mandatoryDims, agg.getSelectRule().mandatoryDims); getDims(hierarchyDimsList, hierarchyDims, agg.getSelectRule().hierarchyDims); getDims(jointDimsList, jointDims, agg.getSelectRule().jointDims);
@Test public void testBadInit9() throws Exception { String[] strs = new String[] { LSTG_FORMAT_NAME, META_CATEG_NAME }; thrown.expect(IllegalStateException.class); thrown.expectMessage( "Aggregation group 1 hierarchy dimensions overlap with joint dimensions: " + sortStrs(strs)); CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchyDims = new String[][] { new String[] { META_CATEG_NAME, CATEG_LVL2_NAME, CATEG_LVL3_NAME }, new String[] { LSTG_FORMAT_NAME, LSTG_SITE_ID } }; cubeDesc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { new String[] { META_CATEG_NAME, LSTG_FORMAT_NAME } }; cubeDesc.init(getTestConfig()); }
@Test public void testBadInit3() throws Exception { thrown.expect(IllegalStateException.class); thrown.expectMessage("Aggregation group 1 'includes' dimensions not include all the dimensions:"); CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); String[] temp = Arrays.asList(cubeDesc.getAggregationGroups().get(0).getIncludes()).subList(0, 3) .toArray(new String[3]); cubeDesc.getAggregationGroups().get(0).setIncludes(temp); cubeDesc.init(getTestConfig()); }
private String getColInAggrGroup(AggregationGroup g, String name) { for (String c : g.getIncludes()) { if (c.toLowerCase(Locale.ROOT).contains(name.toLowerCase(Locale.ROOT))) return c; } throw new IllegalStateException(); }
@Test public void testBadInit1() throws Exception { thrown.expect(IllegalStateException.class); thrown.expectMessage("AggregationGroup incomplete"); CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); String[] temp = null; cubeDesc.getAggregationGroups().get(0).setIncludes(temp); cubeDesc.init(getTestConfig()); }
@Test public void testBadInit2() throws Exception { thrown.expect(IllegalStateException.class); thrown.expectMessage("AggregationGroup incomplete"); CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); SelectRule temp = null; cubeDesc.getAggregationGroups().get(0).setSelectRule(temp); cubeDesc.init(getTestConfig()); }
public void init(CubeDesc cubeDesc, RowKeyDesc rowKeyDesc) { this.cubeDesc = cubeDesc; this.isMandatoryOnlyValid = cubeDesc.getConfig().getCubeAggrGroupIsMandatoryOnlyValid(); if (this.includes == null || this.includes.length == 0 || this.selectRule == null) { throw new IllegalStateException("AggregationGroup incomplete"); } normalizeColumnNames(); buildPartialCubeFullMask(rowKeyDesc); buildMandatoryColumnMask(rowKeyDesc); buildJointColumnMask(rowKeyDesc); buildJointDimsMask(); buildHierarchyMasks(rowKeyDesc); buildHierarchyDimsMask(); buildNormalDimsMask(); }
AggregationGroup lag = lc.getAggregationGroups().get(i); AggregationGroup iag = ic.getAggregationGroups().get(i); assertArrayEquals(lag.getIncludes(), iag.getIncludes()); assertArrayEquals(lag.getSelectRule().mandatoryDims, iag.getSelectRule().mandatoryDims); assertArrayEquals(lag.getSelectRule().hierarchyDims, iag.getSelectRule().hierarchyDims); assertArrayEquals(lag.getSelectRule().jointDims, iag.getSelectRule().jointDims);
@Test public void testGoodDesc2() throws IOException { ValidateContext vContext = new ValidateContext(); CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class); desc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { // new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "CATEG_LVL2_NAME" } }; IValidatorRule<CubeDesc> rule = getAggregationGroupRule(); rule.validate(desc, vContext); //vContext.print(System.out); assertEquals(1, vContext.getResults().length); }
@Test public void testBadDesc1() throws IOException { ValidateContext vContext = new ValidateContext(); CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class); String[] temp = Arrays.asList(desc.getAggregationGroups().get(0).getIncludes()).subList(0, 3).toArray(new String[3]); desc.getAggregationGroups().get(0).setIncludes(temp); IValidatorRule<CubeDesc> rule = getAggregationGroupRule(); rule.validate(desc, vContext); //vContext.print(System.out); assertEquals(1, vContext.getResults().length); assertEquals("Aggregation group 1 'includes' dimensions not include all the dimensions:[seller_id, META_CATEG_NAME, lstg_format_name, lstg_site_id, slr_segment_cd]", (vContext.getResults()[0].getMessage())); }
selectRule.jointDims = new String[0][0]; AggregationGroup aggGroup = new AggregationGroup(); aggGroup.setIncludes(refineColumnWithTable(tableName, dimensions)); aggGroup.setSelectRule(selectRule);
if (agg.getIncludes() == null) { context.addResult(ResultLevel.ERROR, AGGREGATION_GROUP + index + " 'includes' field not set"); continue; if (agg.getSelectRule() == null) { context.addResult(ResultLevel.ERROR, AGGREGATION_GROUP + index + " 'select rule' field not set"); continue; if (agg.getIncludes() != null) { for (String include : agg.getIncludes()) { includeDims.add(include); if (agg.getSelectRule().mandatoryDims != null) { for (String m : agg.getSelectRule().mandatoryDims) { mandatoryDims.add(m); if (agg.getSelectRule().hierarchyDims != null) { for (String[] ss : agg.getSelectRule().hierarchyDims) { for (String s : ss) { hierarchyDims.add(s); if (agg.getSelectRule().jointDims != null) { for (String[] ss : agg.getSelectRule().jointDims) { for (String s : ss) { jointDims.add(s); if (agg.getSelectRule().jointDims != null) { for (String[] joints : agg.getSelectRule().jointDims) {
if (agg.getIncludes() == null) { logger.error("Aggregation group " + index + " 'includes' field not set"); throw new IllegalStateException("Aggregation group " + index + " includes field not set"); if (agg.getSelectRule() == null) { logger.error("Aggregation group " + index + " 'select_rule' field not set"); throw new IllegalStateException("Aggregation group " + index + " select rule field not set"); getDims(includeDims, agg.getIncludes()); getDims(mandatoryDims, agg.getSelectRule().mandatoryDims); getDims(hierarchyDimsList, hierarchyDims, agg.getSelectRule().hierarchyDims); getDims(jointDimsList, jointDims, agg.getSelectRule().jointDims);
@Test public void testBadInit5() throws Exception { CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); cubeDesc.getAggregationGroups().get(0).getSelectRule().mandatoryDims = new String[] { SELLER_ID, META_CATEG_NAME }; cubeDesc.init(getTestConfig()); }
private void buildNormalDimsMask() { //no joint, no hierarchy, no mandatory long leftover = partialCubeFullMask & ~mandatoryColumnMask; leftover &= ~this.jointDimsMask; for (HierarchyMask hierarchyMask : this.hierarchyMasks) { leftover &= ~hierarchyMask.fullMask; } this.normalDimsMask = leftover; this.normalDims = bits(leftover); }
selectRule.jointDims = new String[0][0]; AggregationGroup aggGroup = new AggregationGroup(); aggGroup.setIncludes(refineColumnWithTable(tableName, dimensions)); aggGroup.setSelectRule(selectRule);