Copilot commented on code in PR #15540:
URL: https://github.com/apache/iotdb/pull/15540#discussion_r2097205679


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryWeightUtil.java:
##########
@@ -110,9 +110,10 @@ public static Pair<Integer, Integer> 
calculateTabletRowCountAndMemory(RowRecord
 
         if (tsDataType.isBinary()) {
           final Binary binary = field.getBinaryV();
-          totalSizeInBytes += binary == null ? 0 : binary.getLength();
+          totalSizeInBytes += binary == null ? 8 : binary.ramBytesUsed();

Review Comment:
   The literal `8` here acts as a default overhead but isn’t self-documenting. 
Extract it to a named constant (e.g., `BINARY_DEFAULT_OVERHEAD_BYTES`) to 
clarify its purpose and avoid magic numbers.
   ```suggestion
             totalSizeInBytes += binary == null ? BINARY_DEFAULT_OVERHEAD_BYTES 
: binary.ramBytesUsed();
   ```



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryWeightUtil.java:
##########
@@ -110,9 +110,10 @@ public static Pair<Integer, Integer> 
calculateTabletRowCountAndMemory(RowRecord
 
         if (tsDataType.isBinary()) {
           final Binary binary = field.getBinaryV();
-          totalSizeInBytes += binary == null ? 0 : binary.getLength();
+          totalSizeInBytes += binary == null ? 8 : binary.ramBytesUsed();
         } else {
-          totalSizeInBytes += tsDataType.getDataTypeSize();
+          totalSizeInBytes +=
+              
roundUpToMultiple(TsPrimitiveType.getByType(tsDataType).getSize() + 8, 8);

Review Comment:
   Both the added `8` bytes of overhead and the alignment factor `8` are magic 
numbers. Consider defining constants like `PRIMITIVE_OVERHEAD_BYTES` and 
`ALIGNMENT_BOUNDARY` for clarity.



-- 
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]

Reply via email to