/** * Get {@link Cube} object corresponding to the name * * @param tableName The cube name * @return Returns cube is table name passed is a cube * @throws LensException if there is no cube by the name */ public FactTable getFactTable(String tableName) throws LensException { return getFactTable(tableName, true); }
/** * Get {@link Cube} object corresponding to the name * * @param tableName The cube name * @return Returns cube is table name passed is a cube * @throws LensException if there is no cube by the name */ public FactTable getFactTable(String tableName) throws LensException { return getFactTable(tableName, true); } private FactTable getFactTable(String tableName, boolean throwException) throws LensException {
public void createVirtualFactTable(String cubeName, String virtualFactName, String sourceFactName, Double weight, Map<String, String> properties) throws LensException { FactTable sourceFact = getFactTable(sourceFactName); Optional<Double> optionalWeight = Optional.fromNullable(weight); CubeVirtualFactTable factTable = new CubeVirtualFactTable(cubeName, virtualFactName, optionalWeight, properties, sourceFact); createCubeTable(factTable, null); // do a get to update cache getFactTable(virtualFactName); }
public XFact getXFactTable(String tableName) throws LensException { return getXFactTable(getFactTable(tableName)); }
public void createVirtualFactTable(String cubeName, String virtualFactName, String sourceFactName, Double weight, Map<String, String> properties) throws LensException { FactTable sourceFact = getFactTable(sourceFactName); checkIfAuthorized(); Optional<Double> optionalWeight = Optional.fromNullable(weight); CubeVirtualFactTable factTable = new CubeVirtualFactTable(cubeName, virtualFactName, optionalWeight, properties, sourceFact); createCubeTable(factTable, null); // do a get to update cache getFactTable(virtualFactName); }
public void createCubeFactTable(String cubeName, String factName, List<FieldSchema> columns, Map<String, Set<UpdatePeriod>> storageAggregatePeriods, double weight, Map<String, String> properties, Map<String, StorageTableDesc> storageTableDescs, Map<String, Map<UpdatePeriod, String>> storageUpdatePeriodMap) throws LensException { CubeFactTable factTable = new CubeFactTable(cubeName, factName, columns, storageAggregatePeriods, weight, properties, storageUpdatePeriodMap); createCubeTable(factTable, storageTableDescs); // do a get to update cache getFactTable(factName); }
private void ensureEntryForTimeLineKey(String fact, String storage, UpdatePeriod updatePeriod, String storageTableName, String timeLineKey) throws LensException { // Not found in table properties either, compute from all partitions of the fact-storage table. // First make sure all combinations of update period and partition column have an entry even // if no partitions exist if (getFactTable(fact).getUpdatePeriods() != null && getFactTable(fact).getUpdatePeriods().get(storage) != null) { log.info("loading from all partitions: {}", storageTableName); Table storageTable = getTable(storageTableName); for (String partCol : getTimePartColNamesOfTable(storageTable)) { ensureEntry(timeLineKey, storageTableName, updatePeriod, partCol); } } }
private void ensureEntryForTimeLineKey(String fact, String storage, UpdatePeriod updatePeriod, String storageTableName, String timeLineKey) throws LensException { // Not found in table properties either, compute from all partitions of the fact-storage table. // First make sure all combinations of update period and partition column have an entry even // if no partitions exist if (getFactTable(fact).getUpdatePeriods() != null && getFactTable(fact).getUpdatePeriods().get(storage) != null) { log.info("loading from all partitions: {}", storageTableName); Table storageTable = getTable(storageTableName); for (String partCol : getTimePartColNamesOfTable(storageTable)) { ensureEntry(timeLineKey, storageTableName, updatePeriod, partCol); } } }
/** * Get all facts in metastore * * @return List of Cube Fact Table objects * @throws LensException */ public Collection<FactTable> getAllFacts() throws LensException { if (!allFactTablesPopulated) { List<FactTable> facts = new ArrayList<>(); try { for (String table : getAllHiveTableNames()) { FactTable fact = getFactTable(table, false); if (fact != null) { facts.add(fact); } } } catch (HiveException e) { throw new LensException("Could not get all fact tables", e); } allFactTablesPopulated = enableCaching; return facts; } else { return allFactTables.values(); } }
/** * Get all facts in metastore * * @return List of Cube Fact Table objects * @throws LensException */ public Collection<FactTable> getAllFacts() throws LensException { if (!allFactTablesPopulated) { List<FactTable> facts = new ArrayList<>(); try { for (String table : getAllHiveTableNames()) { FactTable fact = getFactTable(table, false); if (fact != null) { facts.add(fact); } } } catch (HiveException e) { throw new LensException("Could not get all fact tables", e); } allFactTablesPopulated = enableCaching; return facts; } else { return allFactTables.values(); } }
/** * Create a cube fact table * * @param cubeName The cube name to which fact belongs to. * @param factName The fact name * @param columns The columns of fact table * @param storageAggregatePeriods Aggregate periods for the storages * @param weight Weight of the cube * @param properties Properties of fact table * @param storageTableDescs Map of storage table prefix to its storage table description * @throws LensException */ public void createCubeFactTable(String cubeName, String factName, List<FieldSchema> columns, Map<String, Set<UpdatePeriod>> storageAggregatePeriods, double weight, Map<String, String> properties, Map<String, StorageTableDesc> storageTableDescs) throws LensException { CubeFactTable factTable = new CubeFactTable(cubeName, factName, columns, storageAggregatePeriods, weight, properties); createCubeTable(factTable, storageTableDescs); // do a get to update cache getFactTable(factName); }
public void createCubeFactTable(String cubeName, String factName, List<FieldSchema> columns, Map<String, Set<UpdatePeriod>> storageAggregatePeriods, double weight, Map<String, String> properties, Map<String, StorageTableDesc> storageTableDescs, Map<String, Map<UpdatePeriod, String>> storageUpdatePeriodMap, Map<String, Set<String>> storageTablePartitionColumns) throws LensException { checkIfAuthorized(); CubeFactTable factTable = new CubeFactTable(cubeName, factName, columns, storageAggregatePeriods, weight, properties, storageUpdatePeriodMap, storageTablePartitionColumns); createCubeTable(factTable, storageTableDescs); // do a get to update cache getFactTable(factName); }
public CubeVirtualFactTable getCubeVirtualFactTable(String factName) throws LensException { FactTable factTable = getFactTable(factName); if (factTable instanceof CubeVirtualFactTable) { return (CubeVirtualFactTable) factTable; } else { throw new LensException(new LensException(LensCubeErrorCode.ENTITY_TYPE_NOT_AS_EXPECTED.getLensErrorInfo(), factName, "VirtualFact")); } }
public CubeFactTable getCubeFactTable(String factName) throws LensException { FactTable factTable = getFactTable(factName); if (factTable instanceof CubeFactTable) { return (CubeFactTable) factTable; } else { throw new LensException(new LensException(LensCubeErrorCode.ENTITY_TYPE_NOT_AS_EXPECTED.getLensErrorInfo(), factName, "Fact")); } }
public CubeFactTable getCubeFactTable(String factName) throws LensException { FactTable factTable = getFactTable(factName); if (factTable instanceof CubeFactTable) { return (CubeFactTable) factTable; } else { throw new LensException(new LensException(LensCubeErrorCode.ENTITY_TYPE_NOT_AS_EXPECTED.getLensErrorInfo(), factName, "Fact")); } }
public CubeVirtualFactTable getCubeVirtualFactTable(String factName) throws LensException { FactTable factTable = getFactTable(factName); if (factTable instanceof CubeVirtualFactTable) { return (CubeVirtualFactTable) factTable; } else { throw new LensException(new LensException(LensCubeErrorCode.ENTITY_TYPE_NOT_AS_EXPECTED.getLensErrorInfo(), factName, "VirtualFact")); } }
/** * Create a cube fact table * * @param cubeName The cube name to which fact belongs to. * @param factName The fact name * @param columns The columns of fact table * @param storageAggregatePeriods Aggregate periods for the storages * @param weight Weight of the cube * @param properties Properties of fact table * @param storageTableDescs Map of storage table prefix to its storage table description * @throws LensException */ public void createCubeFactTable(String cubeName, String factName, List<FieldSchema> columns, Map<String, Set<UpdatePeriod>> storageAggregatePeriods, double weight, Map<String, String> properties, Map<String, StorageTableDesc> storageTableDescs) throws LensException { CubeFactTable factTable = new CubeFactTable(cubeName, factName, columns, storageAggregatePeriods, weight, properties); checkIfAuthorized(); createCubeTable(factTable, storageTableDescs); // do a get to update cache getFactTable(factName); }
public XStorageTableElement getStorageOfFact(LensSessionHandle sessionid, String fact, String storageName) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)) { CubeMetastoreClient msClient = getClient(sessionid); FactTable factTable = msClient.getFactTable(fact); Set<UpdatePeriod> updatePeriods = factTable.getUpdatePeriods().get(storageName); XStorageTableElement tblElement = JAXBUtils.getXStorageTableFromHiveTable( msClient.getHiveTable(MetastoreUtil.getFactOrDimtableStorageTableName(fact, storageName))); tblElement.setStorageName(storageName); for (UpdatePeriod p : updatePeriods) { tblElement.getUpdatePeriods().getUpdatePeriod().add(XUpdatePeriod.valueOf(p.name())); } return tblElement; } }
public void alterCubeFactTable(XFact fact) throws LensException, HiveException { if (fact instanceof XVirtualFactTable) { XVirtualFactTable xvf = (XVirtualFactTable) fact; alterCubeFactTable(xvf.getName(), JAXBUtils.cubeVirtualFactFromFactTable(xvf, getFactTable(xvf.getSourceFactName())), null, new HashMap<>()); } else { XFactTable xf = (XFactTable) fact; alterCubeFactTable(fact.getName(), JAXBUtils.cubeFactFromFactTable(xf), JAXBUtils.tableDescPrefixMapFromXStorageTables(xf.getStorageTables()), JAXBUtils.columnStartAndEndTimeFromXColumns(xf.getColumns())); } }
public void alterCubeFactTable(XFact fact) throws LensException, HiveException { if (fact instanceof XVirtualFactTable) { XVirtualFactTable xvf = (XVirtualFactTable) fact; alterCubeFactTable(xvf.getName(), JAXBUtils.cubeVirtualFactFromFactTable(xvf, getFactTable(xvf.getSourceFactName())), null, new HashMap<>()); } else { XFactTable xf = (XFactTable) fact; alterCubeFactTable(fact.getName(), JAXBUtils.cubeFactFromFactTable(xf), JAXBUtils.tableDescPrefixMapFromXStorageTables(xf.getStorageTables()), JAXBUtils.columnStartAndEndTimeFromXColumns(xf.getColumns())); } }