Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7DA05200B84 for ; Tue, 20 Sep 2016 19:56:44 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7C551160AC0; Tue, 20 Sep 2016 17:56:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 78F9C160AC5 for ; Tue, 20 Sep 2016 19:56:43 +0200 (CEST) Received: (qmail 42151 invoked by uid 500); 20 Sep 2016 17:56:42 -0000 Mailing-List: contact commits-help@quickstep.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@quickstep.incubator.apache.org Delivered-To: mailing list commits@quickstep.incubator.apache.org Received: (qmail 42142 invoked by uid 99); 20 Sep 2016 17:56:42 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2016 17:56:42 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 4644BC1810 for ; Tue, 20 Sep 2016 17:56:42 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -5.446 X-Spam-Level: X-Spam-Status: No, score=-5.446 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id Pq-GU2ww-Hzo for ; Tue, 20 Sep 2016 17:56:40 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id 3B2285FC3C for ; Tue, 20 Sep 2016 17:56:39 +0000 (UTC) Received: (qmail 41949 invoked by uid 99); 20 Sep 2016 17:56:39 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2016 17:56:39 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 42649E7E18; Tue, 20 Sep 2016 17:56:39 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hbdeshmukh@apache.org To: commits@quickstep.incubator.apache.org Date: Tue, 20 Sep 2016 17:56:45 -0000 Message-Id: <00a7d71663584c839d0484a3765eb6cc@git.apache.org> In-Reply-To: <2447dffeae714bc48ad28d886cc9feea@git.apache.org> References: <2447dffeae714bc48ad28d886cc9feea@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [07/20] incubator-quickstep git commit: Removed some dead code and made minor updates. archived-at: Tue, 20 Sep 2016 17:56:44 -0000 http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3606000b/storage/FastSeparateChainingHashTable.hpp ---------------------------------------------------------------------- diff --git a/storage/FastSeparateChainingHashTable.hpp b/storage/FastSeparateChainingHashTable.hpp index 49cea5b..0670993 100644 --- a/storage/FastSeparateChainingHashTable.hpp +++ b/storage/FastSeparateChainingHashTable.hpp @@ -120,25 +120,15 @@ class FastSeparateChainingHashTable : public FastHashTable &key, - const std::size_t variable_key_size, - const uint8_t &value, - HashTablePreallocationState *prealloc_state) override; + HashTablePutResult putCompositeKeyInternalFast(const std::vector &key, const std::size_t variable_key_size, const std::uint8_t *init_value_ptr, HashTablePreallocationState *prealloc_state) override; - uint8_t* upsertInternal(const TypedValue &key, - const std::size_t variable_key_size, - const uint8_t &initial_value) override; uint8_t* upsertInternalFast(const TypedValue &key, - const std::uint8_t *init_value_ptr, - const std::size_t variable_key_size) override; - - uint8_t* upsertCompositeKeyInternal(const std::vector &key, - const std::size_t variable_key_size, - const uint8_t &initial_value) override; + const std::size_t variable_key_size, + const std::uint8_t *init_value_ptr) override; uint8_t* upsertCompositeKeyInternalFast(const std::vector &key, const std::uint8_t *init_value_ptr, @@ -788,76 +778,6 @@ template HashTablePutResult FastSeparateChainingHashTable - ::putCompositeKeyInternal(const std::vector &key, - const std::size_t variable_key_size, - const uint8_t &value, - HashTablePreallocationState *prealloc_state) { - DEBUG_ASSERT(this->key_types_.size() == key.size()); - - if (prealloc_state == nullptr) { - // Early check for a free bucket. - if (header_->buckets_allocated.load(std::memory_order_relaxed) >= header_->num_buckets) { - return HashTablePutResult::kOutOfSpace; - } - - // TODO(chasseur): If allow_duplicate_keys is true, avoid storing more than - // one copy of the same variable-length key. - if (!key_manager_.allocateVariableLengthKeyStorage(variable_key_size)) { - // Ran out of variable-length key storage space. - return HashTablePutResult::kOutOfSpace; - } - } - - const std::size_t hash_code = this->hashCompositeKey(key); - void *bucket = nullptr; - std::atomic *pending_chain_ptr; - std::size_t pending_chain_ptr_finish_value; - for (;;) { - if (locateBucketForInsertion(hash_code, - 0, - &bucket, - &pending_chain_ptr, - &pending_chain_ptr_finish_value, - prealloc_state)) { - // Found an empty bucket. - break; - } else if (bucket == nullptr) { - // Ran out of buckets. Deallocate any variable space that we were unable - // to use. - DEBUG_ASSERT(prealloc_state == nullptr); - key_manager_.deallocateVariableLengthKeyStorage(variable_key_size); - return HashTablePutResult::kOutOfSpace; - } else { - // Hash collision found, and duplicates aren't allowed. - DEBUG_ASSERT(!allow_duplicate_keys); - DEBUG_ASSERT(prealloc_state == nullptr); - if (key_manager_.compositeKeyCollisionCheck(key, bucket)) { - // Duplicate key. Deallocate any variable storage space and return. - key_manager_.deallocateVariableLengthKeyStorage(variable_key_size); - return HashTablePutResult::kDuplicateKey; - } - } - } - - // Write the key and hash. - writeCompositeKeyToBucket(key, hash_code, bucket, prealloc_state); - - // Store the value by using placement new with ValueT's copy constructor. - new(static_cast(bucket) + kValueOffset) uint8_t(value); - - // Update the previous chain pointer to point to the new bucket. - pending_chain_ptr->store(pending_chain_ptr_finish_value, std::memory_order_release); - - // We're all done. - return HashTablePutResult::kOK; -} - -template -HashTablePutResult - FastSeparateChainingHashTable ::putCompositeKeyInternalFast(const std::vector &key, const std::size_t variable_key_size, const uint8_t *init_value_ptr, @@ -923,76 +843,14 @@ HashTablePutResult return HashTablePutResult::kOK; } - -template -uint8_t* FastSeparateChainingHashTable - ::upsertInternal(const TypedValue &key, - const std::size_t variable_key_size, - const uint8_t &initial_value) { - DEBUG_ASSERT(!allow_duplicate_keys); - DEBUG_ASSERT(this->key_types_.size() == 1); - DEBUG_ASSERT(key.isPlausibleInstanceOf(this->key_types_.front()->getSignature())); - - if (variable_key_size > 0) { - // Don't allocate yet, since the key may already be present. However, we - // do check if either the allocated variable storage space OR the free - // space is big enough to hold the key (at least one must be true: either - // the key is already present and allocated, or we need to be able to - // allocate enough space for it). - std::size_t allocated_bytes = header_->variable_length_bytes_allocated.load(std::memory_order_relaxed); - if ((allocated_bytes < variable_key_size) - && (allocated_bytes + variable_key_size > key_manager_.getVariableLengthKeyStorageSize())) { - return nullptr; - } - } - - const std::size_t hash_code = key.getHash(); - void *bucket = nullptr; - std::atomic *pending_chain_ptr; - std::size_t pending_chain_ptr_finish_value; - for (;;) { - if (locateBucketForInsertion(hash_code, - variable_key_size, - &bucket, - &pending_chain_ptr, - &pending_chain_ptr_finish_value, - nullptr)) { - // Found an empty bucket. - break; - } else if (bucket == nullptr) { - // Ran out of buckets or variable-key space. - return nullptr; - } else if (key_manager_.scalarKeyCollisionCheck(key, bucket)) { - // Found an already-existing entry for this key. - return reinterpret_cast(static_cast(bucket) + kValueOffset); - } - } - - // We are now writing to an empty bucket. - // Write the key and hash. - writeScalarKeyToBucket(key, hash_code, bucket, nullptr); - - // Copy the supplied 'initial_value' into place. - uint8_t *value = new(static_cast(bucket) + kValueOffset) uint8_t(initial_value); - - // Update the previous chain pointer to point to the new bucket. - pending_chain_ptr->store(pending_chain_ptr_finish_value, std::memory_order_release); - - // Return the value. - return value; -} - template uint8_t* FastSeparateChainingHashTable ::upsertInternalFast(const TypedValue &key, - const std::uint8_t *init_value_ptr, - const std::size_t variable_key_size) { + const std::size_t variable_key_size, + const std::uint8_t *init_value_ptr) { DEBUG_ASSERT(!allow_duplicate_keys); DEBUG_ASSERT(this->key_types_.size() == 1); DEBUG_ASSERT(key.isPlausibleInstanceOf(this->key_types_.front()->getSignature())); @@ -1052,67 +910,6 @@ uint8_t* FastSeparateChainingHashTable -uint8_t* FastSeparateChainingHashTable - ::upsertCompositeKeyInternal(const std::vector &key, - const std::size_t variable_key_size, - const uint8_t &initial_value) { - DEBUG_ASSERT(!allow_duplicate_keys); - DEBUG_ASSERT(this->key_types_.size() == key.size()); - - if (variable_key_size > 0) { - // Don't allocate yet, since the key may already be present. However, we - // do check if either the allocated variable storage space OR the free - // space is big enough to hold the key (at least one must be true: either - // the key is already present and allocated, or we need to be able to - // allocate enough space for it). - std::size_t allocated_bytes = header_->variable_length_bytes_allocated.load(std::memory_order_relaxed); - if ((allocated_bytes < variable_key_size) - && (allocated_bytes + variable_key_size > key_manager_.getVariableLengthKeyStorageSize())) { - return nullptr; - } - } - - const std::size_t hash_code = this->hashCompositeKey(key); - void *bucket = nullptr; - std::atomic *pending_chain_ptr; - std::size_t pending_chain_ptr_finish_value; - for (;;) { - if (locateBucketForInsertion(hash_code, - variable_key_size, - &bucket, - &pending_chain_ptr, - &pending_chain_ptr_finish_value, - nullptr)) { - // Found an empty bucket. - break; - } else if (bucket == nullptr) { - // Ran out of buckets or variable-key space. - return nullptr; - } else if (key_manager_.compositeKeyCollisionCheck(key, bucket)) { - // Found an already-existing entry for this key. - return reinterpret_cast(static_cast(bucket) + kValueOffset); - } - } - - // We are now writing to an empty bucket. - // Write the key and hash. - writeCompositeKeyToBucket(key, hash_code, bucket, nullptr); - - // Copy the supplied 'initial_value' into place. - uint8_t *value = new(static_cast(bucket) + kValueOffset) uint8_t(initial_value); - - // Update the previous chaing pointer to point to the new bucket. - pending_chain_ptr->store(pending_chain_ptr_finish_value, std::memory_order_release); - - // Return the value. - return value; -} - template