/** * Get list of all cubes names in the current database * * @return List of cube names * @throws LensException */ @Override public List<String> getAllCubeNames(LensSessionHandle sessionid) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)){ Collection<CubeInterface> cubes = getClient(sessionid).getAllCubes(); if (cubes != null && !cubes.isEmpty()) { List<String> names = new ArrayList<>(cubes.size()); for (CubeInterface cube : cubes) { names.add(cube.getName()); } return names; } } return null; }
@Override public List<String> getAllDerivedCubeNames(LensSessionHandle sessionid) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)){ Collection<CubeInterface> cubes = getClient(sessionid).getAllCubes(); if (cubes != null && !cubes.isEmpty()) { List<String> names = new ArrayList<>(cubes.size()); for (CubeInterface cube : cubes) { if (cube.isDerivedCube()) { names.add(cube.getName()); } } return names; } } return null; }
@Override public List<String> getAllBaseCubeNames(LensSessionHandle sessionid) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)){ Collection<CubeInterface> cubes = getClient(sessionid).getAllCubes(); if (cubes != null && !cubes.isEmpty()) { List<String> names = new ArrayList<>(cubes.size()); for (CubeInterface cube : cubes) { if (!cube.isDerivedCube()) { names.add(cube.getName()); } } return names; } } return null; }
@Override public List<String> getAllQueryableCubeNames(LensSessionHandle sessionid) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)){ Collection<CubeInterface> cubes = getClient(sessionid).getAllCubes(); if (cubes != null && !cubes.isEmpty()) { List<String> names = new ArrayList<>(cubes.size()); for (CubeInterface cube : cubes) { if (cube.allFieldsQueriable()) { names.add(cube.getName()); } } return names; } } return null; }
/** * Get all derived cubes of the cube, that have all fields queryable together * * @param cube Cube object * @return List of DerivedCube objects * @throws LensException */ public List<DerivedCube> getAllDerivedQueryableCubes(CubeInterface cube) throws LensException { List<DerivedCube> dcubes = new ArrayList<>(); for (CubeInterface cb : getAllCubes()) { if (cb.isDerivedCube() && ((DerivedCube) cb).getParent().getName().equalsIgnoreCase(cube.getName()) && cb.allFieldsQueriable()) { dcubes.add((DerivedCube) cb); } } return dcubes; }
/** * Get all derived cubes of the cube, that have all fields queryable together * * @param cube Cube object * @return List of DerivedCube objects * @throws LensException */ public List<DerivedCube> getAllDerivedQueryableCubes(CubeInterface cube) throws LensException { List<DerivedCube> dcubes = new ArrayList<>(); for (CubeInterface cb : getAllCubes()) { if (cb.isDerivedCube() && ((DerivedCube) cb).getParent().getName().equalsIgnoreCase(cube.getName()) && cb.allFieldsQueriable()) { dcubes.add((DerivedCube) cb); } } return dcubes; }
client = CubeMetastoreClient.getInstance(conf); CubeMetastoreClient client2 = CubeMetastoreClient.getInstance(new HiveConf(TestCubeMetastoreClient.class)); assertEquals(6, client.getAllCubes().size()); assertEquals(6, client2.getAllCubes().size()); assertNotNull(client.getCube("testcache1")); assertNotNull(client2.getCube("testcache1")); assertEquals(10, client.getAllCubes().size()); assertEquals(10, client2.getAllCubes().size()); assertEquals(10, client.getAllCubes().size()); assertEquals(10, client2.getAllCubes().size()); assertEquals(10, client.getAllCubes().size()); assertEquals(10, client2.getAllCubes().size()); defineCube("testcache3", "testcache4", "dervied3", "derived4"); client.createCube("testcache3", cubeMeasures, cubeDimensions); assertNotNull(client.getCube("testcache3")); assertNotNull(client2.getCube("testcache3")); assertEquals(14, client.getAllCubes().size()); assertEquals(14, client2.getAllCubes().size()); conf.setBoolean(MetastoreConstants.METASTORE_ENABLE_CACHING, true); client = CubeMetastoreClient.getInstance(conf);