Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public void test1() {
Map<String, Long> tableSizes = new HashMap<>();
while (iterator.next()) {
String table = iterator.getString("table_name");
Assert.assertEquals("BASE TABLE", iterator.getString("table_type"));
long timePartition = iterator.getLong("time_partition");
long size = iterator.getLong("size_in_bytes");
timePartitionSizes.compute(timePartition, (k, v) -> v == null ? size : v + size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ public void testInformationSchema() throws SQLException {
Arrays.asList(
"database,STRING,FIELD,",
"table_name,STRING,FIELD,",
"table_type,STRING,FIELD,",
"datanode_id,INT32,FIELD,",
"region_id,INT32,FIELD,",
"time_partition,INT64,FIELD,",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@

private InformationSchemaContentSupplierFactory() {}

public static IInformationSchemaContentSupplier getSupplier(

Check warning on line 167 in iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/InformationSchemaContentSupplierFactory.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

A "Brain Method" was detected. Refactor it to reduce at least one of the following metrics: LOC from 78 to 64, Complexity from 25 to 14, Nesting Level from 4 to 2, Number of Variables from 9 to 6.

See more on https://sonarcloud.io/project/issues?id=apache_iotdb&issues=AZ5iiDxtb9sO6VmIdbUe&open=AZ5iiDxtb9sO6VmIdbUe&pullRequest=17768
final OperatorContext context,
final List<TSDataType> dataTypes,
final UserEntity userEntity,
Expand Down Expand Up @@ -1420,12 +1420,13 @@
}
totalValidTableCount++;
if (pushDownFilter != null) {
Object[] row = new Object[5];
Object[] row = new Object[6];
row[0] = new Binary(dataRegion.getDatabaseName(), TSFileConfig.STRING_CHARSET);
row[1] = new Binary(tTableInfo.getTableName(), TSFileConfig.STRING_CHARSET);
row[2] = IoTDBDescriptor.getInstance().getConfig().getDataNodeId();
row[3] = dataRegion.getDataRegionId();
row[4] = timePartition;
row[2] = new Binary(getTableTypeName(tTableInfo), TSFileConfig.STRING_CHARSET);
row[3] = IoTDBDescriptor.getInstance().getConfig().getDataNodeId();
row[4] = dataRegion.getDataRegionId();
row[5] = timePartition;
if (!pushDownFilter.satisfyRow(0, row)) {
continue;
}
Expand All @@ -1444,6 +1445,25 @@
return tablesToScan;
}

private String getTableTypeName(final TTableInfo tableInfo) {
if (tableInfo.isSetType()) {
return TableType.values()[tableInfo.getType()].getName();
}
return TableType.BASE_TABLE.getName();
}

private String getTableTypeName(final String databaseName, final String tableName) {
final List<TTableInfo> tableInfos = databaseTableInfoMap.get(databaseName);
if (tableInfos != null) {
for (TTableInfo tableInfo : tableInfos) {
if (tableName.equals(tableInfo.getTableName())) {
return getTableTypeName(tableInfo);
}
}
}
return TableType.BASE_TABLE.getName();
}

@Override
public TsBlock next() {
if (!hasNext()) {
Expand Down Expand Up @@ -1531,10 +1551,14 @@
columns[0].writeBinary(
new Binary(currentDataRegion.getDatabaseName(), TSFileConfig.STRING_CHARSET));
columns[1].writeBinary(new Binary(tableName, TSFileConfig.STRING_CHARSET));
columns[2].writeInt(IoTDBDescriptor.getInstance().getConfig().getDataNodeId());
columns[3].writeInt(currentDataRegion.getDataRegionId());
columns[4].writeLong(timePartition);
columns[5].writeLong(size);
columns[2].writeBinary(
new Binary(
getTableTypeName(currentDataRegion.getDatabaseName(), tableName),
TSFileConfig.STRING_CHARSET));
columns[3].writeInt(IoTDBDescriptor.getInstance().getConfig().getDataNodeId());
columns[4].writeInt(currentDataRegion.getDataRegionId());
columns[5].writeLong(timePartition);
columns[6].writeLong(size);
builder.declarePosition();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ public class InformationSchema {
ColumnHeaderConstant.DATABASE.toLowerCase(Locale.ENGLISH), TSDataType.STRING));
tableDiskUsageTable.addColumnSchema(
new FieldColumnSchema(ColumnHeaderConstant.TABLE_NAME_TABLE_MODEL, TSDataType.STRING));
tableDiskUsageTable.addColumnSchema(
new FieldColumnSchema(ColumnHeaderConstant.TABLE_TYPE_TABLE_MODEL, TSDataType.STRING));
tableDiskUsageTable.addColumnSchema(
new FieldColumnSchema(ColumnHeaderConstant.DATA_NODE_ID_TABLE_MODEL, TSDataType.INT32));
tableDiskUsageTable.addColumnSchema(
Expand Down Expand Up @@ -430,6 +432,7 @@ public class InformationSchema {
ImmutableSet.of(
ColumnHeaderConstant.DATABASE.toLowerCase(),
ColumnHeaderConstant.TABLE_NAME_TABLE_MODEL,
ColumnHeaderConstant.TABLE_TYPE_TABLE_MODEL,
ColumnHeaderConstant.DATA_NODE_ID_TABLE_MODEL,
ColumnHeaderConstant.REGION_ID_TABLE_MODEL,
ColumnHeaderConstant.TIME_PARTITION_TABLE_MODEL));
Expand Down
Loading