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 public class CompactionJobStats extends RocksObject {
9 
CompactionJobStats()10   public CompactionJobStats() {
11     super(newCompactionJobStats());
12   }
13 
14   /**
15    * Private as called from JNI C++
16    */
CompactionJobStats(final long nativeHandle)17   CompactionJobStats(final long nativeHandle) {
18     super(nativeHandle);
19   }
20 
21   /**
22    * Reset the stats.
23    */
reset()24   public void reset() {
25     reset(nativeHandle_);
26   }
27 
28   /**
29    * Aggregate the CompactionJobStats from another instance with this one.
30    *
31    * @param compactionJobStats another instance of stats.
32    */
add(final CompactionJobStats compactionJobStats)33   public void add(final CompactionJobStats compactionJobStats) {
34     add(nativeHandle_, compactionJobStats.nativeHandle_);
35   }
36 
37   /**
38    * Get the elapsed time in micro of this compaction.
39    *
40    * @return the elapsed time in micro of this compaction.
41    */
elapsedMicros()42   public long elapsedMicros() {
43     return elapsedMicros(nativeHandle_);
44   }
45 
46   /**
47    * Get the number of compaction input records.
48    *
49    * @return the number of compaction input records.
50    */
numInputRecords()51   public long numInputRecords() {
52     return numInputRecords(nativeHandle_);
53   }
54 
55   /**
56    * Get the number of compaction input files.
57    *
58    * @return the number of compaction input files.
59    */
numInputFiles()60   public long numInputFiles() {
61     return numInputFiles(nativeHandle_);
62   }
63 
64   /**
65    * Get the number of compaction input files at the output level.
66    *
67    * @return the number of compaction input files at the output level.
68    */
numInputFilesAtOutputLevel()69   public long numInputFilesAtOutputLevel() {
70     return numInputFilesAtOutputLevel(nativeHandle_);
71   }
72 
73   /**
74    * Get the number of compaction output records.
75    *
76    * @return the number of compaction output records.
77    */
numOutputRecords()78   public long numOutputRecords() {
79     return numOutputRecords(nativeHandle_);
80   }
81 
82   /**
83    * Get the number of compaction output files.
84    *
85    * @return the number of compaction output files.
86    */
numOutputFiles()87   public long numOutputFiles() {
88     return numOutputFiles(nativeHandle_);
89   }
90 
91   /**
92    * Determine if the compaction is a manual compaction.
93    *
94    * @return true if the compaction is a manual compaction, false otherwise.
95    */
isManualCompaction()96   public boolean isManualCompaction() {
97     return isManualCompaction(nativeHandle_);
98   }
99 
100   /**
101    * Get the size of the compaction input in bytes.
102    *
103    * @return the size of the compaction input in bytes.
104    */
totalInputBytes()105   public long totalInputBytes() {
106     return totalInputBytes(nativeHandle_);
107   }
108 
109   /**
110    * Get the size of the compaction output in bytes.
111    *
112    * @return the size of the compaction output in bytes.
113    */
totalOutputBytes()114   public long totalOutputBytes() {
115     return totalOutputBytes(nativeHandle_);
116   }
117 
118   /**
119    * Get the number of records being replaced by newer record associated
120    * with same key.
121    *
122    * This could be a new value or a deletion entry for that key so this field
123    * sums up all updated and deleted keys.
124    *
125    * @return the number of records being replaced by newer record associated
126    *     with same key.
127    */
numRecordsReplaced()128   public long numRecordsReplaced() {
129     return numRecordsReplaced(nativeHandle_);
130   }
131 
132   /**
133    * Get the sum of the uncompressed input keys in bytes.
134    *
135    * @return the sum of the uncompressed input keys in bytes.
136    */
totalInputRawKeyBytes()137   public long totalInputRawKeyBytes() {
138     return totalInputRawKeyBytes(nativeHandle_);
139   }
140 
141   /**
142    * Get the sum of the uncompressed input values in bytes.
143    *
144    * @return the sum of the uncompressed input values in bytes.
145    */
totalInputRawValueBytes()146   public long totalInputRawValueBytes() {
147     return totalInputRawValueBytes(nativeHandle_);
148   }
149 
150   /**
151    * Get the number of deletion entries before compaction.
152    *
153    * Deletion entries can disappear after compaction because they expired.
154    *
155    * @return the number of deletion entries before compaction.
156    */
numInputDeletionRecords()157   public long numInputDeletionRecords() {
158     return numInputDeletionRecords(nativeHandle_);
159   }
160 
161   /**
162    * Get the number of deletion records that were found obsolete and discarded
163    * because it is not possible to delete any more keys with this entry.
164    * (i.e. all possible deletions resulting from it have been completed)
165    *
166    * @return the number of deletion records that were found obsolete and
167    *     discarded.
168    */
numExpiredDeletionRecords()169   public long numExpiredDeletionRecords() {
170     return numExpiredDeletionRecords(nativeHandle_);
171   }
172 
173   /**
174    * Get the number of corrupt keys (ParseInternalKey returned false when
175    * applied to the key) encountered and written out.
176    *
177    * @return the number of corrupt keys.
178    */
numCorruptKeys()179   public long numCorruptKeys() {
180     return numCorruptKeys(nativeHandle_);
181   }
182 
183   /**
184    * Get the Time spent on file's Append() call.
185    *
186    * Only populated if {@link ColumnFamilyOptions#reportBgIoStats()} is set.
187    *
188    * @return the Time spent on file's Append() call.
189    */
fileWriteNanos()190   public long fileWriteNanos() {
191     return fileWriteNanos(nativeHandle_);
192   }
193 
194   /**
195    * Get the Time spent on sync file range.
196    *
197    * Only populated if {@link ColumnFamilyOptions#reportBgIoStats()} is set.
198    *
199    * @return the Time spent on sync file range.
200    */
fileRangeSyncNanos()201   public long fileRangeSyncNanos() {
202     return fileRangeSyncNanos(nativeHandle_);
203   }
204 
205   /**
206    * Get the Time spent on file fsync.
207    *
208    * Only populated if {@link ColumnFamilyOptions#reportBgIoStats()} is set.
209    *
210    * @return the Time spent on file fsync.
211    */
fileFsyncNanos()212   public long fileFsyncNanos() {
213     return fileFsyncNanos(nativeHandle_);
214   }
215 
216   /**
217    * Get the Time spent on preparing file write (falocate, etc)
218    *
219    * Only populated if {@link ColumnFamilyOptions#reportBgIoStats()} is set.
220    *
221    * @return the Time spent on preparing file write (falocate, etc).
222    */
filePrepareWriteNanos()223   public long filePrepareWriteNanos() {
224     return filePrepareWriteNanos(nativeHandle_);
225   }
226 
227   /**
228    * Get the smallest output key prefix.
229    *
230    * @return the smallest output key prefix.
231    */
smallestOutputKeyPrefix()232   public byte[] smallestOutputKeyPrefix() {
233     return smallestOutputKeyPrefix(nativeHandle_);
234   }
235 
236   /**
237    * Get the largest output key prefix.
238    *
239    * @return the smallest output key prefix.
240    */
largestOutputKeyPrefix()241   public byte[] largestOutputKeyPrefix() {
242     return largestOutputKeyPrefix(nativeHandle_);
243   }
244 
245   /**
246    * Get the number of single-deletes which do not meet a put.
247    *
248    * @return number of single-deletes which do not meet a put.
249    */
250   @Experimental("Performance optimization for a very specific workload")
numSingleDelFallthru()251   public long numSingleDelFallthru() {
252     return numSingleDelFallthru(nativeHandle_);
253   }
254 
255   /**
256    * Get the number of single-deletes which meet something other than a put.
257    *
258    * @return the number of single-deletes which meet something other than a put.
259    */
260   @Experimental("Performance optimization for a very specific workload")
numSingleDelMismatch()261   public long numSingleDelMismatch() {
262     return numSingleDelMismatch(nativeHandle_);
263   }
264 
newCompactionJobStats()265   private static native long newCompactionJobStats();
disposeInternal(final long handle)266   @Override protected native void disposeInternal(final long handle);
267 
268 
reset(final long handle)269   private static native void reset(final long handle);
add(final long handle, final long compactionJobStatsHandle)270   private static native void add(final long handle,
271       final long compactionJobStatsHandle);
elapsedMicros(final long handle)272   private static native long elapsedMicros(final long handle);
numInputRecords(final long handle)273   private static native long numInputRecords(final long handle);
numInputFiles(final long handle)274   private static native long numInputFiles(final long handle);
numInputFilesAtOutputLevel(final long handle)275   private static native long numInputFilesAtOutputLevel(final long handle);
numOutputRecords(final long handle)276   private static native long numOutputRecords(final long handle);
numOutputFiles(final long handle)277   private static native long numOutputFiles(final long handle);
isManualCompaction(final long handle)278   private static native boolean isManualCompaction(final long handle);
totalInputBytes(final long handle)279   private static native long totalInputBytes(final long handle);
totalOutputBytes(final long handle)280   private static native long totalOutputBytes(final long handle);
numRecordsReplaced(final long handle)281   private static native long numRecordsReplaced(final long handle);
totalInputRawKeyBytes(final long handle)282   private static native long totalInputRawKeyBytes(final long handle);
totalInputRawValueBytes(final long handle)283   private static native long totalInputRawValueBytes(final long handle);
numInputDeletionRecords(final long handle)284   private static native long numInputDeletionRecords(final long handle);
numExpiredDeletionRecords(final long handle)285   private static native long numExpiredDeletionRecords(final long handle);
numCorruptKeys(final long handle)286   private static native long numCorruptKeys(final long handle);
fileWriteNanos(final long handle)287   private static native long fileWriteNanos(final long handle);
fileRangeSyncNanos(final long handle)288   private static native long fileRangeSyncNanos(final long handle);
fileFsyncNanos(final long handle)289   private static native long fileFsyncNanos(final long handle);
filePrepareWriteNanos(final long handle)290   private static native long filePrepareWriteNanos(final long handle);
smallestOutputKeyPrefix(final long handle)291   private static native byte[] smallestOutputKeyPrefix(final long handle);
largestOutputKeyPrefix(final long handle)292   private static native byte[] largestOutputKeyPrefix(final long handle);
numSingleDelFallthru(final long handle)293   private static native long numSingleDelFallthru(final long handle);
numSingleDelMismatch(final long handle)294   private static native long numSingleDelMismatch(final long handle);
295 }
296