Search in sources :

Example 1 with StarTreeMetadataBuilder

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;
}
Also used : StarTreeMetadataBuilder(io.hetu.core.cube.startree.tree.StarTreeMetadataBuilder) ColumnEntity(io.prestosql.spi.metastore.model.ColumnEntity) ArrayList(java.util.ArrayList) CubeFilter(io.hetu.core.spi.cube.CubeFilter) CubeMetadata(io.hetu.core.spi.cube.CubeMetadata) HashSet(java.util.HashSet)

Example 2 with StarTreeMetadataBuilder

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);
}
Also used : StarTreeMetadataBuilder(io.hetu.core.cube.startree.tree.StarTreeMetadataBuilder) StarTreeMetadata(io.hetu.core.cube.startree.tree.StarTreeMetadata) CubeMetadata(io.hetu.core.spi.cube.CubeMetadata) Test(org.testng.annotations.Test)

Aggregations

StarTreeMetadataBuilder (io.hetu.core.cube.startree.tree.StarTreeMetadataBuilder)2 CubeMetadata (io.hetu.core.spi.cube.CubeMetadata)2 StarTreeMetadata (io.hetu.core.cube.startree.tree.StarTreeMetadata)1 CubeFilter (io.hetu.core.spi.cube.CubeFilter)1 ColumnEntity (io.prestosql.spi.metastore.model.ColumnEntity)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Test (org.testng.annotations.Test)1