Github user hbdeshmukh commented on a diff in the pull request: https://github.com/apache/incubator-quickstep/pull/90#discussion_r78224619 --- Diff: storage/FastHashTableFactory.hpp --- @@ -0,0 +1,300 @@ +/** + * Copyright 2015-2016 Pivotal Software, Inc. + * + * Licensed 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. + **/ + +#ifndef QUICKSTEP_STORAGE_FAST_HASH_TABLE_FACTORY_HPP_ +#define QUICKSTEP_STORAGE_FAST_HASH_TABLE_FACTORY_HPP_ + +#include <cstddef> +#include <string> +#include <vector> + +#include "storage/HashTable.hpp" +#include "storage/FastHashTable.hpp" +#include "storage/HashTableBase.hpp" +#include "storage/HashTableFactory.hpp" +#include "storage/HashTable.pb.h" +#include "storage/LinearOpenAddressingHashTable.hpp" +#include "storage/SeparateChainingHashTable.hpp" +#include "storage/FastSeparateChainingHashTable.hpp" +#include "storage/SimpleScalarSeparateChainingHashTable.hpp" +#include "storage/TupleReference.hpp" +#include "types/TypeFactory.hpp" +#include "utility/BloomFilter.hpp" +#include "utility/Macros.hpp" + +#include "glog/logging.h" + +namespace quickstep { + +class StorageManager; +class Type; + +/** \addtogroup Storage + * @{ + */ + +/** + * @brief Templated all-static factory class that makes it easier to + * instantiate HashTables with the particular HashTable implementation + * chosen at runtime. All template parameters are exactly the same as + * those of HashTable. + **/ +template <bool resizable, + bool serializable, + bool force_key_copy, + bool allow_duplicate_keys> +class FastHashTableFactory { + public: + /** + * @brief Create a new resizable HashTable, with the type selected by + * hash_table_type. Other parameters are forwarded to the HashTable's + * constructor. + * + * @param hash_table_type The specific HashTable implementation that should + * be used. + * @param key_types A vector of one or more types (>1 indicates a composite + * key). Forwarded as-is to the HashTable's constructor. + * @param num_entries The estimated number of entries the HashTable will + * hold. Forwarded as-is to the HashTable's constructor. + * @param storage_manager The StorageManager to use (a StorageBlob will be + * allocated to hold the HashTable's contents). Forwarded as-is to the + * HashTable's constructor. + * @return A new resizable HashTable. + **/ + static FastHashTable<resizable, serializable, force_key_copy, allow_duplicate_keys>* + CreateResizable(const HashTableImplType hash_table_type, + const std::vector<const Type*> &key_types, + const std::size_t num_entries, + const std::vector<std::size_t> &payload_sizes, + const std::vector<AggregationHandle *> &handles, + StorageManager *storage_manager) { + DCHECK(resizable); + + switch (hash_table_type) { + case HashTableImplType::kSeparateChaining: + return new FastSeparateChainingHashTable< + resizable, + serializable, + force_key_copy, + allow_duplicate_keys>(key_types, num_entries, payload_sizes, handles, storage_manager); + case HashTableImplType::kLinearOpenAddressing: --- End diff -- No need for this case.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---