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  * The level of Statistics to report.
10  */
11 public enum StatsLevel {
12     /**
13      * Collect all stats except time inside mutex lock AND time spent on
14      * compression.
15      */
16     EXCEPT_DETAILED_TIMERS((byte) 0x0),
17 
18     /**
19      * Collect all stats except the counters requiring to get time inside the
20      * mutex lock.
21      */
22     EXCEPT_TIME_FOR_MUTEX((byte) 0x1),
23 
24     /**
25      * Collect all stats, including measuring duration of mutex operations.
26      *
27      * If getting time is expensive on the platform to run, it can
28      * reduce scalability to more threads, especially for writes.
29      */
30     ALL((byte) 0x2);
31 
32     private final byte value;
33 
StatsLevel(final byte value)34     StatsLevel(final byte value) {
35         this.value = value;
36     }
37 
38     /**
39      * <p>Returns the byte value of the enumerations value.</p>
40      *
41      * @return byte representation
42      */
getValue()43     public byte getValue() {
44         return value;
45     }
46 
47     /**
48      * Get StatsLevel by byte value.
49      *
50      * @param value byte representation of StatsLevel.
51      *
52      * @return {@link org.rocksdb.StatsLevel} instance.
53      * @throws java.lang.IllegalArgumentException if an invalid
54      *     value is provided.
55      */
getStatsLevel(final byte value)56     public static StatsLevel getStatsLevel(final byte value) {
57         for (final StatsLevel statsLevel : StatsLevel.values()) {
58             if (statsLevel.getValue() == value){
59                 return statsLevel;
60             }
61         }
62         throw new IllegalArgumentException(
63                 "Illegal value provided for StatsLevel.");
64     }
65 }
66