public String getDictionary(TblColRef col) { return getColDesc(col).getDictionary(); }
private void updateRowkeyDictionary(CubeDesc oldModel, org.apache.kylin.cube.model.CubeDesc newModel) { RowKeyDesc rowKey = newModel.getRowkey(); for (RowKeyColDesc rowkeyCol : rowKey.getRowKeyColumns()) { if (rowkeyCol.getDictionary() != null && rowkeyCol.getDictionary().length() > 0) rowkeyCol.setDictionary("true"); } }
@Override public void validate(CubeDesc cube, ValidateContext context) { RowKeyDesc row = cube.getRowkey(); if (row == null) { context.addResult(ResultLevel.ERROR, "Rowkey does not exist"); return; } RowKeyColDesc[] rcd = row.getRowKeyColumns(); if (rcd == null) { context.addResult(ResultLevel.ERROR, "Rowkey columns do not exist"); return; } if(rcd.length == 0){ context.addResult(ResultLevel.ERROR, "Rowkey columns is empty"); return; } for (int i = 0; i < rcd.length; i++) { RowKeyColDesc rd = rcd[i]; if (rd.getLength() != 0 && (!StringUtils.isEmpty(rd.getDictionary())&&!rd.getDictionary().equals("false"))) { context.addResult(ResultLevel.ERROR, "Rowkey column " + rd.getColumn() + " must not have both 'length' and 'dictionary' attribute"); } if (rd.getLength() == 0 && (StringUtils.isEmpty(rd.getDictionary())||rd.getDictionary().equals("false"))) { context.addResult(ResultLevel.ERROR, "Rowkey column " + rd.getColumn() + " must not have both 'length' and 'dictionary' empty"); } } }
private static int[] estimateRowKeyColSpace(RowKeyDesc rowKeyDesc, long[] cardinality) { RowKeyColDesc[] rowKeyColDescs = rowKeyDesc.getRowKeyColumns(); int[] ret = new int[rowKeyColDescs.length]; for (int i = 0; i < rowKeyColDescs.length; ++i) { RowKeyColDesc rowKeyColDesc = rowKeyColDescs[rowKeyColDescs.length - 1 - i]; if (rowKeyColDesc.getDictionary() == null) { if (rowKeyColDesc.getLength() == 0) throw new IllegalStateException("The non-dictionary col " + rowKeyColDesc.getColumn() + " has length of 0"); ret[i] = rowKeyColDesc.getLength(); } else { ret[i] = estimateDictionaryColSpace(cardinality[i]); } } return ret; }
public String getDictionary(TblColRef col) { return getColDesc(col).getDictionary(); }
@Override public void validate(CubeDesc cube, ValidateContext context) { RowKeyDesc row = cube.getRowkey(); if (row == null) { context.addResult(ResultLevel.ERROR, "Rowkey does not exist"); return; } RowKeyColDesc[] rcd = row.getRowKeyColumns(); if (rcd == null) { context.addResult(ResultLevel.ERROR, "Rowkey columns do not exist"); return; } if (rcd.length == 0) { context.addResult(ResultLevel.ERROR, "Rowkey columns is empty"); return; } for (int i = 0; i < rcd.length; i++) { RowKeyColDesc rd = rcd[i]; if (rd.getLength() != 0 && (!StringUtils.isEmpty(rd.getDictionary()) && !rd.getDictionary().equals("false"))) { context.addResult(ResultLevel.ERROR, "Rowkey column " + rd.getColumn() + " must not have both 'length' and 'dictionary' attribute"); } if (rd.getLength() == 0 && (StringUtils.isEmpty(rd.getDictionary()) || rd.getDictionary().equals("false"))) { context.addResult(ResultLevel.ERROR, "Rowkey column " + rd.getColumn() + " must not have both 'length' and 'dictionary' empty"); } } }
private static int[] estimateRowKeyColSpace(RowKeyDesc rowKeyDesc, long[] cardinality) { RowKeyColDesc[] rowKeyColDescs = rowKeyDesc.getRowKeyColumns(); int[] ret = new int[rowKeyColDescs.length]; for (int i = 0; i < rowKeyColDescs.length; ++i) { RowKeyColDesc rowKeyColDesc = rowKeyColDescs[rowKeyColDescs.length - 1 - i]; if (rowKeyColDesc.getDictionary() == null) { if (rowKeyColDesc.getLength() == 0) throw new IllegalStateException("The non-dictionary col " + rowKeyColDesc.getColumn() + " has length of 0"); ret[i] = rowKeyColDesc.getLength(); } else { ret[i] = estimateDictionaryColSpace(cardinality[i]); } } return ret; }
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]); } } } }