]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
11fdf7f2 TL |
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). | |
7c673cae | 5 | // |
7c673cae FG |
6 | |
7 | #ifndef ROCKSDB_LITE | |
8 | ||
9 | #include "rocksdb/convenience.h" | |
10 | ||
11 | #include "db/db_impl.h" | |
11fdf7f2 | 12 | #include "util/cast_util.h" |
7c673cae FG |
13 | |
14 | namespace rocksdb { | |
15 | ||
16 | void CancelAllBackgroundWork(DB* db, bool wait) { | |
11fdf7f2 TL |
17 | (static_cast_with_check<DBImpl, DB>(db->GetRootDB())) |
18 | ->CancelAllBackgroundWork(wait); | |
7c673cae FG |
19 | } |
20 | ||
21 | Status DeleteFilesInRange(DB* db, ColumnFamilyHandle* column_family, | |
11fdf7f2 TL |
22 | const Slice* begin, const Slice* end, |
23 | bool include_end) { | |
24 | RangePtr range(begin, end); | |
25 | return DeleteFilesInRanges(db, column_family, &range, 1, include_end); | |
26 | } | |
27 | ||
28 | Status DeleteFilesInRanges(DB* db, ColumnFamilyHandle* column_family, | |
29 | const RangePtr* ranges, size_t n, | |
30 | bool include_end) { | |
31 | return (static_cast_with_check<DBImpl, DB>(db->GetRootDB())) | |
32 | ->DeleteFilesInRanges(column_family, ranges, n, include_end); | |
33 | } | |
34 | ||
35 | Status VerifySstFileChecksum(const Options& options, | |
36 | const EnvOptions& env_options, | |
37 | const std::string& file_path) { | |
494da23a | 38 | std::unique_ptr<RandomAccessFile> file; |
11fdf7f2 TL |
39 | uint64_t file_size; |
40 | InternalKeyComparator internal_comparator(options.comparator); | |
41 | ImmutableCFOptions ioptions(options); | |
42 | ||
43 | Status s = ioptions.env->NewRandomAccessFile(file_path, &file, env_options); | |
44 | if (s.ok()) { | |
45 | s = ioptions.env->GetFileSize(file_path, &file_size); | |
46 | } else { | |
47 | return s; | |
48 | } | |
494da23a | 49 | std::unique_ptr<TableReader> table_reader; |
11fdf7f2 TL |
50 | std::unique_ptr<RandomAccessFileReader> file_reader( |
51 | new RandomAccessFileReader(std::move(file), file_path)); | |
52 | const bool kImmortal = true; | |
53 | s = ioptions.table_factory->NewTableReader( | |
54 | TableReaderOptions(ioptions, options.prefix_extractor.get(), env_options, | |
55 | internal_comparator, false /* skip_filters */, | |
56 | !kImmortal, -1 /* level */), | |
57 | std::move(file_reader), file_size, &table_reader, | |
58 | false /* prefetch_index_and_filter_in_cache */); | |
59 | if (!s.ok()) { | |
60 | return s; | |
61 | } | |
62 | s = table_reader->VerifyChecksum(); | |
63 | return s; | |
7c673cae FG |
64 | } |
65 | ||
66 | } // namespace rocksdb | |
67 | ||
68 | #endif // ROCKSDB_LITE |