use of io.hetu.core.cube.startree.tree.StarTreeMetadataBuilder in project hetu-core by openlookeng.
the class StarTreeMetaStore method convertTablesToMetadata.
private List<CubeMetadata> convertTablesToMetadata(List<TableEntity> tableEntities) {
List<CubeMetadata> cubeMetadataList = new ArrayList<>();
tableEntities.forEach(table -> {
List<ColumnEntity> cols = table.getColumns();
StarTreeMetadataBuilder builder = new StarTreeMetadataBuilder(table.getParameters().get(STAR_TABLE_NAME), table.getParameters().get(SOURCE_TABLE_NAME));
cols.forEach(col -> {
if (col.getType().equals("aggregate")) {
builder.addAggregationColumn(col.getName(), col.getParameters().get("aggregateFunction"), col.getParameters().get(ORIGINAL_COLUMN), Boolean.parseBoolean(col.getParameters().get("distinct")));
} else if (col.getType().equals("dimension")) {
builder.addDimensionColumn(col.getName(), col.getParameters().get(ORIGINAL_COLUMN));
}
});
String groupingString = table.getParameters().get(GROUPING_STRING);
// Create empty set to support Empty Group
builder.addGroup((groupingString == null || groupingString.isEmpty()) ? new HashSet<>() : Sets.newHashSet(groupingString.split(COLUMN_DELIMITER)));
String sourceTablePredicate = table.getParameters().get(SOURCE_FILTER_STRING);
String cubePredicate = table.getParameters().get(PREDICATE_STRING);
if (sourceTablePredicate != null || cubePredicate != null) {
builder.withCubeFilter(new CubeFilter(sourceTablePredicate, cubePredicate));
}
builder.setCubeStatus(CubeStatus.forValue(Integer.parseInt(table.getParameters().get(CUBE_STATUS))));
builder.setTableLastUpdatedTime(Long.parseLong(table.getParameters().get(SOURCE_TABLE_LAST_UPDATED_TIME)));
builder.setCubeLastUpdatedTime(Long.parseLong(table.getParameters().get(CUBE_LAST_UPDATED_TIME)));
cubeMetadataList.add(builder.build());
});
return cubeMetadataList;
}
use of io.hetu.core.cube.startree.tree.StarTreeMetadataBuilder in project hetu-core by openlookeng.
the class TestStarTreeMetaStore method testUpdateMetadata.
@Test
public void testUpdateMetadata() {
cubeMetadataService.persist(cubeMetadata1);
StarTreeMetadata starTreeMetadata = (StarTreeMetadata) cubeMetadata1;
StarTreeMetadataBuilder builder = new StarTreeMetadataBuilder(starTreeMetadata);
builder.setCubeLastUpdatedTime(System.currentTimeMillis());
CubeMetadata updated = builder.build();
assertNotEquals(cubeMetadata1, updated);
}
Aggregations