/src/rocksdb/table/block_based/hash_index_reader.h
Line | Count | Source |
1 | | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | | // This source code is licensed under both the GPLv2 (found in the |
3 | | // COPYING file in the root directory) and Apache 2.0 License |
4 | | // (found in the LICENSE.Apache file in the root directory). |
5 | | // |
6 | | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. |
7 | | // Use of this source code is governed by a BSD-style license that can be |
8 | | // found in the LICENSE file. See the AUTHORS file for names of contributors. |
9 | | #pragma once |
10 | | |
11 | | #include "table/block_based/index_reader_common.h" |
12 | | |
13 | | namespace ROCKSDB_NAMESPACE { |
14 | | // Index that leverages an internal hash table to quicken the lookup for a given |
15 | | // key. |
16 | | class HashIndexReader : public BlockBasedTable::IndexReaderCommon { |
17 | | public: |
18 | | static Status Create(const BlockBasedTable* table, const ReadOptions& ro, |
19 | | FilePrefetchBuffer* prefetch_buffer, |
20 | | InternalIterator* meta_index_iter, bool use_cache, |
21 | | bool prefetch, bool pin, |
22 | | BlockCacheLookupContext* lookup_context, |
23 | | std::unique_ptr<IndexReader>* index_reader); |
24 | | |
25 | | InternalIteratorBase<IndexValue>* NewIterator( |
26 | | const ReadOptions& read_options, bool disable_prefix_seek, |
27 | | IndexBlockIter* iter, GetContext* get_context, |
28 | | BlockCacheLookupContext* lookup_context) override; |
29 | | |
30 | 0 | size_t ApproximateMemoryUsage() const override { |
31 | 0 | size_t usage = ApproximateIndexBlockMemoryUsage(); |
32 | 0 | #ifdef ROCKSDB_MALLOC_USABLE_SIZE |
33 | 0 | usage += malloc_usable_size(const_cast<HashIndexReader*>(this)); |
34 | | #else |
35 | | if (prefix_index_) { |
36 | | usage += prefix_index_->ApproximateMemoryUsage(); |
37 | | } |
38 | | usage += sizeof(*this); |
39 | | #endif // ROCKSDB_MALLOC_USABLE_SIZE |
40 | 0 | return usage; |
41 | 0 | } |
42 | | |
43 | | private: |
44 | | HashIndexReader(const BlockBasedTable* t, CachableEntry<Block>&& index_block) |
45 | 0 | : IndexReaderCommon(t, std::move(index_block)) {} |
46 | | |
47 | | std::unique_ptr<BlockPrefixIndex> prefix_index_; |
48 | | }; |
49 | | } // namespace ROCKSDB_NAMESPACE |