diff --git a/be/src/common/status.h b/be/src/common/status.h index f441ccd759..7604d0aa30 100644 --- a/be/src/common/status.h +++ b/be/src/common/status.h @@ -506,12 +506,12 @@ public: // Used like if (res == Status::OK()) // if the state is ok, then both code and precise code is not initialized properly, so that should check ok state // ignore error messages during comparison - bool operator==(const Status& st) { + bool operator==(const Status& st) const { return ok() ? st.ok() : code() == st.code() && precise_code() == st.precise_code(); } // Used like if (res != Status::OK()) - bool operator!=(const Status& st) { + bool operator!=(const Status& st) const { return ok() ? !st.ok() : code() != st.code() || precise_code() != st.precise_code(); } diff --git a/be/src/exec/hash_table.h b/be/src/exec/hash_table.h index 15cd9c67f9..74b412d0e7 100644 --- a/be/src/exec/hash_table.h +++ b/be/src/exec/hash_table.h @@ -152,7 +152,7 @@ public: int64_t size() const { return _num_nodes; } // Returns the number of buckets - int64_t num_buckets() { return _buckets.size(); } + int64_t num_buckets() const { return _buckets.size(); } // Returns the number of filled buckets int64_t num_filled_buckets() const { return _num_filled_buckets; } @@ -286,11 +286,11 @@ public: return _node->matched; } - bool operator==(const Iterator& rhs) { + bool operator==(const Iterator& rhs) const { return _bucket_idx == rhs._bucket_idx && _node == rhs._node; } - bool operator!=(const Iterator& rhs) { + bool operator!=(const Iterator& rhs) const { return _bucket_idx != rhs._bucket_idx || _node != rhs._node; } diff --git a/be/src/gutil/stl_util.h b/be/src/gutil/stl_util.h index 6ef7ea3ce5..b2bc50a2da 100644 --- a/be/src/gutil/stl_util.h +++ b/be/src/gutil/stl_util.h @@ -433,9 +433,9 @@ private: template class TemplatedElementDeleter : public BaseDeleter { public: - explicit TemplatedElementDeleter(STLContainer* ptr) : container_ptr_(ptr) {} + explicit TemplatedElementDeleter(STLContainer* ptr) : container_ptr_(ptr) {} - virtual ~TemplatedElementDeleter() { STLDeleteElements(container_ptr_); } + virtual ~TemplatedElementDeleter() { STLDeleteElements(container_ptr_); } private: STLContainer* container_ptr_; @@ -466,9 +466,9 @@ private: template class TemplatedValueDeleter : public BaseDeleter { public: - explicit TemplatedValueDeleter(STLContainer* ptr) : container_ptr_(ptr) {} + explicit TemplatedValueDeleter(STLContainer* ptr) : container_ptr_(ptr) {} - virtual ~TemplatedValueDeleter() { STLDeleteValues(container_ptr_); } + virtual ~TemplatedValueDeleter() { STLDeleteValues(container_ptr_); } private: STLContainer* container_ptr_; @@ -502,8 +502,8 @@ private: template class STLElementDeleter { public: - STLElementDeleter(STLContainer* ptr) : container_ptr_(ptr) {} - ~STLElementDeleter() { STLDeleteElements(container_ptr_); } + STLElementDeleter(STLContainer* ptr) : container_ptr_(ptr) {} + ~STLElementDeleter() { STLDeleteElements(container_ptr_); } private: STLContainer* container_ptr_; @@ -512,8 +512,8 @@ private: template class STLValueDeleter { public: - STLValueDeleter(STLContainer* ptr) : container_ptr_(ptr) {} - ~STLValueDeleter() { STLDeleteValues(container_ptr_); } + STLValueDeleter(STLContainer* ptr) : container_ptr_(ptr) {} + ~STLValueDeleter() { STLDeleteValues(container_ptr_); } private: STLContainer* container_ptr_; @@ -763,49 +763,6 @@ BinaryComposeBinary BinaryCompose2(F f, G1 g1, G2 g2) { return BinaryComposeBinary(f, g1, g2); } -// This is a wrapper for an STL allocator which keeps a count of the -// active bytes allocated by this class of allocators. This is NOT -// THREAD SAFE. This should only be used in situations where you can -// ensure that only a single thread performs allocation and -// deallocation. -template > -class STLCountingAllocator : public Alloc { -public: - typedef typename Alloc::pointer pointer; - typedef typename Alloc::size_type size_type; - - STLCountingAllocator() : bytes_used_(NULL) {} - STLCountingAllocator(int64* b) : bytes_used_(b) {} // TODO(user): explicit? - - // Constructor used for rebinding - template - STLCountingAllocator(const STLCountingAllocator& x) - : Alloc(x), bytes_used_(x.bytes_used()) {} - - pointer allocate(size_type n, std::allocator::const_pointer hint = 0) { - assert(bytes_used_ != NULL); - *bytes_used_ += n * sizeof(T); - return Alloc::allocate(n, hint); - } - - void deallocate(pointer p, size_type n) { - Alloc::deallocate(p, n); - assert(bytes_used_ != NULL); - *bytes_used_ -= n * sizeof(T); - } - - // Rebind allows an allocator to be used for a different type - template - struct rebind { - typedef STLCountingAllocator::other> other; - }; - - int64* bytes_used() const { return bytes_used_; } - -private: - int64* bytes_used_; -}; - // Even though a struct has no data members, it cannot have zero size // according to the standard. However, "empty base-class // optimization" allows an empty parent class to add no additional diff --git a/be/src/runtime/exec_env_init.cpp b/be/src/runtime/exec_env_init.cpp index 8281375331..b574fd75b1 100644 --- a/be/src/runtime/exec_env_init.cpp +++ b/be/src/runtime/exec_env_init.cpp @@ -362,6 +362,7 @@ void ExecEnv::_destroy() { SAFE_DELETE(_query_pool_mem_tracker); SAFE_DELETE(_load_pool_mem_tracker); SAFE_DELETE(_task_pool_mem_tracker_registry); + SAFE_DELETE(_buffer_reservation); DEREGISTER_HOOK_METRIC(query_mem_consumption); DEREGISTER_HOOK_METRIC(load_mem_consumption); diff --git a/be/src/util/bitmap_value.h b/be/src/util/bitmap_value.h index 7eaeb11e79..fe2aa3a613 100644 --- a/be/src/util/bitmap_value.h +++ b/be/src/util/bitmap_value.h @@ -1032,13 +1032,13 @@ public: return false; } - bool operator==(const Roaring64MapSetBitForwardIterator& o) { + bool operator==(const Roaring64MapSetBitForwardIterator& o) const { if (map_iter == map_end && o.map_iter == o.map_end) return true; if (o.map_iter == o.map_end) return false; return **this == *o; } - bool operator!=(const Roaring64MapSetBitForwardIterator& o) { + bool operator!=(const Roaring64MapSetBitForwardIterator& o) const { if (map_iter == map_end && o.map_iter == o.map_end) return false; if (o.map_iter == o.map_end) return true; return **this != *o; diff --git a/be/test/util/metrics_test.cpp b/be/test/util/metrics_test.cpp index 68470c84fb..e71801e9bd 100644 --- a/be/test/util/metrics_test.cpp +++ b/be/test/util/metrics_test.cpp @@ -85,9 +85,8 @@ void mt_updater(int32_t loop, T* counter, std::atomic* used_time) { TEST_F(MetricsTest, CounterPerf) { static const int kLoopCount = LOOP_LESS_OR_MORE(10, 100000000); static const int kThreadLoopCount = LOOP_LESS_OR_MORE(1000, 1000000); - // volatile int64_t { - volatile int64_t sum = 0; + int64_t sum = 0; MonotonicStopWatch watch; watch.start(); for (int i = 0; i < kLoopCount; ++i) {