Caideyipi commented on code in PR #18029:
URL: https://github.com/apache/iotdb/pull/18029#discussion_r3472954764
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/tag/TagManager.java:
##########
@@ -166,34 +165,33 @@ public void addIndex(String tagKey, String tagValue,
IMeasurementMNode<?> measur
return;
}
- int tagIndexOldSize = tagIndex.size();
- Map<String, Set<IMeasurementMNode<?>>> tagValueMap =
- tagIndex.computeIfAbsent(tagKey, k -> new ConcurrentHashMap<>());
- int tagIndexNewSize = tagIndex.size();
-
- int tagValueMapOldSize = tagValueMap.size();
- Set<IMeasurementMNode<?>> measurementsSet =
- tagValueMap.computeIfAbsent(tagValue, v ->
Collections.synchronizedSet(new HashSet<>()));
- int tagValueMapNewSize = tagValueMap.size();
+ tagIndex.compute(
+ tagKey,
+ (key, tagValueMap) -> {
+ long memorySize = 0;
+ if (tagValueMap == null) {
+ tagValueMap = new ConcurrentHashMap<>();
+ // the last 4 is the memory occupied by the size of tagvaluemap
+ memorySize += RamUsageEstimator.sizeOf(tagKey) + 4;
Review Comment:
Followed up in 28a97160245: renamed the constant to
INDEX_ENTRY_OVERHEAD_ESTIMATE_BYTES and added a comment clarifying that it is
an int-sized accounting estimate for each indexed key/value/measurement
reference, not a specific ConcurrentHashMap or Set field.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]