This is an automated email from the ASF dual-hosted git repository.

joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 4cc1b4ad04cd5770a41961269d69a65cdfac1dcf
Author: Joe McDonnell <joemcdonn...@cloudera.com>
AuthorDate: Wed May 27 15:05:04 2020 -0700

    IMPALA-9415: Switch result set size calculations from capacity() to size()
    
    The behavior of string's capacity() is implementation specific.
    In GCC 7.5.0, the implementation has different behavior compared
    to GCC 4.9.2. This is causing a DCHECK to fire in
    ClientRequestState::FetchRowsInternal():
    
    // Confirm that this was not an underestimate of the memory required.
    DCHECK_GE(before + delta_bytes, after)
    
    What happens on GCC 7.5.0 is that the capacity of the string before the
    copy is 29, but after the copy to the result set, the capacity is 30.
    The size remains unchanged.
    
    This switches the code to use size(), which is guaranteed to be
    consistent across copies. This loses some accuracy, because there is some
    string object overhead and excess capacity that no longer counts. However,
    this is not code that requires perfect accuracy.
    
    Testing:
     - Ran core tests with GCC 4.9.2 and GCC 7.5.0
    
    Change-Id: I3f9ab260927e14d8951b7c7661f2b5b18a1da39a
    Reviewed-on: http://gerrit.cloudera.org:8080/15992
    Reviewed-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
    Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
---
 be/src/service/query-result-set.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/be/src/service/query-result-set.cc 
b/be/src/service/query-result-set.cc
index 5445ec7..f2d5b8e 100644
--- a/be/src/service/query-result-set.cc
+++ b/be/src/service/query-result-set.cc
@@ -226,7 +226,7 @@ int64_t AsciiQueryResultSet::ByteSize(int start_idx, int 
num_rows) {
   int64_t bytes = 0;
   const int end = min(static_cast<size_t>(num_rows), result_set_->size() - 
start_idx);
   for (int i = start_idx; i < start_idx + end; ++i) {
-    bytes += sizeof(result_set_[i]) + result_set_[i].capacity();
+    bytes += sizeof(result_set_[i]) + result_set_[i].size();
   }
   return bytes;
 }
@@ -237,7 +237,7 @@ namespace {
 
 // Utility functions for computing the size of HS2 Thrift structs in bytes.
 inline int64_t ByteSize(const ThriftTColumnValue& val) {
-  return sizeof(val) + val.stringVal.value.capacity();
+  return sizeof(val) + val.stringVal.value.size();
 }
 
 int64_t ByteSize(const TRow& row) {

Reply via email to