1 // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2 package org.rocksdb;
3 
4 /**
5  * Algorithm used to make a compaction request stop picking new files
6  * into a single compaction run
7  */
8 public enum CompactionStopStyle {
9 
10   /**
11    * Pick files of similar size
12    */
13   CompactionStopStyleSimilarSize((byte)0x0),
14 
15   /**
16    * Total size of picked files > next file
17    */
18   CompactionStopStyleTotalSize((byte)0x1);
19 
20 
21   private final byte value;
22 
CompactionStopStyle(final byte value)23   CompactionStopStyle(final byte value) {
24     this.value = value;
25   }
26 
27   /**
28    * Returns the byte value of the enumerations value
29    *
30    * @return byte representation
31    */
getValue()32   public byte getValue() {
33     return value;
34   }
35 
36   /**
37    * Get CompactionStopStyle by byte value.
38    *
39    * @param value byte representation of CompactionStopStyle.
40    *
41    * @return {@link org.rocksdb.CompactionStopStyle} instance or null.
42    * @throws java.lang.IllegalArgumentException if an invalid
43    *     value is provided.
44    */
getCompactionStopStyle(final byte value)45   public static CompactionStopStyle getCompactionStopStyle(final byte value) {
46     for (final CompactionStopStyle compactionStopStyle :
47         CompactionStopStyle.values()) {
48       if (compactionStopStyle.getValue() == value){
49         return compactionStopStyle;
50       }
51     }
52     throw new IllegalArgumentException(
53         "Illegal value provided for CompactionStopStyle.");
54   }
55 }
56