lucasfang commented on code in PR #395:
URL: https://github.com/apache/paimon-cpp/pull/395#discussion_r4128752826


##########
src/paimon/format/blob/blob_file_batch_reader.cpp:
##########
@@ -90,6 +91,141 @@ Result<int32_t> GetMapBlobFixedKeyLength(const 
std::shared_ptr<arrow::DataType>&
     }
 }
 
+Status AddBuilderCapacity(int64_t increment, int64_t* capacity, const char* 
capacity_name) {
+    if (increment < 0 || increment > std::numeric_limits<int64_t>::max() - 
*capacity) {
+        return Status::CapacityError(fmt::format("{} exceeds int64 capacity", 
capacity_name));
+    }
+    *capacity += increment;
+    return Status::OK();
+}
+
+Status AddBuilderCapacityProduct(int64_t count, int64_t element_size, int64_t* 
capacity,
+                                 const char* capacity_name) {
+    if (count < 0 || element_size < 0 ||
+        (count > 0 && element_size > (std::numeric_limits<int64_t>::max() - 
*capacity) / count)) {
+        return Status::CapacityError(fmt::format("{} exceeds int64 capacity", 
capacity_name));
+    }
+    *capacity += count * element_size;
+    return Status::OK();
+}
+
+Result<int64_t> GetSerializedDescriptorSize(const std::string& file_path,

Review Comment:
   GetSerializedDescriptorSize is recomputed per batch: the serialized length 
depends only on file_path_ (all fixed-width fields), so the estimate is exact 
and ReserveData never under-allocates — well done. But it could be computed 
once in Create and cached as a member.



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