CubeInstance extends RootPersistentEntity implements IRealization, IBuildable { public Map<Long, Long> getCuboids() { if (cuboidBytes == null) return null; byte[] uncompressed; try { uncompressed = CompressionUtils.decompress(cuboidBytes); String str = new String(uncompressed, StandardCharsets.UTF_8); TypeReference<Map<Long, Long>> typeRef = new TypeReference<Map<Long, Long>>() { }; Map<Long, Long> cuboids = JsonUtil.readValue(str, typeRef); return cuboids.isEmpty() ? null : cuboids; } catch (Exception e) { throw new RuntimeException(e); } } CubeInstance(); static CubeInstance create(String cubeName, CubeDesc cubeDesc); CubeInstance latestCopyForWrite(); CuboidScheduler getCuboidScheduler(); Segments<CubeSegment> getBuildingSegments(); Segments<CubeSegment> getMergingSegments(CubeSegment mergedSegment); CubeSegment getOriginalSegmentToRefresh(CubeSegment refreshedSegment); CubeSegment getOriginalSegmentToOptimize(CubeSegment optimizedSegment); CubeDesc getDescriptor(); @Override DataModelDesc getModel(); boolean isReady(); boolean allowBrokenDescriptor(); @Override String resourceName(); String getResourcePath(); static String concatResourcePath(String cubeName); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override KylinConfig getConfig(); String getRootFactTable(); @Override String getName(); @Override String getCanonicalName(); @Override List<MeasureDesc> getMeasures(); void setName(String name); String getOwner(); void setOwner(String owner); String getDescName(); void setDescName(String descName); String getDisplayName(); void setDisplayName(String displayName); @Override int getCost(); void setCost(int cost); RealizationStatusEnum getStatus(); void setStatus(RealizationStatusEnum status); CubeSegment getFirstSegment(); CubeSegment getLatestReadySegment(); CubeSegment getLatestBuiltSegment(); Segments<CubeSegment> getSegments(); Segments<CubeSegment> getSegments(SegmentStatusEnum status); CubeSegment getSegment(String name, SegmentStatusEnum status); void setSegments(Segments segments); CubeSegment getSegmentById(String segmentId); CubeSegment[] regetSegments(CubeSegment... segs); long getCreateTimeUTC(); void setCreateTimeUTC(long createTimeUTC); void clearCuboids(); Set<Long> getCuboidsByMode(String cuboidModeName); Set<Long> getCuboidsByMode(CuboidModeEnum cuboidMode); Map<Long, Long> getCuboids(); void setCuboids(Map<Long, Long> cuboids); Set<Long> getCuboidsRecommend(); void setCuboidsRecommend(Set<Long> cuboids); long getCuboidLastOptimized(); void setCuboidLastOptimized(long lastOptimized); int getBuildLevel(); @Override CapabilityResult isCapable(SQLDigest digest); int getCost(SQLDigest digest); @Override RealizationType getType(); @Override Set<TblColRef> getAllColumns(); @Override Set<ColumnDesc> getAllColumnDescs(); @Override long getDateRangeStart(); @Override long getDateRangeEnd(); @Override boolean supportsLimitPushDown(); int getRowKeyColumnCount(); @Override List<TblColRef> getAllDimensions(); boolean needAutoMerge(); SegmentRange autoMergeCubeSegments(); Segments calculateToBeSegments(CubeSegment newSegment); CubeSegment getLastSegment(); long getSizeKB(); long getInputRecordCount(); long getInputRecordSizeBytes(); String getProject(); ProjectInstance getProjectInstance(); @Override int getSourceType(); @Override int getStorageType(); @Override int getEngineType(); Map<String, String> getSnapshots(); String getSnapshotResPath(String tableName); void putSnapshotResPath(String table, String snapshotResPath); static CubeInstance getCopyOf(CubeInstance cubeInstance); static CubeSegment findSegmentWithJobId(String jobID, CubeInstance cubeInstance); static final int COST_WEIGHT_MEASURE; static final int COST_WEIGHT_DIMENSION; static final int COST_WEIGHT_INNER_JOIN; }
@Test public void getTreeCuboidSchedulerTest() { Map<Long, Long> cuboidsWithRowCnt = cubeInstance.getCuboids(); TreeCuboidScheduler.CuboidTree.createFromCuboids(Lists.newArrayList(cuboidsWithRowCnt.keySet()), new TreeCuboidScheduler.CuboidCostComparator(cuboidsWithRowCnt)); List<Long> cuboids = Lists.newArrayList(cuboidsWithRowCnt.keySet()); Collections.sort(cuboids); for (Long cuboid : cuboids) { System.out.println(cuboid + ":" + cuboidsWithRowCnt.get(cuboid)); } Assert.assertNotNull(cuboidsWithRowCnt.get(255L)); }