uncompression_dict_reader.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #pragma once
  7. #include <cassert>
  8. #include "table/block_based/cachable_entry.h"
  9. #include "table/format.h"
  10. namespace ROCKSDB_NAMESPACE {
  11. class BlockBasedTable;
  12. struct BlockCacheLookupContext;
  13. class FilePrefetchBuffer;
  14. class GetContext;
  15. struct ReadOptions;
  16. struct UncompressionDict;
  17. // Provides access to the uncompression dictionary regardless of whether
  18. // it is owned by the reader or stored in the cache, or whether it is pinned
  19. // in the cache or not.
  20. class UncompressionDictReader {
  21. public:
  22. static Status Create(
  23. const BlockBasedTable* table, const ReadOptions& ro,
  24. FilePrefetchBuffer* prefetch_buffer, bool use_cache, bool prefetch,
  25. bool pin, BlockCacheLookupContext* lookup_context,
  26. std::unique_ptr<UncompressionDictReader>* uncompression_dict_reader);
  27. Status GetOrReadUncompressionDictionary(
  28. FilePrefetchBuffer* prefetch_buffer, const ReadOptions& ro,
  29. GetContext* get_context, BlockCacheLookupContext* lookup_context,
  30. CachableEntry<DecompressorDict>* uncompression_dict) const;
  31. size_t ApproximateMemoryUsage() const;
  32. private:
  33. UncompressionDictReader(const BlockBasedTable* t,
  34. CachableEntry<DecompressorDict>&& uncompression_dict)
  35. : table_(t), uncompression_dict_(std::move(uncompression_dict)) {
  36. assert(table_);
  37. }
  38. bool cache_dictionary_blocks() const;
  39. static Status ReadUncompressionDictionary(
  40. const BlockBasedTable* table, FilePrefetchBuffer* prefetch_buffer,
  41. const ReadOptions& read_options, bool use_cache, GetContext* get_context,
  42. BlockCacheLookupContext* lookup_context,
  43. CachableEntry<DecompressorDict>* uncompression_dict);
  44. const BlockBasedTable* table_;
  45. CachableEntry<DecompressorDict> uncompression_dict_;
  46. };
  47. } // namespace ROCKSDB_NAMESPACE