]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/IndexShorteningMode.java
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / java / src / main / java / org / rocksdb / IndexShorteningMode.java
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).
5 package org.rocksdb;
6
7 /**
8 * This enum allows trading off increased index size for improved iterator
9 * seek performance in some situations, particularly when block cache is
10 * disabled ({@link ReadOptions#fillCache()} == false and direct IO is
11 * enabled ({@link DBOptions#useDirectReads()} == true).
12 * The default mode is the best tradeoff for most use cases.
13 * This option only affects newly written tables.
14 *
15 * The index contains a key separating each pair of consecutive blocks.
16 * Let A be the highest key in one block, B the lowest key in the next block,
17 * and I the index entry separating these two blocks:
18 * [ ... A] I [B ...]
19 * I is allowed to be anywhere in [A, B).
20 * If an iterator is seeked to a key in (A, I], we'll unnecessarily read the
21 * first block, then immediately fall through to the second block.
22 * However, if I=A, this can't happen, and we'll read only the second block.
23 * In kNoShortening mode, we use I=A. In other modes, we use the shortest
24 * key in [A, B), which usually significantly reduces index size.
25 *
26 * There's a similar story for the last index entry, which is an upper bound
27 * of the highest key in the file. If it's shortened and therefore
28 * overestimated, iterator is likely to unnecessarily read the last data block
29 * from each file on each seek.
30 */
31 public enum IndexShorteningMode {
32 /**
33 * Use full keys.
34 */
35 kNoShortening((byte) 0),
36 /**
37 * Shorten index keys between blocks, but use full key for the last index
38 * key, which is the upper bound of the whole file.
39 */
40 kShortenSeparators((byte) 1),
41 /**
42 * Shorten both keys between blocks and key after last block.
43 */
44 kShortenSeparatorsAndSuccessor((byte) 2);
45
46 private final byte value;
47
48 IndexShorteningMode(final byte value) {
49 this.value = value;
50 }
51
52 /**
53 * Returns the byte value of the enumerations value.
54 *
55 * @return byte representation
56 */
57 byte getValue() {
58 return value;
59 }
60 }