Java Code Examples for org.apache.kylin.metadata.realization.IRealization#getModel()
The following examples show how to use
org.apache.kylin.metadata.realization.IRealization#getModel() .
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: FactTableRealizationSetCalculator.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private String getRootFactTableForRealization(IRealization realization) { if (realization == null) { logger.warn("Cannot find realization %s", realization); return null; } DataModelDesc model = realization.getModel(); if (model == null) { logger.warn("The model for realization %s is null", realization.getName()); return null; } TableRef rootFactTable = model.getRootFactTable(); if (rootFactTable == null) { logger.warn("The root table for model %s is null", model.getName()); return null; } return rootFactTable.getTableIdentity(); }
Example 2
Source File: FactTableRealizationSetCalculator.java From kylin with Apache License 2.0 | 6 votes |
private String getRootFactTableForRealization(IRealization realization) { if (realization == null) { logger.warn("Cannot find realization %s", realization); return null; } DataModelDesc model = realization.getModel(); if (model == null) { logger.warn("The model for realization %s is null", realization.getName()); return null; } TableRef rootFactTable = model.getRootFactTable(); if (rootFactTable == null) { logger.warn("The root table for model %s is null", model.getName()); return null; } return rootFactTable.getTableIdentity(); }
Example 3
Source File: OLAPContext.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
public boolean belongToFactTableDims(TblColRef tblColRef) { if (!belongToContextTables(tblColRef)) { return false; } KylinConfig kylinConfig = olapSchema.getConfig(); String projectName = olapSchema.getProjectName(); String factTableName = firstTableScan.getOlapTable().getTableName(); Set<IRealization> realizations = ProjectManager.getInstance(kylinConfig).getRealizationsByTable(projectName, factTableName); for (IRealization real : realizations) { DataModelDesc model = real.getModel(); TblColRef.fixUnknownModel(model, tblColRef.getTableRef().getTableIdentity(), tblColRef); // cannot be a measure column Set<String> metrics = Sets.newHashSet(model.getMetrics()); if (metrics.contains(tblColRef.getIdentity())) { tblColRef.unfixTableRef(); return false; } // must belong to a fact table for (TableRef factTable : model.getFactTables()) { if (factTable.getColumns().contains(tblColRef)) { tblColRef.unfixTableRef(); return true; } } tblColRef.unfixTableRef(); } return false; }
Example 4
Source File: OLAPContext.java From kylin with Apache License 2.0 | 5 votes |
public boolean belongToFactTableDims(TblColRef tblColRef) { if (!belongToContextTables(tblColRef)) { return false; } KylinConfig kylinConfig = olapSchema.getConfig(); String projectName = olapSchema.getProjectName(); String factTableName = firstTableScan.getOlapTable().getTableName(); Set<IRealization> realizations = ProjectManager.getInstance(kylinConfig).getRealizationsByTable(projectName, factTableName); for (IRealization real : realizations) { DataModelDesc model = real.getModel(); TblColRef.fixUnknownModel(model, tblColRef.getTableRef().getTableIdentity(), tblColRef); // cannot be a measure column Set<String> metrics = Sets.newHashSet(model.getMetrics()); if (metrics.contains(tblColRef.getIdentity())) { tblColRef.unfixTableRef(); return false; } // must belong to a fact table for (TableRef factTable : model.getFactTables()) { if (factTable.getColumns().contains(tblColRef)) { tblColRef.unfixTableRef(); return true; } } tblColRef.unfixTableRef(); } return false; }
Example 5
Source File: RealizationChooser.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
private static Map<DataModelDesc, Set<IRealization>> makeOrderedModelMap(OLAPContext context) { OLAPContext first = context; KylinConfig kylinConfig = first.olapSchema.getConfig(); String projectName = first.olapSchema.getProjectName(); String factTableName = first.firstTableScan.getOlapTable().getTableName(); Set<IRealization> realizations = ProjectManager.getInstance(kylinConfig).getRealizationsByTable(projectName, factTableName); final Map<DataModelDesc, Set<IRealization>> models = Maps.newHashMap(); final Map<DataModelDesc, RealizationCost> costs = Maps.newHashMap(); for (IRealization real : realizations) { if (real.isReady() == false) { context.realizationCheck.addIncapableCube(real, RealizationCheck.IncapableReason.create(RealizationCheck.IncapableType.CUBE_NOT_READY)); continue; } if (containsAll(real.getAllColumnDescs(), first.allColumns) == false) { context.realizationCheck.addIncapableCube(real, RealizationCheck.IncapableReason .notContainAllColumn(notContain(real.getAllColumnDescs(), first.allColumns))); continue; } if (RemoveBlackoutRealizationsRule.accept(real) == false) { context.realizationCheck.addIncapableCube(real, RealizationCheck.IncapableReason .create(RealizationCheck.IncapableType.CUBE_BLACK_OUT_REALIZATION)); continue; } RealizationCost cost = new RealizationCost(real); DataModelDesc m = real.getModel(); Set<IRealization> set = models.get(m); if (set == null) { set = Sets.newHashSet(); set.add(real); models.put(m, set); costs.put(m, cost); } else { set.add(real); RealizationCost curCost = costs.get(m); if (cost.compareTo(curCost) < 0) costs.put(m, cost); } } // order model by cheapest realization cost TreeMap<DataModelDesc, Set<IRealization>> result = Maps.newTreeMap(new Comparator<DataModelDesc>() { @Override public int compare(DataModelDesc o1, DataModelDesc o2) { RealizationCost c1 = costs.get(o1); RealizationCost c2 = costs.get(o2); int comp = c1.compareTo(c2); if (comp == 0) comp = o1.getName().compareTo(o2.getName()); return comp; } }); result.putAll(models); return result; }
Example 6
Source File: RealizationChooser.java From kylin with Apache License 2.0 | 4 votes |
private static Map<DataModelDesc, Set<IRealization>> makeOrderedModelMap(OLAPContext context) { OLAPContext first = context; KylinConfig kylinConfig = first.olapSchema.getConfig(); String projectName = first.olapSchema.getProjectName(); String factTableName = first.firstTableScan.getOlapTable().getTableName(); Set<IRealization> realizations = ProjectManager.getInstance(kylinConfig).getRealizationsByTable(projectName, factTableName); final Map<DataModelDesc, Set<IRealization>> models = Maps.newHashMap(); final Map<DataModelDesc, RealizationCost> costs = Maps.newHashMap(); for (IRealization real : realizations) { if (real.isReady() == false) { context.realizationCheck.addIncapableCube(real, RealizationCheck.IncapableReason.create(RealizationCheck.IncapableType.CUBE_NOT_READY)); continue; } if (containsAll(real.getAllColumnDescs(), first.allColumns) == false) { context.realizationCheck.addIncapableCube(real, RealizationCheck.IncapableReason .notContainAllColumn(notContain(real.getAllColumnDescs(), first.allColumns))); continue; } if (RemoveBlackoutRealizationsRule.accept(real) == false) { context.realizationCheck.addIncapableCube(real, RealizationCheck.IncapableReason .create(RealizationCheck.IncapableType.CUBE_BLACK_OUT_REALIZATION)); continue; } RealizationCost cost = new RealizationCost(real); DataModelDesc m = real.getModel(); Set<IRealization> set = models.get(m); if (set == null) { set = Sets.newHashSet(); set.add(real); models.put(m, set); costs.put(m, cost); } else { set.add(real); RealizationCost curCost = costs.get(m); if (cost.compareTo(curCost) < 0) costs.put(m, cost); } } // order model by cheapest realization cost TreeMap<DataModelDesc, Set<IRealization>> result = Maps.newTreeMap(new Comparator<DataModelDesc>() { @Override public int compare(DataModelDesc o1, DataModelDesc o2) { RealizationCost c1 = costs.get(o1); RealizationCost c2 = costs.get(o2); int comp = c1.compareTo(c2); if (comp == 0) comp = o1.getName().compareTo(o2.getName()); return comp; } }); result.putAll(models); return result; }