]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
11fdf7f2 TL |
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). | |
7c673cae FG |
5 | |
6 | package org.rocksdb; | |
7 | ||
8 | /** | |
9 | * File access pattern once a compaction has started | |
10 | */ | |
11 | public enum AccessHint { | |
12 | NONE((byte)0x0), | |
13 | NORMAL((byte)0x1), | |
14 | SEQUENTIAL((byte)0x2), | |
15 | WILLNEED((byte)0x3); | |
16 | ||
17 | private final byte value; | |
18 | ||
19 | AccessHint(final byte value) { | |
20 | this.value = value; | |
21 | } | |
22 | ||
23 | /** | |
24 | * <p>Returns the byte value of the enumerations value.</p> | |
25 | * | |
26 | * @return byte representation | |
27 | */ | |
28 | public byte getValue() { | |
29 | return value; | |
30 | } | |
31 | ||
32 | /** | |
33 | * <p>Get the AccessHint enumeration value by | |
34 | * passing the byte identifier to this method.</p> | |
35 | * | |
36 | * @param byteIdentifier of AccessHint. | |
37 | * | |
38 | * @return AccessHint instance. | |
39 | * | |
40 | * @throws IllegalArgumentException if the access hint for the byteIdentifier | |
41 | * cannot be found | |
42 | */ | |
43 | public static AccessHint getAccessHint(final byte byteIdentifier) { | |
44 | for (final AccessHint accessHint : AccessHint.values()) { | |
45 | if (accessHint.getValue() == byteIdentifier) { | |
46 | return accessHint; | |
47 | } | |
48 | } | |
49 | ||
50 | throw new IllegalArgumentException( | |
51 | "Illegal value provided for AccessHint."); | |
52 | } | |
53 | } |