]>
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 FG |
5 | |
6 | #pragma once | |
7 | ||
8 | #include <string> | |
9 | #include "rocksdb/table.h" | |
10 | ||
11 | namespace rocksdb { | |
12 | ||
13 | class Slice; | |
14 | class BlockBuilder; | |
15 | struct Options; | |
16 | ||
17 | // FlushBlockPolicy provides a configurable way to determine when to flush a | |
18 | // block in the block based tables, | |
19 | class FlushBlockPolicy { | |
20 | public: | |
21 | // Keep track of the key/value sequences and return the boolean value to | |
22 | // determine if table builder should flush current data block. | |
23 | virtual bool Update(const Slice& key, | |
24 | const Slice& value) = 0; | |
25 | ||
26 | virtual ~FlushBlockPolicy() { } | |
27 | }; | |
28 | ||
29 | class FlushBlockPolicyFactory { | |
30 | public: | |
31 | // Return the name of the flush block policy. | |
32 | virtual const char* Name() const = 0; | |
33 | ||
34 | // Return a new block flush policy that flushes data blocks by data size. | |
35 | // FlushBlockPolicy may need to access the metadata of the data block | |
36 | // builder to determine when to flush the blocks. | |
37 | // | |
38 | // Callers must delete the result after any database that is using the | |
39 | // result has been closed. | |
40 | virtual FlushBlockPolicy* NewFlushBlockPolicy( | |
41 | const BlockBasedTableOptions& table_options, | |
42 | const BlockBuilder& data_block_builder) const = 0; | |
43 | ||
44 | virtual ~FlushBlockPolicyFactory() { } | |
45 | }; | |
46 | ||
47 | class FlushBlockBySizePolicyFactory : public FlushBlockPolicyFactory { | |
48 | public: | |
49 | FlushBlockBySizePolicyFactory() {} | |
50 | ||
11fdf7f2 | 51 | const char* Name() const override { return "FlushBlockBySizePolicyFactory"; } |
7c673cae | 52 | |
11fdf7f2 | 53 | FlushBlockPolicy* NewFlushBlockPolicy( |
7c673cae FG |
54 | const BlockBasedTableOptions& table_options, |
55 | const BlockBuilder& data_block_builder) const override; | |
56 | ||
57 | static FlushBlockPolicy* NewFlushBlockPolicy( | |
58 | const uint64_t size, const int deviation, | |
59 | const BlockBuilder& data_block_builder); | |
60 | }; | |
61 | ||
62 | } // rocksdb |