westonpace commented on a change in pull request #11441:
URL: https://github.com/apache/arrow/pull/11441#discussion_r735980483



##########
File path: cpp/src/arrow/util/byte_size.cc
##########
@@ -0,0 +1,107 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "arrow/util/byte_size.h"
+
+#include <cstdint>
+#include <unordered_set>
+
+#include "arrow/array.h"
+#include "arrow/buffer.h"
+
+namespace arrow {
+
+namespace util {
+
+namespace {
+
+int64_t DoTotalBufferSize(const ArrayData& array_data,
+                          std::unordered_set<const uint8_t*>* seen_buffers) {
+  int64_t sum = 0;
+  for (const auto& buffer : array_data.buffers) {
+    if (buffer && seen_buffers->insert(buffer->data()).second) {

Review comment:
       That's a fair point.  I'd been so caught up in zero-copy array slicing I 
didn't realize there was zero-copy buffer slicing.  There is a PR up for 
removing duplicate ranges.  It looks like I will need to do that here as well.  
I will add a note at least to the comments for now and then probably solve 
duplicate ranges the same across both methods.




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