]>
git.proxmox.com Git - ceph.git/blob - 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).
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.
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:
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.
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.
31 public enum IndexShorteningMode
{
35 kNoShortening((byte) 0),
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.
40 kShortenSeparators((byte) 1),
42 * Shorten both keys between blocks and key after last block.
44 kShortenSeparatorsAndSuccessor((byte) 2);
46 private final byte value
;
48 IndexShorteningMode(final byte value
) {
53 * Returns the byte value of the enumerations value.
55 * @return byte representation