]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/db/convenience.cc
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).
9 #include "rocksdb/convenience.h"
11 #include "db/db_impl/db_impl.h"
12 #include "util/cast_util.h"
14 namespace ROCKSDB_NAMESPACE
{
16 void CancelAllBackgroundWork(DB
* db
, bool wait
) {
17 (static_cast_with_check
<DBImpl
, DB
>(db
->GetRootDB()))
18 ->CancelAllBackgroundWork(wait
);
21 Status
DeleteFilesInRange(DB
* db
, ColumnFamilyHandle
* column_family
,
22 const Slice
* begin
, const Slice
* end
,
24 RangePtr
range(begin
, end
);
25 return DeleteFilesInRanges(db
, column_family
, &range
, 1, include_end
);
28 Status
DeleteFilesInRanges(DB
* db
, ColumnFamilyHandle
* column_family
,
29 const RangePtr
* ranges
, size_t n
,
31 return (static_cast_with_check
<DBImpl
, DB
>(db
->GetRootDB()))
32 ->DeleteFilesInRanges(column_family
, ranges
, n
, include_end
);
35 Status
VerifySstFileChecksum(const Options
& options
,
36 const EnvOptions
& env_options
,
37 const std::string
& file_path
) {
38 return VerifySstFileChecksum(options
, env_options
, ReadOptions(), file_path
);
40 Status
VerifySstFileChecksum(const Options
& options
,
41 const EnvOptions
& env_options
,
42 const ReadOptions
& read_options
,
43 const std::string
& file_path
) {
44 std::unique_ptr
<FSRandomAccessFile
> file
;
46 InternalKeyComparator
internal_comparator(options
.comparator
);
47 ImmutableCFOptions
ioptions(options
);
49 Status s
= ioptions
.fs
->NewRandomAccessFile(file_path
,
50 FileOptions(env_options
),
53 s
= ioptions
.fs
->GetFileSize(file_path
, IOOptions(), &file_size
, nullptr);
57 std::unique_ptr
<TableReader
> table_reader
;
58 std::unique_ptr
<RandomAccessFileReader
> file_reader(
59 new RandomAccessFileReader(std::move(file
), file_path
));
60 const bool kImmortal
= true;
61 s
= ioptions
.table_factory
->NewTableReader(
62 TableReaderOptions(ioptions
, options
.prefix_extractor
.get(), env_options
,
63 internal_comparator
, false /* skip_filters */,
64 !kImmortal
, -1 /* level */),
65 std::move(file_reader
), file_size
, &table_reader
,
66 false /* prefetch_index_and_filter_in_cache */);
70 s
= table_reader
->VerifyChecksum(read_options
,
71 TableReaderCaller::kUserVerifyChecksum
);
75 } // namespace ROCKSDB_NAMESPACE
77 #endif // ROCKSDB_LITE