Java Code Examples for org.apache.kylin.cube.model.CubeDesc#setDimensions()

The following examples show how to use org.apache.kylin.cube.model.CubeDesc#setDimensions() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubeDescCreator.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public static CubeDesc generateKylinCubeDesc(String tableName, int storageType,
        List<DimensionDesc> dimensionDescList, List<MeasureDesc> measureDescList, RowKeyDesc rowKeyDesc,
        AggregationGroup aggGroup, HBaseMappingDesc hBaseMapping, Map<String, String> overrideProperties) {
    CubeDesc desc = new CubeDesc();
    desc.setName(tableName.replace('.', '_'));
    desc.setModelName(tableName.replace('.', '_'));
    desc.setDescription("");
    desc.setLastModified(0L);
    desc.setDimensions(dimensionDescList);
    desc.setMeasures(measureDescList);
    desc.setRowkey(rowKeyDesc);
    desc.setHbaseMapping(hBaseMapping);
    desc.setNotifyList(Lists.<String> newArrayList());
    desc.setStatusNeedNotify(Lists.newArrayList(JobStatusEnum.ERROR.toString()));
    desc.setAutoMergeTimeRanges(new long[] { 86400000L, 604800000L, 2419200000L });
    desc.setEngineType(IEngineAware.ID_MR_V2);
    desc.setStorageType(storageType);
    desc.setAggregationGroups(Lists.newArrayList(aggGroup));
    desc.getOverrideKylinProps().putAll(overrideProperties);
    desc.updateRandomUuid();
    return desc;
}
 
Example 2
Source File: CubeDescCreator.java    From kylin with Apache License 2.0 6 votes vote down vote up
public static CubeDesc generateKylinCubeDesc(String tableName, int storageType,
        List<DimensionDesc> dimensionDescList, List<MeasureDesc> measureDescList, RowKeyDesc rowKeyDesc,
        AggregationGroup aggGroup, HBaseMappingDesc hBaseMapping, Map<String, String> overrideProperties) {
    CubeDesc desc = new CubeDesc();
    desc.setName(tableName.replace('.', '_'));
    desc.setModelName(tableName.replace('.', '_'));
    desc.setDescription("");
    desc.setLastModified(0L);
    desc.setDimensions(dimensionDescList);
    desc.setMeasures(measureDescList);
    desc.setRowkey(rowKeyDesc);
    desc.setHbaseMapping(hBaseMapping);
    desc.setNotifyList(Lists.<String> newArrayList());
    desc.setStatusNeedNotify(Lists.newArrayList(JobStatusEnum.ERROR.toString()));
    desc.setAutoMergeTimeRanges(new long[] { 86400000L, 604800000L, 2419200000L, 7776000000L, 31104000000L });
    desc.setEngineType(IEngineAware.ID_MR_V2);
    desc.setStorageType(storageType);
    desc.setAggregationGroups(Lists.newArrayList(aggGroup));
    desc.getOverrideKylinProps().putAll(overrideProperties);
    desc.updateRandomUuid();
    return desc;
}
 
Example 3
Source File: CubeControllerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Test
public void testBasics() throws IOException {
    CubeDesc[] cubes = cubeDescController.getCube("test_kylin_cube_with_slr_ready");
    Assert.assertNotNull(cubes);
    Assert.assertNotNull(cubeController.getSql("test_kylin_cube_with_slr_ready", "20130331080000_20131212080000"));
    Assert.assertNotNull(cubeController.getCubes(null, null, null, 0, 5));

    CubeDesc cube = cubes[0];
    CubeDesc newCube = new CubeDesc();
    String newCubeName = cube.getName() + "_test_save";

    try {
        cubeController.deleteCube(newCubeName);
    } catch (Exception e) {
        // it may not exist, ignore the exception
    }

    newCube.setName(newCubeName);
    newCube.setModelName(cube.getModelName());
    newCube.setModel(cube.getModel());
    newCube.setDimensions(cube.getDimensions());
    newCube.setHbaseMapping(cube.getHbaseMapping());
    newCube.setMeasures(cube.getMeasures());
    newCube.setRowkey(cube.getRowkey());
    newCube.setAggregationGroups(cube.getAggregationGroups());

    newCube.getModel().setLastModified(0);

    ObjectMapper cubeDescMapper = new ObjectMapper();
    StringWriter cubeDescWriter = new StringWriter();
    cubeDescMapper.writeValue(cubeDescWriter, newCube);

    ObjectMapper modelDescMapper = new ObjectMapper();
    StringWriter modelDescWriter = new StringWriter();
    modelDescMapper.writeValue(modelDescWriter, newCube.getModel());

    CubeRequest cubeRequest = new CubeRequest();
    cubeRequest.setCubeDescData(cubeDescWriter.toString());
    cubeRequest.setCubeName(newCube.getName());
    cubeRequest = cubeController.saveCubeDesc(cubeRequest);

    List<String> notifyList = Lists.newArrayList();
    notifyList.add("[email protected]");
    cubeController.updateNotifyList(newCubeName, notifyList);

    List<CubeInstanceResponse> cubeInstances = cubeController.getCubes(newCubeName, cube.getModelName(), "default",
            1, 0);

    CubeInstance cubeInstance = cubeController.getCube(cubeInstances.get(0).getName());
    Assert.assertTrue(cubeInstance.getDescriptor().getNotifyList().contains("[email protected]"));
    Assert.assertTrue(cubeInstance.getCost() == 495);
    cubeController.deleteCube(newCubeName);
}
 
Example 4
Source File: CubeControllerTest.java    From kylin with Apache License 2.0 4 votes vote down vote up
@Test
public void testBasics() throws IOException {
    CubeDesc[] cubes = cubeDescController.getCube("test_kylin_cube_with_slr_ready");
    Assert.assertNotNull(cubes);
    Assert.assertNotNull(cubeController.getSql("test_kylin_cube_with_slr_ready", "20130331080000_20131212080000"));
    Assert.assertNotNull(cubeController.getCubes(null, null, null, 0, 5));

    CubeDesc cube = cubes[0];
    CubeDesc newCube = new CubeDesc();
    String newCubeName = cube.getName() + "_test_save";

    try {
        cubeController.deleteCube(newCubeName);
    } catch (Exception e) {
        // it may not exist, ignore the exception
    }

    newCube.setName(newCubeName);
    newCube.setModelName(cube.getModelName());
    newCube.setModel(cube.getModel());
    newCube.setDimensions(cube.getDimensions());
    newCube.setHbaseMapping(cube.getHbaseMapping());
    newCube.setMeasures(cube.getMeasures());
    newCube.setRowkey(cube.getRowkey());
    newCube.setAggregationGroups(cube.getAggregationGroups());

    newCube.getModel().setLastModified(0);

    ObjectMapper cubeDescMapper = new ObjectMapper();
    StringWriter cubeDescWriter = new StringWriter();
    cubeDescMapper.writeValue(cubeDescWriter, newCube);

    ObjectMapper modelDescMapper = new ObjectMapper();
    StringWriter modelDescWriter = new StringWriter();
    modelDescMapper.writeValue(modelDescWriter, newCube.getModel());

    CubeRequest cubeRequest = new CubeRequest();
    cubeRequest.setCubeDescData(cubeDescWriter.toString());
    cubeRequest.setCubeName(newCube.getName());
    cubeRequest = cubeController.saveCubeDesc(cubeRequest);

    List<String> notifyList = Lists.newArrayList();
    notifyList.add("[email protected]");
    cubeController.updateNotifyList(newCubeName, notifyList);

    List<CubeInstanceResponse> cubeInstances = cubeController.getCubes(newCubeName, cube.getModelName(), "default",
            1, 0);

    CubeInstance cubeInstance = cubeController.getCube(cubeInstances.get(0).getName());
    Assert.assertTrue(cubeInstance.getDescriptor().getNotifyList().contains("[email protected]"));
    Assert.assertTrue(cubeInstance.getCost() == 495);
    cubeController.deleteCube(newCubeName);
}
 
Example 5
Source File: CubeControllerTest.java    From Kylin with Apache License 2.0 4 votes vote down vote up
@Test
public void testBasics() throws IOException {
    CubeDesc[] cubes = (CubeDesc[]) cubeDescController.getCube("test_kylin_cube_with_slr_ready");
    Assert.assertNotNull(cubes);
    Assert.assertNotNull(cubeController.getSql("test_kylin_cube_with_slr_ready", "20130331080000_20131212080000"));
    Assert.assertNotNull(cubeController.getCubes(null, null, 0, 5));

    CubeDesc cube = cubes[0];
    CubeDesc newCube = new CubeDesc();
    String newCubeName = cube.getName() + "_test_save";

    try {
        cubeController.deleteCube(newCubeName);
    } catch (Exception e) {
        // it may not exist, ignore the exception
    }

    newCube.setName(newCubeName);
    newCube.setModelName(cube.getModelName());
    newCube.setModel(cube.getModel());
    newCube.setDimensions(cube.getDimensions());
    newCube.setHBaseMapping(cube.getHBaseMapping());
    newCube.setMeasures(cube.getMeasures());
    newCube.setConfig(cube.getConfig());
    newCube.setRowkey(cube.getRowkey());

    String newModelName = newCubeName + "_model_desc";
    newCube.getModel().setName(newModelName);//generate a random model
    newCube.getModel().setLastModified(0);

    ObjectMapper cubeDescMapper = new ObjectMapper();
    StringWriter cubeDescWriter = new StringWriter();
    cubeDescMapper.writeValue(cubeDescWriter, newCube);

    ObjectMapper modelDescMapper = new ObjectMapper();
    StringWriter modelDescWriter = new StringWriter();
    modelDescMapper.writeValue(modelDescWriter, newCube.getModel());

    CubeRequest cubeRequest = new CubeRequest();
    cubeRequest.setCubeDescData(cubeDescWriter.toString());
    cubeRequest.setModelDescData(modelDescWriter.toString());
    cubeRequest = cubeController.saveCubeDesc(cubeRequest);


    DataModelDesc model = modelController.getModel(newModelName);
    Assert.assertNotNull(model);

    List<String> notifyList = Lists.newArrayList();
    notifyList.add("[email protected]");
    cubeController.updateNotifyList(newCubeName, notifyList);
    cubeController.updateCubeCost(newCubeName, 80);

    List<CubeInstance> cubeInstances = cubeController.getCubes(newCubeName, "default", 1, 0);

    CubeInstance cubeInstance = cubeInstances.get(0);
    Assert.assertTrue(cubeInstance.getDescriptor().getNotifyList().contains("[email protected]"));
    Assert.assertTrue(cubeInstance.getCost() == 80);
    cubeController.deleteCube(newCubeName);
}