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 
6 package org.rocksdb;
7 
8 /**
9  * EncodingType
10  *
11  * <p>The value will determine how to encode keys
12  * when writing to a new SST file.</p>
13  *
14  * <p>This value will be stored
15  * inside the SST file which will be used when reading from
16  * the file, which makes it possible for users to choose
17  * different encoding type when reopening a DB. Files with
18  * different encoding types can co-exist in the same DB and
19  * can be read.</p>
20  */
21 public enum EncodingType {
22   /**
23    * Always write full keys without any special encoding.
24    */
25   kPlain((byte) 0),
26   /**
27    * <p>Find opportunity to write the same prefix once for multiple rows.
28    * In some cases, when a key follows a previous key with the same prefix,
29    * instead of writing out the full key, it just writes out the size of the
30    * shared prefix, as well as other bytes, to save some bytes.</p>
31    *
32    * <p>When using this option, the user is required to use the same prefix
33    * extractor to make sure the same prefix will be extracted from the same key.
34    * The Name() value of the prefix extractor will be stored in the file. When
35    * reopening the file, the name of the options.prefix_extractor given will be
36    * bitwise compared to the prefix extractors stored in the file. An error
37    * will be returned if the two don't match.</p>
38    */
39   kPrefix((byte) 1);
40 
41   /**
42    * Returns the byte value of the enumerations value
43    *
44    * @return byte representation
45    */
getValue()46   public byte getValue() {
47     return value_;
48   }
49 
EncodingType(byte value)50   private EncodingType(byte value) {
51     value_ = value;
52   }
53 
54   private final byte value_;
55 }
56