From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/rocksdb/utilities/cache_dump_load.cc | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/rocksdb/utilities/cache_dump_load.cc (limited to 'src/rocksdb/utilities/cache_dump_load.cc') diff --git a/src/rocksdb/utilities/cache_dump_load.cc b/src/rocksdb/utilities/cache_dump_load.cc new file mode 100644 index 000000000..9a7c76798 --- /dev/null +++ b/src/rocksdb/utilities/cache_dump_load.cc @@ -0,0 +1,69 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +// This source code is licensed under both the GPLv2 (found in the +// COPYING file in the root directory) and Apache 2.0 License +// (found in the LICENSE.Apache file in the root directory). + +#ifndef ROCKSDB_LITE + +#include "rocksdb/utilities/cache_dump_load.h" + +#include "file/writable_file_writer.h" +#include "port/lang.h" +#include "rocksdb/env.h" +#include "rocksdb/file_system.h" +#include "table/format.h" +#include "util/crc32c.h" +#include "utilities/cache_dump_load_impl.h" + +namespace ROCKSDB_NAMESPACE { + +IOStatus NewToFileCacheDumpWriter(const std::shared_ptr& fs, + const FileOptions& file_opts, + const std::string& file_name, + std::unique_ptr* writer) { + std::unique_ptr file_writer; + IOStatus io_s = WritableFileWriter::Create(fs, file_name, file_opts, + &file_writer, nullptr); + if (!io_s.ok()) { + return io_s; + } + writer->reset(new ToFileCacheDumpWriter(std::move(file_writer))); + return io_s; +} + +IOStatus NewFromFileCacheDumpReader(const std::shared_ptr& fs, + const FileOptions& file_opts, + const std::string& file_name, + std::unique_ptr* reader) { + std::unique_ptr file_reader; + IOStatus io_s = RandomAccessFileReader::Create(fs, file_name, file_opts, + &file_reader, nullptr); + if (!io_s.ok()) { + return io_s; + } + reader->reset(new FromFileCacheDumpReader(std::move(file_reader))); + return io_s; +} + +Status NewDefaultCacheDumper(const CacheDumpOptions& dump_options, + const std::shared_ptr& cache, + std::unique_ptr&& writer, + std::unique_ptr* cache_dumper) { + cache_dumper->reset( + new CacheDumperImpl(dump_options, cache, std::move(writer))); + return Status::OK(); +} + +Status NewDefaultCacheDumpedLoader( + const CacheDumpOptions& dump_options, + const BlockBasedTableOptions& toptions, + const std::shared_ptr& secondary_cache, + std::unique_ptr&& reader, + std::unique_ptr* cache_dump_loader) { + cache_dump_loader->reset(new CacheDumpedLoaderImpl( + dump_options, toptions, secondary_cache, std::move(reader))); + return Status::OK(); +} + +} // namespace ROCKSDB_NAMESPACE +#endif // ROCKSDB_LITE -- cgit v1.2.3