/** * @param cube * @param context */ private void innerValidateMaxSize(CubeDesc cube, ValidateContext context) { int maxSize = getMaxAgrGroupSize(); String[][] groups = cube.getRowkey().getAggregationGroups(); for (int i = 0; i < groups.length; i++) { String[] group = groups[i]; if (group.length >= maxSize) { context.addResult(ResultLevel.ERROR, "Length of the number " + i + " aggregation group's length should be less than " + maxSize); } } }
@Override public void validate(CubeDesc cube, ValidateContext context) { Set<String> mands = new HashSet<String>(); RowKeyColDesc[] cols = cube.getRowkey().getRowKeyColumns(); if (cols == null || cols.length == 0) { return; } for (int i = 0; i < cols.length; i++) { RowKeyColDesc rowKeyColDesc = cols[i]; if (rowKeyColDesc.isMandatory()) { mands.add(rowKeyColDesc.getColumn()); } } if (mands.isEmpty()) { return; } String[][] groups = cube.getRowkey().getAggregationGroups(); for (int i = 0; i < groups.length; i++) { String[] group = groups[i]; for (int j = 0; j < group.length; j++) { String col = group[j]; if (mands.contains(col)) { context.addResult(ResultLevel.ERROR, "mandatory column " + col + " must not be in aggregation group [" + ArrayUtils.toString(group) + "]"); } } } }
/** * @param cube * @param context */ private void innerValidateMaxSize(CubeDesc cube, ValidateContext context) { int maxSize = getMaxAgrGroupSize(); String[][] groups = cube.getRowkey().getAggregationGroups(); for (int i = 0; i < groups.length; i++) { String[] group = groups[i]; if (group.length >= maxSize) { context.addResult(ResultLevel.ERROR, "Length of the number " + i + " aggregation group's length should be less than " + maxSize); } } }
@Override public void validate(CubeDesc cube, ValidateContext context) { Set<String> mands = new HashSet<String>(); RowKeyColDesc[] cols = cube.getRowkey().getRowKeyColumns(); if (cols == null || cols.length == 0) { return; } for (int i = 0; i < cols.length; i++) { RowKeyColDesc rowKeyColDesc = cols[i]; if (rowKeyColDesc.isMandatory()) { mands.add(rowKeyColDesc.getColumn()); } } if (mands.isEmpty()) { return; } String[][] groups = cube.getRowkey().getAggregationGroups(); for (int i = 0; i < groups.length; i++) { String[] group = groups[i]; for (int j = 0; j < group.length; j++) { String col = group[j]; if (mands.contains(col)) { context.addResult(ResultLevel.ERROR, "mandatory column " + col + " must not be in aggregation group [" + ArrayUtils.toString(group) + "]"); } } } }
private void updateRowkeyDictionary(org.apache.kylin.cube.model.CubeDesc newModel) { DataModelDesc modelDesc = newModel.getModel(); Map<String, String> pkToFK = Maps.newHashMap(); for (LookupDesc lookupDesc : modelDesc.getLookups()) { if (lookupDesc.getJoin() != null) { JoinDesc join = lookupDesc.getJoin(); for (int i = 0; i < join.getForeignKey().length; i++) { pkToFK.put(join.getPrimaryKey()[i], join.getForeignKey()[i]); } } } RowKeyDesc rowKey = newModel.getRowkey(); for (RowKeyColDesc rowkeyCol : rowKey.getRowKeyColumns()) { if (rowkeyCol.getDictionary() != null && rowkeyCol.getDictionary().length() > 0) rowkeyCol.setDictionary("true"); if (pkToFK.containsKey(rowkeyCol.getColumn())) { rowkeyCol.setColumn(pkToFK.get(rowkeyCol.getColumn())); } } for (String[] aggregationGroup : rowKey.getAggregationGroups()) { for (int i = 0; i < aggregationGroup.length; i++) { if (pkToFK.containsKey(aggregationGroup[i])) { aggregationGroup[i] = pkToFK.get(aggregationGroup[i]); } } } }