Java Code Examples for org.apache.kylin.cube.model.RowKeyDesc#getRowKeyColumns()
The following examples show how to use
org.apache.kylin.cube.model.RowKeyDesc#getRowKeyColumns() .
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: RowKeyAttrRule.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@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 || rcd.length == 0) { context.addResult(ResultLevel.ERROR, "Rowkey columns do not exist"); return; } for (int i = 0; i < rcd.length; i++) { RowKeyColDesc rd = rcd[i]; if (rd.getColumn() == null || rd.getColumn().length() == 0) { context.addResult(ResultLevel.ERROR, "Rowkey column empty"); } } }
Example 2
Source File: RowKeyAttrRule.java From kylin with Apache License 2.0 | 6 votes |
@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 || rcd.length == 0) { context.addResult(ResultLevel.ERROR, "Rowkey columns do not exist"); return; } for (int i = 0; i < rcd.length; i++) { RowKeyColDesc rd = rcd[i]; if (rd.getColumn() == null || rd.getColumn().length() == 0) { context.addResult(ResultLevel.ERROR, "Rowkey column empty"); } } }
Example 3
Source File: ResponseResultSchema.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
private void init(Set<TblColRef> selectedDimensions, Set<FunctionDesc> selectedMetrics) { this.dimensions = new TblColRef[selectedDimensions.size()]; this.metrics = new FunctionDesc[selectedMetrics.size()]; this.measures = new MeasureDesc[selectedMetrics.size()]; this.dimDataTypes = new DataType[dimensions.length]; this.metricsDataTypes = new DataType[metrics.length]; // sort dimensions according to the rowKey definition dimColIdxMap = Maps.newHashMap(); RowKeyDesc rowKeyDesc = cubeDesc.getRowkey(); int colIdx = 0; for (RowKeyColDesc rowKeyColDesc : rowKeyDesc.getRowKeyColumns()) { TblColRef dimension = rowKeyColDesc.getColRef(); if (selectedDimensions.contains(dimension)) { dimensions[colIdx] = dimension; dimDataTypes[colIdx] = dimension.getType(); dimColIdxMap.put(dimension, colIdx); colIdx++; } } nDimensions = colIdx; colIdx = 0; // metrics metricsColIdxMap = Maps.newHashMap(); for (MeasureDesc measure : cubeDesc.getMeasures()) { FunctionDesc func = measure.getFunction(); if (selectedMetrics.contains(func)) { metrics[colIdx] = func; measures[colIdx] = measure; metricsColIdxMap.put(func.getParameter().getColRef(), colIdx); metricsDataTypes[colIdx] = func.getReturnDataType(); colIdx++; } } nMetrics = colIdx; }
Example 4
Source File: ResponseResultSchema.java From kylin with Apache License 2.0 | 5 votes |
private void init(Set<TblColRef> selectedDimensions, Set<FunctionDesc> selectedMetrics) { this.dimensions = new TblColRef[selectedDimensions.size()]; this.metrics = new FunctionDesc[selectedMetrics.size()]; this.measures = new MeasureDesc[selectedMetrics.size()]; this.dimDataTypes = new DataType[dimensions.length]; this.metricsDataTypes = new DataType[metrics.length]; // sort dimensions according to the rowKey definition dimColIdxMap = Maps.newHashMap(); RowKeyDesc rowKeyDesc = cubeDesc.getRowkey(); int colIdx = 0; for (RowKeyColDesc rowKeyColDesc : rowKeyDesc.getRowKeyColumns()) { TblColRef dimension = rowKeyColDesc.getColRef(); if (selectedDimensions.contains(dimension)) { dimensions[colIdx] = dimension; dimDataTypes[colIdx] = dimension.getType(); dimColIdxMap.put(dimension, colIdx); colIdx++; } } nDimensions = colIdx; colIdx = 0; // metrics metricsColIdxMap = Maps.newHashMap(); for (MeasureDesc measure : cubeDesc.getMeasures()) { FunctionDesc func = measure.getFunction(); if (selectedMetrics.contains(func)) { metrics[colIdx] = func; measures[colIdx] = measure; metricsColIdxMap.put(func.getParameter().getColRef(), colIdx); metricsDataTypes[colIdx] = func.getReturnDataType(); colIdx++; } } nMetrics = colIdx; }
Example 5
Source File: RowKeyAttrRule.java From Kylin with Apache License 2.0 | 5 votes |
@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"); } } }
Example 6
Source File: CubeSizeEstimationCLI.java From Kylin with Apache License 2.0 | 5 votes |
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; }
Example 7
Source File: CubeSizeEstimationCLI.java From Kylin with Apache License 2.0 | 5 votes |
private static RowKeyColInfo extractRowKeyInfo(CubeDesc cubeDesc) { RowKeyDesc rowKeyDesc = cubeDesc.getRowkey(); RowKeyColInfo info = new RowKeyColInfo(); info.hierachyColBitIndice = new ArrayList<List<Integer>>(); info.nonHierachyColBitIndice = new ArrayList<Integer>(); HashSet<Integer> heirachyIndexSet = new HashSet<Integer>(); for (DimensionDesc dim : cubeDesc.getDimensions()) { if (dim.getHierarchy() != null) { LinkedList<Integer> hlist = new LinkedList<Integer>(); for (HierarchyDesc hierarchyDesc : dim.getHierarchy()) { int index = rowKeyDesc.getColumnBitIndex(hierarchyDesc.getColumnRef()); hlist.add(index); heirachyIndexSet.add(index); } info.hierachyColBitIndice.add(hlist); } } for (int i = 0; i < rowKeyDesc.getRowKeyColumns().length; ++i) { if (!heirachyIndexSet.contains(i)) { info.nonHierachyColBitIndice.add(i); } } return info; }
Example 8
Source File: CubeDescUpgrader.java From Kylin with Apache License 2.0 | 3 votes |
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"); } }