You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by hb...@apache.org on 2016/10/21 21:20:14 UTC
incubator-quickstep git commit: Remember handle count in
FastSeparateChainingHashTable
Repository: incubator-quickstep
Updated Branches:
refs/heads/fix-emptypayload-fastsephashtable [created] 9c32ea45c
Remember handle count in FastSeparateChainingHashTable
- Using handles_ vector directly in FastSeparateChainingHashTable can
cause problems. One example is a distinctify hash table which doesn't
accept any payload. In this case, the reference to handles_ vector
becomes garbage after the constructor gets executed. Therefore to
avoid faults about accessing an invalid reference, we use the number
of handles as a guarding mechanism.
Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/9c32ea45
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/9c32ea45
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/9c32ea45
Branch: refs/heads/fix-emptypayload-fastsephashtable
Commit: 9c32ea45c5971568fae3d611a0fc9d963d7501bf
Parents: 8746eed
Author: Harshad Deshmukh <hb...@apache.org>
Authored: Fri Oct 21 16:15:53 2016 -0500
Committer: Harshad Deshmukh <hb...@apache.org>
Committed: Fri Oct 21 16:15:53 2016 -0500
----------------------------------------------------------------------
storage/FastSeparateChainingHashTable.hpp | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9c32ea45/storage/FastSeparateChainingHashTable.hpp
----------------------------------------------------------------------
diff --git a/storage/FastSeparateChainingHashTable.hpp b/storage/FastSeparateChainingHashTable.hpp
index 231da7e..2435d45 100644
--- a/storage/FastSeparateChainingHashTable.hpp
+++ b/storage/FastSeparateChainingHashTable.hpp
@@ -145,10 +145,10 @@ class FastSeparateChainingHashTable
header_->buckets_allocated.load(std::memory_order_relaxed);
void *bucket_ptr = static_cast<char *>(buckets_) + kValueOffset;
for (std::size_t bucket_num = 0; bucket_num < num_buckets; ++bucket_num) {
- for (std::size_t handle_num = 0; handle_num < handles_.size(); ++handle_num) {
+ for (std::size_t handle_id = 0; handle_id < num_handles_; ++handle_id) {
void *value_internal_ptr =
- static_cast<char *>(bucket_ptr) + this->payload_offsets_[handle_num];
- handles_[handle_num]->destroyPayload(static_cast<std::uint8_t *>(value_internal_ptr));
+ static_cast<char *>(bucket_ptr) + this->payload_offsets_[handle_id];
+ handles_[handle_id]->destroyPayload(static_cast<std::uint8_t *>(value_internal_ptr));
}
bucket_ptr = static_cast<char *>(bucket_ptr) + bucket_size_;
}
@@ -223,6 +223,7 @@ class FastSeparateChainingHashTable
bool isFull(const std::size_t extra_variable_storage) const;
const std::vector<AggregationHandle *> &handles_;
+ const std::size_t num_handles_;
// Helper object to manage key storage.
HashTableKeyManager<serializable, force_key_copy> key_manager_;
@@ -292,6 +293,7 @@ FastSeparateChainingHashTable<resizable,
kBucketAlignment(alignof(std::atomic<std::size_t>)),
kValueOffset(sizeof(std::atomic<std::size_t>) + sizeof(std::size_t)),
handles_(handles),
+ num_handles_(handles.size()),
key_manager_(this->key_types_, kValueOffset + this->total_payload_size_),
bucket_size_(ComputeBucketSize(key_manager_.getFixedKeySize())) {
init_payload_ =