uncompression_dict_reader.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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, FilePrefetchBuffer* prefetch_buffer,
  24. bool use_cache, bool prefetch, bool pin,
  25. BlockCacheLookupContext* lookup_context,
  26. std::unique_ptr<UncompressionDictReader>* uncompression_dict_reader);
  27. Status GetOrReadUncompressionDictionary(
  28. FilePrefetchBuffer* prefetch_buffer, bool no_io, GetContext* get_context,
  29. BlockCacheLookupContext* lookup_context,
  30. CachableEntry<UncompressionDict>* uncompression_dict) const;
  31. size_t ApproximateMemoryUsage() const;
  32. private:
  33. UncompressionDictReader(const BlockBasedTable* t,
  34. CachableEntry<UncompressionDict>&& 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<UncompressionDict>* uncompression_dict);
  44. const BlockBasedTable* table_;
  45. CachableEntry<UncompressionDict> uncompression_dict_;
  46. };
  47. } // namespace ROCKSDB_NAMESPACE