public void createSegmentation(Segmentation cubeSeg) throws LensException { checkIfAuthorized(); // create virtual cube table in metastore createCubeHiveTable(cubeSeg); }
public void dropSegmentation(String segName) throws LensException { getTableWithTypeFailFast(segName, CubeTableType.SEGMENTATION); checkIfAuthorized(); dropHiveTable(segName); allSegmentations.remove(segName.trim().toLowerCase()); }
/** * Drop a dimension * * @param dimName dimension name to be dropped * @throws LensException */ public void dropDimension(String dimName) throws LensException { getTableWithTypeFailFast(dimName, CubeTableType.DIMENSION); checkIfAuthorized(); allDims.remove(dimName.trim().toLowerCase()); dropHiveTable(dimName); }
/** * Drop a cube * * @param cubeName cube name * @throws LensException */ public void dropCube(String cubeName) throws LensException { checkIfAuthorized(); getCube(getTableWithTypeFailFast(cubeName, CubeTableType.CUBE)); allCubes.remove(cubeName.trim().toLowerCase()); dropHiveTable(cubeName); }
public void alterStorage(String storageName, Storage storage) throws LensException, HiveException { checkIfAuthorized(); Table storageTbl = getTableWithTypeFailFast(storageName, CubeTableType.STORAGE); alterCubeTable(storageName, storageTbl, storage); if (enableCaching) { allStorages.put(storageName.trim().toLowerCase(), getStorage(refreshTable(storageName))); } }
public void alterDimension(String dimName, Dimension newDim) throws HiveException, LensException { checkIfAuthorized(); Table tbl = getTableWithTypeFailFast(dimName, CubeTableType.DIMENSION); alterCubeTable(dimName, tbl, newDim); if (enableCaching) { allDims.put(dimName.trim().toLowerCase(), getDimension(refreshTable(dimName))); } }
/** * Alter cube specified by the name to new definition * * @param cubeName The cube name to be altered * @param cube The new cube definition {@link Cube} or {@link DerivedCube} * @throws HiveException */ public void alterCube(String cubeName, CubeInterface cube) throws HiveException, LensException { checkIfAuthorized(); Table cubeTbl = getTableWithTypeFailFast(cubeName, CubeTableType.CUBE); alterCubeTable(cubeName, cubeTbl, (AbstractCubeTable) cube); if (enableCaching) { allCubes.put(cubeName.trim().toLowerCase(), getCube(refreshTable(cubeName))); } }
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 void createStorage(Storage storage) throws LensException { checkIfAuthorized(); createCubeHiveTable(storage); // do a get to update cache getStorage(storage.getName()); }
/** * Create cube in metastore defined by {@link Cube} or {@link DerivedCube} object * * @param cube the {@link Cube} object. * @throws LensException */ public void createCube(CubeInterface cube) throws LensException { checkIfAuthorized(); createCubeHiveTable((AbstractCubeTable) cube); // do a get to update cache getCube(cube.getName()); }
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); }
/** * Create dimension in metastore defined by {@link Dimension} object * * @param dim the {@link Dimension} object. * @throws LensException */ public void createDimension(Dimension dim) throws LensException { checkIfAuthorized(); createCubeHiveTable(dim); // do a get to update cache getDimension(dim.getName()); }
private void dropStorageFromDim(String dimTblName, String storage, boolean updateDimTbl) throws LensException { checkIfAuthorized(); CubeDimensionTable cdt = getDimensionTable(dimTblName); String storageTableName = getFactOrDimtableStorageTableName(dimTblName, storage); dropHiveTable(storageTableName); latestLookupCache.remove(storageTableName.trim().toLowerCase()); if (updateDimTbl) { cdt.dropStorage(storage); alterCubeTable(dimTblName, getTableWithTypeFailFast(dimTblName, CubeTableType.DIM_TABLE), cdt); updateDimCache(dimTblName); } }
/** * Drop the dimension table * * @param dimTblName dim table name * @param cascade If true, will drop all the dimension storages * @throws HiveException */ public void dropDimensionTable(String dimTblName, boolean cascade) throws LensException { checkIfAuthorized(); getTableWithTypeFailFast(dimTblName, CubeTableType.DIM_TABLE); CubeDimensionTable dim = getDimensionTable(dimTblName); if (cascade) { for (String storage : dim.getStorages()) { dropStorageFromDim(dimTblName, storage, false); } } dropHiveTable(dimTblName); allDimTables.remove(dimTblName.trim().toLowerCase()); }
/** * Alter dimension table with new dimension definition and underlying storage tables as well * * @param dimTableName dim table name * @param cubeDimensionTable cube dimention table * @throws HiveException */ public void alterCubeDimensionTable(String dimTableName, CubeDimensionTable cubeDimensionTable, Map<String, StorageTableDesc> storageTableDescs) throws HiveException, LensException { checkIfAuthorized(); Table dimTbl = getTableWithTypeFailFast(dimTableName, CubeTableType.DIM_TABLE); alterCubeTable(dimTableName, dimTbl, cubeDimensionTable); if (storageTableDescs != null) { // create/alter tables for each storage for (Map.Entry<String, StorageTableDesc> entry : storageTableDescs.entrySet()) { createOrAlterStorageHiveTable(getTable(dimTableName), entry.getKey(), entry.getValue()); } } updateDimCache(dimTableName); }
/** * Create a cube dimension table * * @param dimName The dimension name to which the dim-table belongs to * @param dimTblName dimension table name * @param columns Columns of the dimension table * @param weight Weight of the dimension table * @param dumpPeriods Storage names and their dump periods on which dimension is available * @param properties properties of dimension table * @param storageTableDescs Map of storage to its storage table description * @throws LensException */ public void createCubeDimensionTable(String dimName, String dimTblName, List<FieldSchema> columns, double weight, Map<String, UpdatePeriod> dumpPeriods, Map<String, String> properties, Map<String, StorageTableDesc> storageTableDescs) throws LensException { checkIfAuthorized(); CubeDimensionTable dimTable = new CubeDimensionTable(dimName, dimTblName, columns, weight, dumpPeriods, properties); createCubeTable(dimTable, storageTableDescs); // do a get to update cache getDimensionTable(dimTblName); }
/** * Create a cube dimension table * * @param dimName The dimension name to which the dim-table belongs to * @param dimTblName dimension table name * @param columns Columns of the dimension table * @param weight Weight of the dimension table * @param storageNames Storages on which dimension is available without any dumps * @param properties Properties of dimension table * @param storageTableDescs Map of storage to its storage table description * @throws LensException */ public void createCubeDimensionTable(String dimName, String dimTblName, List<FieldSchema> columns, double weight, Set<String> storageNames, Map<String, String> properties, Map<String, StorageTableDesc> storageTableDescs) throws LensException { CubeDimensionTable dimTable = new CubeDimensionTable(dimName, dimTblName, columns, weight, storageNames, properties); checkIfAuthorized(); createCubeTable(dimTable, storageTableDescs); // do a get to update cache getDimensionTable(dimTblName); }
public void alterSegmentation(String segName, Segmentation seg) throws HiveException, LensException { getTableWithTypeFailFast(segName, CubeTableType.SEGMENTATION); checkIfAuthorized(); if (!(getSegmentation(segName) == seg)) { dropSegmentation(segName); createSegmentation(seg); updateSegmentationCache(segName); } }
/** * Drop a storage from fact * * @param factName fact name * @param storage storage name * @throws LensException */ public void dropStorageFromFact(String factName, String storage) throws LensException { CubeFactTable cft = getCubeFactTable(factName); checkIfAuthorized(); dropHiveTablesForStorage(factName, storage); cft.dropStorage(storage); alterCubeTable(factName, getTableWithTypeFailFast(factName, CubeTableType.FACT), cft); updateFactCache(factName); }
/** * Adds storage to dimension and creates corresponding storage table * * @param dim The CubeDimensionTable * @param storage The storage * @param dumpPeriod The dumpPeriod if any, null otherwise * @param storageTableDesc The storage table description * @throws LensException */ public void addStorage(CubeDimensionTable dim, String storage, UpdatePeriod dumpPeriod, StorageTableDesc storageTableDesc) throws LensException { checkIfAuthorized(); dim.alterSnapshotDumpPeriod(storage, dumpPeriod); createOrAlterStorageHiveTable(getTableWithTypeFailFast(dim.getName(), CubeTableType.DIM_TABLE), storage, storageTableDesc); alterCubeTable(dim.getName(), getTableWithTypeFailFast(dim.getName(), CubeTableType.DIM_TABLE), dim); updateDimCache(dim.getName()); }