reader_common.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  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. #include "rocksdb/advanced_cache.h"
  11. #include "rocksdb/table.h"
  12. namespace ROCKSDB_NAMESPACE {
  13. class Footer;
  14. // Release the cached entry and decrement its ref count.
  15. void ForceReleaseCachedEntry(void* arg, void* h);
  16. inline MemoryAllocator* GetMemoryAllocator(
  17. const BlockBasedTableOptions& table_options) {
  18. return table_options.block_cache.get()
  19. ? table_options.block_cache->memory_allocator()
  20. : nullptr;
  21. }
  22. // Assumes block has a trailer past `data + block_size` as in format.h.
  23. // `file_name` provided for generating diagnostic message in returned status.
  24. // `offset` might be required for proper verification (also used for message).
  25. //
  26. // Returns Status::OK() on checksum match, or Status::Corruption() on checksum
  27. // mismatch.
  28. Status VerifyBlockChecksum(const Footer& footer, const char* data,
  29. size_t block_size, const std::string& file_name,
  30. uint64_t offset);
  31. } // namespace ROCKSDB_NAMESPACE