-
Notifications
You must be signed in to change notification settings - Fork 5
/
dedupfs.cc
56 lines (41 loc) · 1.52 KB
/
dedupfs.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2021-present, Facebook, Inc. 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).
#include "dedupfs.h"
#include <openssl/md5.h>
#include <rocksdb/utilities/object_registry.h>
namespace ROCKSDB_NAMESPACE {
#ifndef ROCKSDB_LITE
extern "C" FactoryFunc<FileSystem> dedupfs_reg;
#if ROCKSDB_MAJOR >= 7
FactoryFunc<FileSystem> dedupfs_reg =
ObjectLibrary::Default()->AddFactory<FileSystem>(
"dedupfs",
[](const std::string& /* uri */, std::unique_ptr<FileSystem>* f,
std::string* /* errmsg */) {
*f = NewDedupFileSystem();
return f->get();
});
#else // ROCKSDB_MAJOR >= 7
FactoryFunc<FileSystem> dedupfs_reg =
ObjectLibrary::Default()->Register<FileSystem>(
"dedupfs",
[](const std::string& /* uri */, std::unique_ptr<FileSystem>* f,
std::string* /* errmsg */) {
*f = NewDedupFileSystem();
return f->get();
});
#endif // ROCKSDB_MAJOR >= 7
#endif // ROCKSDB_LITE
class DedupFileSystem : public FileSystemWrapper {
public:
DedupFileSystem(std::shared_ptr<FileSystem> t) : FileSystemWrapper(t) {}
const char* Name() const override { return "DedupFileSystem"; }
};
std::unique_ptr<FileSystem>
NewDedupFileSystem() {
return std::unique_ptr<FileSystem>(
new DedupFileSystem(FileSystem::Default()));
}
} // namespace ROCKSDB_NAMESPACE