Skip to content

Commit

Permalink
Add table series number in schema quota
Browse files Browse the repository at this point in the history
  • Loading branch information
JackieTien97 authored Nov 30, 2024
1 parent 1e93245 commit 2f51c3b
Showing 1 changed file with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,31 +388,28 @@ public Map<Integer, Long> countTimeSeriesNumBySchemaRegion(final List<Integer> s
&& SchemaRegionConsensusImpl.getInstance().isLeader(entry.getKey()))
.forEach(
entry ->
timeSeriesNum.put(
entry.getKey().getId(),
entry.getValue().getSchemaRegionStatistics().getSeriesNumber(false)
+ entry
.getValue()
.getSchemaRegionStatistics()
.getTable2DevicesNumMap()
.entrySet()
.stream()
.map(
tableEntry -> {
final TsTable table =
DataNodeTableCache.getInstance()
.getTable(
PathUtils.unQualifyDatabaseName(
entry.getValue().getDatabaseFullPath()),
tableEntry.getKey());
return Objects.nonNull(table)
? table.getMeasurementNum() * tableEntry.getValue()
: 0;
})
.reduce(0L, Long::sum)));
timeSeriesNum.put(entry.getKey().getId(), getTimeSeriesNumber(entry.getValue())));
return timeSeriesNum;
}

// not including view number
private long getTimeSeriesNumber(ISchemaRegion schemaRegion) {
return schemaRegion.getSchemaRegionStatistics().getSeriesNumber(false)
+ schemaRegion.getSchemaRegionStatistics().getTable2DevicesNumMap().entrySet().stream()
.map(
tableEntry -> {
final TsTable table =
DataNodeTableCache.getInstance()
.getTable(
PathUtils.unQualifyDatabaseName(schemaRegion.getDatabaseFullPath()),
tableEntry.getKey());
return Objects.nonNull(table)
? table.getMeasurementNum() * tableEntry.getValue()
: 0;
})
.reduce(0L, Long::sum);
}

/**
* Update total count in schema quota manager and generate local count map response. If limit is
* not -1 and deviceNumMap/timeSeriesNumMap is null, fill deviceNumMap/timeSeriesNumMap of the
Expand Down Expand Up @@ -459,9 +456,7 @@ public void updateAndFillSchemaCountMap(TDataNodeHeartbeatReq req, TDataNodeHear
tmp.put(
consensusGroupId.getId(),
Optional.ofNullable(schemaRegionMap.get(consensusGroupId))
.map(
schemaRegion ->
schemaRegion.getSchemaRegionStatistics().getSeriesNumber(false))
.map(this::getTimeSeriesNumber)
.orElse(0L)));
}
}
Expand Down

0 comments on commit 2f51c3b

Please sign in to comment.