@Override public int hashCode() { int result = 0; result = 31 * result + name.hashCode(); result = 31 * result + getFactTable().hashCode(); return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CubeDesc cubeDesc = (CubeDesc) o; if (!name.equals(cubeDesc.name)) return false; if (!getFactTable().equals(cubeDesc.getFactTable())) return false; return true; }
@Override public String getFactTable() { return this.getDescriptor().getFactTable(); }
public String calculateSignature() { MessageDigest md = null; try { md = MessageDigest.getInstance("MD5"); StringBuilder sigString = new StringBuilder(); sigString.append(this.name).append("|").append(this.getFactTable()).append("|").append(JsonUtil.writeValueAsString(this.model.getPartitionDesc())).append("|").append(JsonUtil.writeValueAsString(this.dimensions)).append("|").append(JsonUtil.writeValueAsString(this.measures)).append("|").append(JsonUtil.writeValueAsString(this.rowkey)).append("|").append(JsonUtil.writeValueAsString(this.hbaseMapping)); byte[] signature = md.digest(sigString.toString().getBytes()); return new String(Base64.encodeBase64(signature)); } catch (NoSuchAlgorithmException | JsonProcessingException e) { throw new RuntimeException("Failed to calculate signature"); } }
/** * @deprecated use getModel().getAllTables() instead * @return */ public List<TableDesc> listTables() { MetadataManager metaMgr = MetadataManager.getInstance(config); HashSet<String> tableNames = new HashSet<String>(); List<TableDesc> result = new ArrayList<TableDesc>(); tableNames.add(this.getFactTable().toUpperCase()); for (DimensionDesc dim : dimensions) { String table = dim.getTable(); if (table != null) tableNames.add(table.toUpperCase()); } for (String tableName : tableNames) { result.add(metaMgr.getTableDesc(tableName)); } return result; }
private Boolean checkNeedMerging(TblColRef col) throws IOException { Boolean ret = dictsNeedMerging.get(col); if (ret != null) return ret; else { ret = cubeDesc.getRowkey().isUseDictionary(col); if (ret) { String dictTable = (String) DictionaryManager.getInstance(config).decideSourceData(cubeDesc.getModel(), cubeDesc.getRowkey().getDictionary(col), col, null)[0]; ret = cubeDesc.getFactTable().equalsIgnoreCase(dictTable); } dictsNeedMerging.put(col, ret); return ret; } }
String factTable = cube.getFactTable(); if (StringUtils.isEmpty(factTable)) { context.addResult(ResultLevel.ERROR, "Fact table can not be null.");
private static boolean isWeaklyMatchedWithAggregations(Collection<FunctionDesc> aggregations, Collection<TblColRef> metricColumns, CubeInstance cube) { CubeDesc cubeDesc = cube.getDescriptor(); Collection<FunctionDesc> cubeFuncs = cubeDesc.listAllFunctions(); boolean matched = true; for (FunctionDesc functionDesc : aggregations) { if (cubeFuncs.contains(functionDesc)) continue; // only inverted-index cube does not have count, and let calcite handle in this case if (functionDesc.isCount()) continue; if (functionDesc.isCountDistinct()) // calcite can not handle distinct count matched = false; TblColRef col = functionDesc.selectTblColRef(metricColumns, cubeDesc.getFactTable()); if (col == null || !cubeDesc.listDimensionColumnsIncludingDerived().contains(col)) { matched = false; } } return matched; } }
private static void adjustOLAPContextIfNecessary(CubeInstance cube, OLAPContext olapContext) { if (CubeCapabilityChecker.check(cube, olapContext.getSQLDigest(), false)) return; CubeDesc cubeDesc = cube.getDescriptor(); Collection<FunctionDesc> cubeFuncs = cubeDesc.listAllFunctions(); convertAggregationToDimension(olapContext, cubeFuncs, cubeDesc.getFactTable()); }
String factTable = cubeDesc.getFactTable(); if (factTable.equals(pTable)) { j.swapPKFK();
TableDesc factTable = tables.get(getFactTable()); for (MeasureDesc m : measures) { m.setName(m.getName().toUpperCase());
if (newSeg.getCubeDesc().getRowkey().isUseDictionary(col)) { String dictTable = (String) dictMgr.decideSourceData(cubeDesc.getModel(), cubeDesc.getRowkey().getDictionary(col), col, null)[0]; if (cubeDesc.getFactTable().equalsIgnoreCase(dictTable)) { colsNeedMeringDict.add(col); } else {
@Override protected void setup(Context context) throws IOException { super.publishConfiguration(context.getConfiguration()); cubeName = context.getConfiguration().get(BatchConstants.CFG_CUBE_NAME).toUpperCase(); segmentName = context.getConfiguration().get(BatchConstants.CFG_CUBE_SEGMENT_NAME); KylinConfig config = AbstractHadoopJob.loadKylinPropsAndMetadata(context.getConfiguration()); metadataManager = MetadataManager.getInstance(config); cube = CubeManager.getInstance(config).getCube(cubeName); cubeSegment = cube.getSegment(segmentName, SegmentStatusEnum.NEW); cubeDesc = cube.getDescriptor(); factTableDesc = metadataManager.getTableDesc(cubeDesc.getFactTable()); long baseCuboidId = Cuboid.getBaseCuboidId(cubeDesc); baseCuboid = Cuboid.findById(cubeDesc, baseCuboidId); // intermediateTableDesc = new // JoinedFlatTableDesc(cube.getDescriptor()); rowKeyEncoder = AbstractRowKeyEncoder.createInstance(cubeSegment, baseCuboid); measureCodec = new MeasureCodec(cubeDesc.getMeasures()); measures = new Object[cubeDesc.getMeasures().size()]; int colCount = cubeDesc.getRowkey().getRowKeyColumns().length; keyBytesBuf = new byte[colCount][]; bytesSplitter = new BytesSplitter(factTableDesc.getColumns().length, 4096); nullValue = new byte[] { (byte) '\\', (byte) 'N' };// As in Hive, null // value is // represented by \N prepareJoins(); prepareMetrics(); }
private static void processSegment(KylinConfig config, CubeSegment cubeSeg, String factColumnsPath) throws IOException { CubeManager cubeMgr = CubeManager.getInstance(config); for (DimensionDesc dim : cubeSeg.getCubeDesc().getDimensions()) { // dictionary for (TblColRef col : dim.getColumnRefs()) { if (cubeSeg.getCubeDesc().getRowkey().isUseDictionary(col)) { logger.info("Building dictionary for " + col); cubeMgr.buildDictionary(cubeSeg, col, factColumnsPath); } } // build snapshot if (dim.getTable() != null && !dim.getTable().equalsIgnoreCase(cubeSeg.getCubeDesc().getFactTable())) { // CubeSegment seg = cube.getTheOnlySegment(); logger.info("Building snapshot of " + dim.getTable()); cubeMgr.buildSnapshotTable(cubeSeg, dim.getTable()); logger.info("Checking snapshot of " + dim.getTable()); cubeMgr.getLookupTable(cubeSeg, dim); // load the table for // sanity check } } }
newDim.setTable(getMetadataManager().appendDBName(newModel.getFactTable()));
private void init(String cubeName, int rowCount, double conflictRaio, double linkableRatio, long randomSeed) { this.rowCount = rowCount; this.conflictRatio = conflictRaio; this.cubeName = cubeName; this.randomSeed = randomSeed; this.linkableRatio = linkableRatio; this.unlinkableRowCountMax = (int) (this.rowCount * (1 - linkableRatio)); this.unlinkableRowCount = 0; r = new Random(randomSeed); KylinConfig config = KylinConfig.getInstanceFromEnv(); cube = CubeManager.getInstance(config).getCube(cubeName); desc = cube.getDescriptor(); factTableName = desc.getFactTable(); store = ResourceStore.getStore(config); }
@Override public int hashCode() { int result = 0; result = 31 * result + name.hashCode(); result = 31 * result + getFactTable().hashCode(); return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CubeDesc cubeDesc = (CubeDesc) o; if (!name.equals(cubeDesc.name)) return false; if (!getFactTable().equals(cubeDesc.getFactTable())) return false; return true; }
@Override public String getFactTable() { return this.getDescriptor().getFactTable(); }
public String calculateSignature() { MessageDigest md = null; try { md = MessageDigest.getInstance("MD5"); StringBuilder sigString = new StringBuilder(); sigString.append(this.name).append("|").append(this.getFactTable()).append("|").append(JsonUtil.writeValueAsString(this.model.getPartitionDesc())).append("|").append(JsonUtil.writeValueAsString(this.dimensions)).append("|").append(JsonUtil.writeValueAsString(this.measures)).append("|").append(JsonUtil.writeValueAsString(this.rowkey)).append("|").append(JsonUtil.writeValueAsString(this.hbaseMapping)); byte[] signature = md.digest(sigString.toString().getBytes()); return new String(Base64.encodeBase64(signature)); } catch (NoSuchAlgorithmException | JsonProcessingException e) { throw new RuntimeException("Failed to calculate signature"); } }