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  * RocksDB {@link ReadOptions} read tiers.
10  */
11 public enum ReadTier {
12   READ_ALL_TIER((byte)0),
13   BLOCK_CACHE_TIER((byte)1),
14   PERSISTED_TIER((byte)2),
15   MEMTABLE_TIER((byte)3);
16 
17   private final byte value;
18 
ReadTier(final byte value)19   ReadTier(final byte value) {
20     this.value = value;
21   }
22 
23   /**
24    * Returns the byte value of the enumerations value
25    *
26    * @return byte representation
27    */
getValue()28   public byte getValue() {
29     return value;
30   }
31 
32   /**
33    * Get ReadTier by byte value.
34    *
35    * @param value byte representation of ReadTier.
36    *
37    * @return {@link org.rocksdb.ReadTier} instance or null.
38    * @throws java.lang.IllegalArgumentException if an invalid
39    *     value is provided.
40    */
getReadTier(final byte value)41   public static ReadTier getReadTier(final byte value) {
42     for (final ReadTier readTier : ReadTier.values()) {
43       if (readTier.getValue() == value){
44         return readTier;
45       }
46     }
47     throw new IllegalArgumentException("Illegal value provided for ReadTier.");
48   }
49 }
50