Java Code Examples for org.apache.kylin.metadata.model.DataModelDesc#setLastModified()

The following examples show how to use org.apache.kylin.metadata.model.DataModelDesc#setLastModified() . 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: ModelCreator.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public static DataModelDesc generateKylinModel(String owner, String tableName, List<String> dimensions,
        List<String> measures, PartitionDesc partitionDesc) {
    ModelDimensionDesc modelDimensionDesc = new ModelDimensionDesc();
    modelDimensionDesc.setTable(tableName);
    modelDimensionDesc.setColumns(dimensions.toArray(new String[dimensions.size()]));

    DataModelDesc kylinModel = new DataModelDesc();
    kylinModel.setName(tableName.replace('.', '_'));
    kylinModel.setOwner(owner);
    kylinModel.setDescription("");
    kylinModel.setLastModified(0L);
    kylinModel.setRootFactTableName(tableName);
    kylinModel.setJoinTables(new JoinTableDesc[0]);
    kylinModel.setDimensions(Lists.newArrayList(modelDimensionDesc));
    kylinModel.setMetrics(measures.toArray(new String[measures.size()]));
    kylinModel.setFilterCondition("");
    kylinModel.setPartitionDesc(partitionDesc);
    kylinModel.setCapacity(DataModelDesc.RealizationCapacity.SMALL);
    kylinModel.updateRandomUuid();

    return kylinModel;
}
 
Example 2
Source File: ModelCreator.java    From kylin with Apache License 2.0 6 votes vote down vote up
public static DataModelDesc generateKylinModel(String owner, String tableName, List<String> dimensions,
        List<String> measures, PartitionDesc partitionDesc) {
    ModelDimensionDesc modelDimensionDesc = new ModelDimensionDesc();
    modelDimensionDesc.setTable(tableName);
    modelDimensionDesc.setColumns(dimensions.toArray(new String[dimensions.size()]));

    DataModelDesc kylinModel = new DataModelDesc();
    kylinModel.setName(tableName.replace('.', '_'));
    kylinModel.setOwner(owner);
    kylinModel.setDescription("");
    kylinModel.setLastModified(0L);
    kylinModel.setRootFactTableName(tableName);
    kylinModel.setJoinTables(new JoinTableDesc[0]);
    kylinModel.setDimensions(Lists.newArrayList(modelDimensionDesc));
    kylinModel.setMetrics(measures.toArray(new String[measures.size()]));
    kylinModel.setFilterCondition("");
    kylinModel.setPartitionDesc(partitionDesc);
    kylinModel.setCapacity(DataModelDesc.RealizationCapacity.SMALL);
    kylinModel.updateRandomUuid();

    return kylinModel;
}
 
Example 3
Source File: CacheServiceTest.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Test
public void testMetaCRUD() throws Exception {
    final TableMetadataManager tableMgr = TableMetadataManager.getInstance(configA);
    final TableMetadataManager tableMgrB = TableMetadataManager.getInstance(configB);
    final DataModelManager modelMgr = DataModelManager.getInstance(configA);
    final DataModelManager modelMgrB = DataModelManager.getInstance(configB);
    final Broadcaster broadcaster = Broadcaster.getInstance(configA);
    broadcaster.getCounterAndClear();

    TableDesc tableDesc = createTestTableDesc();
    assertTrue(tableMgr.getTableDesc(tableDesc.getIdentity(), "default") == null);
    assertTrue(tableMgrB.getTableDesc(tableDesc.getIdentity(), "default") == null);
    tableMgr.saveSourceTable(tableDesc, "default");
    //only one for table insert
    assertEquals(1, broadcaster.getCounterAndClear());
    waitForCounterAndClear(1);
    assertNotNull(tableMgr.getTableDesc(tableDesc.getIdentity(), "default"));
    assertNotNull(tableMgrB.getTableDesc(tableDesc.getIdentity(), "default"));

    final String dataModelName = "test_data_model";
    DataModelDesc dataModelDesc = modelMgr.getDataModelDesc("test_kylin_left_join_model_desc");
    dataModelDesc.setName(dataModelName);
    dataModelDesc.setLastModified(0);
    assertTrue(modelMgr.getDataModelDesc(dataModelName) == null);
    assertTrue(modelMgrB.getDataModelDesc(dataModelName) == null);

    dataModelDesc.setName(dataModelName);
    modelMgr.createDataModelDesc(dataModelDesc, "default", "ADMIN");
    //one for data model creation, one for project meta update
    assertEquals(2, broadcaster.getCounterAndClear());
    waitForCounterAndClear(2);
    assertEquals(dataModelDesc.getName(), modelMgrB.getDataModelDesc(dataModelName).getName());

    final JoinTableDesc[] lookups = dataModelDesc.getJoinTables();
    assertTrue(lookups.length > 0);
    modelMgr.updateDataModelDesc(dataModelDesc);
    //only one for data model update
    assertEquals(1, broadcaster.getCounterAndClear());
    waitForCounterAndClear(1);
    assertEquals(dataModelDesc.getJoinTables().length,
            modelMgrB.getDataModelDesc(dataModelName).getJoinTables().length);

}
 
Example 4
Source File: CacheServiceTest.java    From kylin with Apache License 2.0 4 votes vote down vote up
@Test
public void testMetaCRUD() throws Exception {
    final TableMetadataManager tableMgr = TableMetadataManager.getInstance(configA);
    final TableMetadataManager tableMgrB = TableMetadataManager.getInstance(configB);
    final DataModelManager modelMgr = DataModelManager.getInstance(configA);
    final DataModelManager modelMgrB = DataModelManager.getInstance(configB);
    final Broadcaster broadcaster = Broadcaster.getInstance(configA);
    broadcaster.getCounterAndClear();

    TableDesc tableDesc = createTestTableDesc();
    assertTrue(tableMgr.getTableDesc(tableDesc.getIdentity(), "default") == null);
    assertTrue(tableMgrB.getTableDesc(tableDesc.getIdentity(), "default") == null);
    tableMgr.saveSourceTable(tableDesc, "default");
    //only one for table insert
    assertEquals(1, broadcaster.getCounterAndClear());
    waitForCounterAndClear(1);
    assertNotNull(tableMgr.getTableDesc(tableDesc.getIdentity(), "default"));
    assertNotNull(tableMgrB.getTableDesc(tableDesc.getIdentity(), "default"));

    final String dataModelName = "test_data_model";
    DataModelDesc dataModelDesc = modelMgr.getDataModelDesc("test_kylin_left_join_model_desc");
    dataModelDesc.setName(dataModelName);
    dataModelDesc.setLastModified(0);
    assertTrue(modelMgr.getDataModelDesc(dataModelName) == null);
    assertTrue(modelMgrB.getDataModelDesc(dataModelName) == null);

    dataModelDesc.setName(dataModelName);
    modelMgr.createDataModelDesc(dataModelDesc, "default", "ADMIN");
    //one for data model creation, one for project meta update
    assertEquals(2, broadcaster.getCounterAndClear());
    waitForCounterAndClear(2);
    assertEquals(dataModelDesc.getName(), modelMgrB.getDataModelDesc(dataModelName).getName());

    final JoinTableDesc[] lookups = dataModelDesc.getJoinTables();
    assertTrue(lookups.length > 0);
    modelMgr.updateDataModelDesc(dataModelDesc);
    //only one for data model update
    assertEquals(1, broadcaster.getCounterAndClear());
    waitForCounterAndClear(1);
    assertEquals(dataModelDesc.getJoinTables().length,
            modelMgrB.getDataModelDesc(dataModelName).getJoinTables().length);

}
 
Example 5
Source File: TableSchemaUpdater.java    From kylin with Apache License 2.0 4 votes vote down vote up
public static DataModelDesc dealWithMappingForModel(DataModelDesc other,
        Map<String, TableSchemaUpdateMapping> mappings) {
    // For filter condition, not support
    if (!Strings.isNullOrEmpty(other.getFilterCondition())) {
        throw new UnsupportedOperationException("Cannot deal with filter condition " + other.getFilterCondition());
    }

    DataModelDesc copy = DataModelDesc.getCopyOf(other);
    copy.setLastModified(other.getLastModified());

    // mapping for root fact table identity
    TableSchemaUpdateMapping rootMapping = getTableSchemaUpdateMapping(mappings, other.getRootFactTableName());
    if (rootMapping != null) {
        TableDesc rootFactTable = other.getRootFactTable().getTableDesc();
        copy.setRootFactTableName(
                rootMapping.getTableIdentity(rootFactTable.getDatabase(), rootFactTable.getName()));
    }

    // mapping for joins
    JoinTableDesc[] joinTables = other.getJoinTables();
    JoinTableDesc[] joinTablesCopy = new JoinTableDesc[joinTables.length];
    for (int i = 0; i < joinTables.length; i++) {
        JoinTableDesc joinTable = joinTables[i];
        joinTablesCopy[i] = JoinTableDesc.getCopyOf(joinTable);
        String tableIdentity = joinTable.getTable();
        TableSchemaUpdateMapping mapping = getTableSchemaUpdateMapping(mappings, tableIdentity);
        if (mapping != null && mapping.isTableIdentityChanged()) {
            joinTablesCopy[i].setTable(mapping.getTableIdentity(tableIdentity));
        }
    }
    copy.setJoinTables(joinTablesCopy);

    // mapping for partition columns
    PartitionDesc partDesc = other.getPartitionDesc();
    PartitionDesc partCopy = PartitionDesc.getCopyOf(partDesc);
    if (partDesc.getPartitionDateColumnRef() != null) {
        partCopy.setPartitionDateColumn(
                replacePartitionCol(partDesc.getPartitionDateColumnRef().getCanonicalName(), mappings));
    }
    if (partDesc.getPartitionTimeColumnRef() != null) {
        partCopy.setPartitionTimeColumn(
                replacePartitionCol(partDesc.getPartitionTimeColumnRef().getCanonicalName(), mappings));
    }
    copy.setPartitionDesc(partCopy);

    return copy;
}
 
Example 6
Source File: CacheServiceTest.java    From Kylin with Apache License 2.0 4 votes vote down vote up
@Test
public void testMetaCRUD() throws Exception {
    final MetadataManager metadataManager = MetadataManager.getInstance(configA);
    final MetadataManager metadataManagerB = MetadataManager.getInstance(configB);
    final Broadcaster broadcaster = Broadcaster.getInstance();
    broadcaster.getCounterAndClear();

    TableDesc tableDesc = createTestTableDesc();
    assertTrue(metadataManager.getTableDesc(tableDesc.getIdentity()) == null);
    assertTrue(metadataManagerB.getTableDesc(tableDesc.getIdentity()) == null);
    metadataManager.saveSourceTable(tableDesc);
    //only one for table insert
    assertEquals(1, broadcaster.getCounterAndClear());
    waitForCounterAndClear(1);
    assertNotNull(metadataManager.getTableDesc(tableDesc.getIdentity()));
    assertNotNull(metadataManagerB.getTableDesc(tableDesc.getIdentity()));




    final String dataModelName = "test_data_model";
    DataModelDesc dataModelDesc = metadataManager.getDataModelDesc("test_kylin_ii_model_desc");
    dataModelDesc.setName(dataModelName);
    dataModelDesc.setLastModified(0);
    assertTrue(metadataManager.getDataModelDesc(dataModelName) == null);
    assertTrue(metadataManagerB.getDataModelDesc(dataModelName) == null);

    dataModelDesc.setName(dataModelName);
    metadataManager.createDataModelDesc(dataModelDesc);
    //only one for data model update
    assertEquals(1, broadcaster.getCounterAndClear());
    waitForCounterAndClear(1);
    assertEquals(dataModelDesc.getName(), metadataManagerB.getDataModelDesc(dataModelName).getName());

    final LookupDesc[] lookups = dataModelDesc.getLookups();
    assertTrue(lookups.length > 0);
    dataModelDesc.setLookups(new LookupDesc[]{lookups[0]});
    metadataManager.updateDataModelDesc(dataModelDesc);
    //only one for data model update
    assertEquals(1, broadcaster.getCounterAndClear());
    waitForCounterAndClear(1);
    assertEquals(dataModelDesc.getLookups().length, metadataManagerB.getDataModelDesc(dataModelName).getLookups().length);

}