diff --git a/iotdb-2.0/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb200/ModelStrategy/TableStrategy.java b/iotdb-2.0/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb200/ModelStrategy/TableStrategy.java index 3b542c2a4..a29f7abbf 100644 --- a/iotdb-2.0/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb200/ModelStrategy/TableStrategy.java +++ b/iotdb-2.0/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb200/ModelStrategy/TableStrategy.java @@ -96,11 +96,14 @@ public void registerDatabases(Session metaSession, List schema private void registerTable(Session metaSession, List timeseriesSchemas) throws TsdbException { try { + // get all tables + Set tableNames = getAllTables(timeseriesSchemas); + // register tables + DeviceSchema deviceSchema = timeseriesSchemas.get(0).getDeviceSchema(); HashMap> tables = new HashMap<>(); - for (TimeseriesSchema timeseriesSchema : timeseriesSchemas) { - DeviceSchema deviceSchema = timeseriesSchema.getDeviceSchema(); + for (String tableName : tableNames) { StringBuilder builder = new StringBuilder(); - builder.append("create table if not exists ").append(deviceSchema.getTable()).append("("); + builder.append("create table if not exists ").append(tableName).append("("); for (int i = 0; i < deviceSchema.getSensors().size(); i++) { if (i != 0) builder.append(", "); builder @@ -143,6 +146,15 @@ private void registerTable(Session metaSession, List timeserie } } + public Set getAllTables(List schemaList) { + Set tableNames = new HashSet<>(); + for (TimeseriesSchema timeseriesSchema : schemaList) { + DeviceSchema schema = timeseriesSchema.getDeviceSchema(); + tableNames.add(schema.getTable()); + } + return tableNames; + } + // region select @Override