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 import java.util.Arrays; 9 import java.util.List; 10 import java.util.Map; 11 12 public class CompactionJobInfo extends RocksObject { 13 CompactionJobInfo()14 public CompactionJobInfo() { 15 super(newCompactionJobInfo()); 16 } 17 18 /** 19 * Private as called from JNI C++ 20 */ CompactionJobInfo(final long nativeHandle)21 private CompactionJobInfo(final long nativeHandle) { 22 super(nativeHandle); 23 } 24 25 /** 26 * Get the name of the column family where the compaction happened. 27 * 28 * @return the name of the column family 29 */ columnFamilyName()30 public byte[] columnFamilyName() { 31 return columnFamilyName(nativeHandle_); 32 } 33 34 /** 35 * Get the status indicating whether the compaction was successful or not. 36 * 37 * @return the status 38 */ status()39 public Status status() { 40 return status(nativeHandle_); 41 } 42 43 /** 44 * Get the id of the thread that completed this compaction job. 45 * 46 * @return the id of the thread 47 */ threadId()48 public long threadId() { 49 return threadId(nativeHandle_); 50 } 51 52 /** 53 * Get the job id, which is unique in the same thread. 54 * 55 * @return the id of the thread 56 */ jobId()57 public int jobId() { 58 return jobId(nativeHandle_); 59 } 60 61 /** 62 * Get the smallest input level of the compaction. 63 * 64 * @return the input level 65 */ baseInputLevel()66 public int baseInputLevel() { 67 return baseInputLevel(nativeHandle_); 68 } 69 70 /** 71 * Get the output level of the compaction. 72 * 73 * @return the output level 74 */ outputLevel()75 public int outputLevel() { 76 return outputLevel(nativeHandle_); 77 } 78 79 /** 80 * Get the names of the compaction input files. 81 * 82 * @return the names of the input files. 83 */ inputFiles()84 public List<String> inputFiles() { 85 return Arrays.asList(inputFiles(nativeHandle_)); 86 } 87 88 /** 89 * Get the names of the compaction output files. 90 * 91 * @return the names of the output files. 92 */ outputFiles()93 public List<String> outputFiles() { 94 return Arrays.asList(outputFiles(nativeHandle_)); 95 } 96 97 /** 98 * Get the table properties for the input and output tables. 99 * 100 * The map is keyed by values from {@link #inputFiles()} and 101 * {@link #outputFiles()}. 102 * 103 * @return the table properties 104 */ tableProperties()105 public Map<String, TableProperties> tableProperties() { 106 return tableProperties(nativeHandle_); 107 } 108 109 /** 110 * Get the Reason for running the compaction. 111 * 112 * @return the reason. 113 */ compactionReason()114 public CompactionReason compactionReason() { 115 return CompactionReason.fromValue(compactionReason(nativeHandle_)); 116 } 117 118 // 119 /** 120 * Get the compression algorithm used for output files. 121 * 122 * @return the compression algorithm 123 */ compression()124 public CompressionType compression() { 125 return CompressionType.getCompressionType(compression(nativeHandle_)); 126 } 127 128 /** 129 * Get detailed information about this compaction. 130 * 131 * @return the detailed information, or null if not available. 132 */ stats()133 public /* @Nullable */ CompactionJobStats stats() { 134 final long statsHandle = stats(nativeHandle_); 135 if (statsHandle == 0) { 136 return null; 137 } 138 139 return new CompactionJobStats(statsHandle); 140 } 141 142 newCompactionJobInfo()143 private static native long newCompactionJobInfo(); disposeInternal(final long handle)144 @Override protected native void disposeInternal(final long handle); 145 columnFamilyName(final long handle)146 private static native byte[] columnFamilyName(final long handle); status(final long handle)147 private static native Status status(final long handle); threadId(final long handle)148 private static native long threadId(final long handle); jobId(final long handle)149 private static native int jobId(final long handle); baseInputLevel(final long handle)150 private static native int baseInputLevel(final long handle); outputLevel(final long handle)151 private static native int outputLevel(final long handle); inputFiles(final long handle)152 private static native String[] inputFiles(final long handle); outputFiles(final long handle)153 private static native String[] outputFiles(final long handle); tableProperties( final long handle)154 private static native Map<String, TableProperties> tableProperties( 155 final long handle); compactionReason(final long handle)156 private static native byte compactionReason(final long handle); compression(final long handle)157 private static native byte compression(final long handle); stats(final long handle)158 private static native long stats(final long handle); 159 } 160