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 * MemoryUsageType 10 * 11 * <p>The value will be used as a key to indicate the type of memory usage 12 * described</p> 13 */ 14 public enum MemoryUsageType { 15 /** 16 * Memory usage of all the mem-tables. 17 */ 18 kMemTableTotal((byte) 0), 19 /** 20 * Memory usage of those un-flushed mem-tables. 21 */ 22 kMemTableUnFlushed((byte) 1), 23 /** 24 * Memory usage of all the table readers. 25 */ 26 kTableReadersTotal((byte) 2), 27 /** 28 * Memory usage by Cache. 29 */ 30 kCacheTotal((byte) 3), 31 /** 32 * Max usage types - copied to keep 1:1 with native. 33 */ 34 kNumUsageTypes((byte) 4); 35 36 /** 37 * Returns the byte value of the enumerations value 38 * 39 * @return byte representation 40 */ getValue()41 public byte getValue() { 42 return value_; 43 } 44 45 /** 46 * <p>Get the MemoryUsageType enumeration value by 47 * passing the byte identifier to this method.</p> 48 * 49 * @param byteIdentifier of MemoryUsageType. 50 * 51 * @return MemoryUsageType instance. 52 * 53 * @throws IllegalArgumentException if the usage type for the byteIdentifier 54 * cannot be found 55 */ getMemoryUsageType(final byte byteIdentifier)56 public static MemoryUsageType getMemoryUsageType(final byte byteIdentifier) { 57 for (final MemoryUsageType memoryUsageType : MemoryUsageType.values()) { 58 if (memoryUsageType.getValue() == byteIdentifier) { 59 return memoryUsageType; 60 } 61 } 62 63 throw new IllegalArgumentException( 64 "Illegal value provided for MemoryUsageType."); 65 } 66 MemoryUsageType(byte value)67 MemoryUsageType(byte value) { 68 value_ = value; 69 } 70 71 private final byte value_; 72 } 73