]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/utilities/date_tiered/date_tiered_db_impl.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rocksdb / utilities / date_tiered / date_tiered_db_impl.h
CommitLineData
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
FG
5
6#pragma once
7#ifndef ROCKSDB_LITE
8
9#include <map>
10#include <string>
11#include <vector>
12
13#include "monitoring/instrumented_mutex.h"
14#include "options/cf_options.h"
15#include "rocksdb/db.h"
16#include "rocksdb/utilities/date_tiered_db.h"
17
18namespace rocksdb {
19
20// Implementation of DateTieredDB.
21class DateTieredDBImpl : public DateTieredDB {
22 public:
23 DateTieredDBImpl(DB* db, Options options,
24 const std::vector<ColumnFamilyDescriptor>& descriptors,
25 const std::vector<ColumnFamilyHandle*>& handles, int64_t ttl,
26 int64_t column_family_interval);
27
28 virtual ~DateTieredDBImpl();
29
30 Status Put(const WriteOptions& options, const Slice& key,
31 const Slice& val) override;
32
33 Status Get(const ReadOptions& options, const Slice& key,
34 std::string* value) override;
35
36 Status Delete(const WriteOptions& options, const Slice& key) override;
37
38 bool KeyMayExist(const ReadOptions& options, const Slice& key,
39 std::string* value, bool* value_found = nullptr) override;
40
41 Status Merge(const WriteOptions& options, const Slice& key,
42 const Slice& value) override;
43
44 Iterator* NewIterator(const ReadOptions& opts) override;
45
46 Status DropObsoleteColumnFamilies() override;
47
48 // Extract timestamp from key.
49 static Status GetTimestamp(const Slice& key, int64_t* result);
50
51 private:
52 // Base database object
53 DB* db_;
54
55 const ColumnFamilyOptions cf_options_;
56
57 const ImmutableCFOptions ioptions_;
58
11fdf7f2
TL
59 const MutableCFOptions moptions_;
60
61 const InternalKeyComparator icomp_;
62
7c673cae
FG
63 // Storing all column family handles for time series data.
64 std::vector<ColumnFamilyHandle*> handles_;
65
66 // Manages a mapping from a column family's maximum timestamp to its handle.
67 std::map<int64_t, ColumnFamilyHandle*> handle_map_;
68
69 // A time-to-live value to indicate when the data should be removed.
70 int64_t ttl_;
71
72 // An variable to indicate the time range of a column family.
73 int64_t column_family_interval_;
74
75 // Indicate largest maximum timestamp of a column family.
76 int64_t latest_timebound_;
77
78 // Mutex to protect handle_map_ operations.
79 InstrumentedMutex mutex_;
80
81 // Internal method to execute Put and Merge in batch.
82 Status Write(const WriteOptions& opts, WriteBatch* updates);
83
84 Status CreateColumnFamily(ColumnFamilyHandle** column_family);
85
86 Status FindColumnFamily(int64_t keytime, ColumnFamilyHandle** column_family,
87 bool create_if_missing);
88
89 static bool IsStale(int64_t keytime, int64_t ttl, Env* env);
90};
91
92} // namespace rocksdb
93#endif // ROCKSDB_LITE