Java Code Examples for org.apache.kylin.metadata.model.TableDesc#init()
The following examples show how to use
org.apache.kylin.metadata.model.TableDesc#init() .
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: CubeMetadataUpgrade.java From Kylin with Apache License 2.0 | 6 votes |
private void upgradeTableDesc() { List<String> paths = listResourceStore(ResourceStore.TABLE_RESOURCE_ROOT); for (String path : paths) { TableDesc t; try { t = store.getResource(path, TableDesc.class, MetadataManager.TABLE_SERIALIZER); t.init(); // if it only has 1 "." in the path, delete the old resource if it exists if (path.substring(path.indexOf(".")).length() == MetadataConstants.FILE_SURFIX.length()) { getStore().deleteResource(path); // the new source will be new; t.setLastModified(0); getStore().putResource(t.getResourcePath(), t, MetadataManager.TABLE_SERIALIZER); updatedResources.add(t.getResourcePath()); } } catch (IOException e) { e.printStackTrace(); errorMsgs.add("Upgrade TableDesc at '" + path + "' failed: " + e.getLocalizedMessage()); } } }
Example 2
Source File: KylinTableCreator.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
public static TableDesc generateKylinTable(KylinConfig kylinConfig, MetricsSinkDesc sinkDesc, String subject, List<Pair<String, String>> columns) { TableDesc kylinTable = new TableDesc(); Pair<String, String> tableNameSplits = ActiveReservoirReporter .getTableNameSplits(sinkDesc.getTableNameForMetrics(subject)); kylinTable.setUuid(RandomUtil.randomUUID().toString()); kylinTable.setDatabase(tableNameSplits.getFirst()); kylinTable.setName(tableNameSplits.getSecond()); kylinTable.setTableType(null); kylinTable.setLastModified(0L); kylinTable.setSourceType(sinkDesc.getSourceType()); ColumnDesc[] columnDescs = new ColumnDesc[columns.size()]; for (int i = 0; i < columns.size(); i++) { columnDescs[i] = new ColumnDesc(); Pair<String, String> entry = columns.get(i); columnDescs[i].setId(Integer.toString(i + 1)); columnDescs[i].setName(entry.getFirst()); columnDescs[i].setDatatype(entry.getSecond()); } kylinTable.setColumns(columnDescs); kylinTable.init(kylinConfig, MetricsManager.SYSTEM_PROJECT); return kylinTable; }
Example 3
Source File: SnapshotManagerTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
private TableDesc genTableDesc(String tableName) { TableDesc table = TableDesc.mockup(tableName); ColumnDesc desc1 = new ColumnDesc("1", "id", "string", null, null, null, null); desc1.setId("1"); desc1.setDatatype("long"); ColumnDesc desc2 = new ColumnDesc("2", "country", "string", null, null, null, null); desc2.setId("2"); desc2.setDatatype("string"); ColumnDesc[] columns = { desc1, desc2 }; table.setColumns(columns); table.init(kylinConfig, "default"); return table; }
Example 4
Source File: KylinTableCreator.java From kylin with Apache License 2.0 | 5 votes |
public static TableDesc generateKylinTable(KylinConfig kylinConfig, MetricsSinkDesc sinkDesc, String subject, List<Pair<String, String>> columns) { TableDesc kylinTable = new TableDesc(); Pair<String, String> tableNameSplits = ActiveReservoirReporter .getTableNameSplits(sinkDesc.getTableNameForMetrics(subject)); kylinTable.setUuid(RandomUtil.randomUUID().toString()); kylinTable.setDatabase(tableNameSplits.getFirst()); kylinTable.setName(tableNameSplits.getSecond()); kylinTable.setTableType(null); kylinTable.setLastModified(0L); kylinTable.setSourceType(sinkDesc.getSourceType()); ColumnDesc[] columnDescs = new ColumnDesc[columns.size()]; for (int i = 0; i < columns.size(); i++) { columnDescs[i] = new ColumnDesc(); Pair<String, String> entry = columns.get(i); columnDescs[i].setId(Integer.toString(i + 1)); columnDescs[i].setName(entry.getFirst()); columnDescs[i].setDatatype(entry.getSecond()); } kylinTable.setColumns(columnDescs); kylinTable.init(kylinConfig, MetricsManager.SYSTEM_PROJECT); return kylinTable; }
Example 5
Source File: SnapshotManagerTest.java From kylin with Apache License 2.0 | 5 votes |
private TableDesc genTableDesc(String tableName) { TableDesc table = TableDesc.mockup(tableName); ColumnDesc desc1 = new ColumnDesc("1", "id", "string", null, null, null, null); desc1.setId("1"); desc1.setDatatype("long"); ColumnDesc desc2 = new ColumnDesc("2", "country", "string", null, null, null, null); desc2.setId("2"); desc2.setDatatype("string"); ColumnDesc[] columns = { desc1, desc2 }; table.setColumns(columns); table.init(kylinConfig, "default"); return table; }
Example 6
Source File: MetadataManager.java From Kylin with Apache License 2.0 | 5 votes |
public void saveSourceTable(TableDesc srcTable) throws IOException { if (srcTable.getUuid() == null || srcTable.getIdentity() == null) { throw new IllegalArgumentException(); } srcTable.init(); String path = srcTable.getResourcePath(); getStore().putResource(path, srcTable, TABLE_SERIALIZER); srcTableMap.put(srcTable.getIdentity(), srcTable); }
Example 7
Source File: MetadataManager.java From Kylin with Apache License 2.0 | 5 votes |
private TableDesc reloadSourceTableAt(String path) throws IOException { ResourceStore store = getStore(); TableDesc t = store.getResource(path, TableDesc.class, TABLE_SERIALIZER); if (t == null) { logger.error("Didn't load table at " + path); return null; } t.init(); String tableIdentity = t.getIdentity(); srcTableMap.putLocal(tableIdentity, t); return t; }
Example 8
Source File: TableMetadataManager.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
public void saveSourceTable(TableDesc srcTable, String prj) throws IOException { try (AutoLock lock = srcTableMapLock.lockForWrite()) { srcTable.init(config, prj); srcTableCrud.save(srcTable); } }
Example 9
Source File: TableMetadataManager.java From kylin with Apache License 2.0 | 4 votes |
public void saveSourceTable(TableDesc srcTable, String prj) throws IOException { try (AutoLock lock = srcTableMapLock.lockForWrite()) { srcTable.init(config, prj); srcTableCrud.save(srcTable); } }