/** * 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 when the table name does not correspond to a cube */ public CubeInterface getCube(String tableName) throws LensException { return getCube(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 when the table name does not correspond to a cube */ public CubeInterface getCube(String tableName) throws LensException { return getCube(tableName, true); }
/** * 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); }
/** * 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 { createCubeHiveTable((AbstractCubeTable) cube); // do a get to update cache getCube(cube.getName()); }
/** * 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 { Table cubeTbl = getTableWithTypeFailFast(cubeName, CubeTableType.CUBE); alterCubeTable(cubeName, cubeTbl, (AbstractCubeTable) cube); if (enableCaching) { allCubes.put(cubeName.trim().toLowerCase(), getCube(refreshTable(cubeName))); } }
SegmentationCandidate(CubeQueryContext cubeQueryContext, Segmentation segmentation) throws LensException { this.cubeQueryContext = cubeQueryContext; this.segmentation = segmentation; cubesOfSegmentation = Maps.newHashMap(); cubeQueryContextMap = Maps.newHashMap(); for (Segment segment : segmentation.getSegments()) { // assuming only base cubes in segmentation cubesOfSegmentation.put(segment.getName(), (Cube) getCubeMetastoreClient().getCube(segment.getName())); } }
SegmentationCandidate(CubeQueryContext cubeQueryContext, Segmentation segmentation) throws LensException { this.cubeQueryContext = cubeQueryContext; this.segmentation = segmentation; cubesOfSegmentation = Maps.newHashMap(); cubeQueryContextMap = Maps.newHashMap(); for (Segment segment : segmentation.getSegments()) { // assuming only base cubes in segmentation cubesOfSegmentation.put(segment.getName(), (Cube) getCubeMetastoreClient().getCube(segment.getName())); } }
/** * Create derived cube defined by measures, dimensions and properties * * @param parent Name of the parent cube * @param name Name of the derived cube * @param measures Measures of the derived cube * @param dimensions Dimensions of the derived cube * @param properties Properties of the derived cube * @param weight Weight of the derived cube * @throws LensException */ public void createDerivedCube(String parent, String name, Set<String> measures, Set<String> dimensions, Map<String, String> properties, double weight) throws LensException { DerivedCube cube = new DerivedCube(name, measures, dimensions, properties, weight, (Cube) getCube(parent)); createCube(cube); }
/** * Create derived cube defined by measures, dimensions and properties * * @param parent Name of the parent cube * @param name Name of the derived cube * @param measures Measures of the derived cube * @param dimensions Dimensions of the derived cube * @param properties Properties of the derived cube * @param weight Weight of the derived cube * @throws LensException */ public void createDerivedCube(String parent, String name, Set<String> measures, Set<String> dimensions, Map<String, String> properties, double weight) throws LensException { DerivedCube cube = new DerivedCube(name, measures, dimensions, properties, weight, (Cube) getCube(parent)); createCube(cube); }
/** * 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))); } }
/** * 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 createCube(XCube cube) throws LensException { Cube parent = cube instanceof XDerivedCube ? (Cube) getCube( ((XDerivedCube) cube).getParent()) : null; createCube(JAXBUtils.hiveCubeFromXCube(cube, parent)); }
public void createCube(XCube cube) throws LensException { Cube parent = cube instanceof XDerivedCube ? (Cube) getCube( ((XDerivedCube) cube).getParent()) : null; createCube(JAXBUtils.hiveCubeFromXCube(cube, parent)); }
@Override public List<String> getAllFactNames(LensSessionHandle sessionid, String cubeName) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)){ CubeMetastoreClient client = getClient(sessionid); CubeInterface fact = client.getCube(cubeName); if (cubeName != null && fact == null) { throw new LensException("Could not get table: " + cubeName + " as a cube"); } Collection<FactTable> facts = client.getAllFacts(fact); List<String> factNames = new ArrayList<>(facts.size()); for (FactTable cft : facts) { factNames.add(cft.getName()); } return factNames; } }
private CubeInterface getCube(Table tbl) throws LensException { String parentCube = tbl.getParameters().get(getParentCubeNameKey(tbl.getTableName())); if (parentCube != null) { return new DerivedCube(tbl, (Cube) getCube(parentCube)); } else { return new Cube(tbl); } }
/** * Get a cube from the metastore * * @param cubeName cube name * @return The cube object as {@link XCube} * @throws LensException */ @Override public XCube getCube(LensSessionHandle sessionid, String cubeName) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)){ CubeInterface c = getClient(sessionid).getCube(cubeName); if (c != null) { return JAXBUtils.xCubeFromHiveCube(c); } } return null; }
private CubeInterface getCube(Table tbl) throws LensException { String parentCube = tbl.getParameters().get(getParentCubeNameKey(tbl.getTableName())); if (parentCube != null) { return new DerivedCube(tbl, (Cube) getCube(parentCube)); } else { return new Cube(tbl); } }
public void alterCube(XCube cube) throws HiveException, LensException { Cube parent = cube instanceof XDerivedCube ? (Cube) getCube( ((XDerivedCube) cube).getParent()) : null; alterCube(cube.getName(), JAXBUtils.hiveCubeFromXCube(cube, parent)); } /**
public void alterCube(XCube cube) throws HiveException, LensException { Cube parent = cube instanceof XDerivedCube ? (Cube) getCube( ((XDerivedCube) cube).getParent()) : null; alterCube(cube.getName(), JAXBUtils.hiveCubeFromXCube(cube, parent)); }
@Override public Date getLatestDateOfCube(LensSessionHandle sessionid, String cubeName, String timeDimension) throws LensException, HiveException { try(SessionContext ignored = new SessionContext(sessionid)) { // get the partitionColumn corresponding to timeDimension passed CubeMetastoreClient msClient = getClient(sessionid); CubeInterface ci = msClient.getCube(cubeName); if (!(ci instanceof Cube)) { throw new BadRequestException("cubeName : " + cubeName + " is not a base cube."); } Cube c = (Cube) ci; return msClient.getLatestDateOfCube(c, timeDimension); } }