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 * The metadata that describes a SST file. 10 */ 11 public class SstFileMetaData { 12 private final String fileName; 13 private final String path; 14 private final long size; 15 private final long smallestSeqno; 16 private final long largestSeqno; 17 private final byte[] smallestKey; 18 private final byte[] largestKey; 19 private final long numReadsSampled; 20 private final boolean beingCompacted; 21 private final long numEntries; 22 private final long numDeletions; 23 24 /** 25 * Called from JNI C++ 26 * 27 * @param fileName the file name 28 * @param path the file path 29 * @param size the size of the file 30 * @param smallestSeqno the smallest sequence number 31 * @param largestSeqno the largest sequence number 32 * @param smallestKey the smallest key 33 * @param largestKey the largest key 34 * @param numReadsSampled the number of reads sampled 35 * @param beingCompacted true if the file is being compacted, false otherwise 36 * @param numEntries the number of entries 37 * @param numDeletions the number of deletions 38 */ SstFileMetaData( final String fileName, final String path, final long size, final long smallestSeqno, final long largestSeqno, final byte[] smallestKey, final byte[] largestKey, final long numReadsSampled, final boolean beingCompacted, final long numEntries, final long numDeletions)39 protected SstFileMetaData( 40 final String fileName, 41 final String path, 42 final long size, 43 final long smallestSeqno, 44 final long largestSeqno, 45 final byte[] smallestKey, 46 final byte[] largestKey, 47 final long numReadsSampled, 48 final boolean beingCompacted, 49 final long numEntries, 50 final long numDeletions) { 51 this.fileName = fileName; 52 this.path = path; 53 this.size = size; 54 this.smallestSeqno = smallestSeqno; 55 this.largestSeqno = largestSeqno; 56 this.smallestKey = smallestKey; 57 this.largestKey = largestKey; 58 this.numReadsSampled = numReadsSampled; 59 this.beingCompacted = beingCompacted; 60 this.numEntries = numEntries; 61 this.numDeletions = numDeletions; 62 } 63 64 /** 65 * Get the name of the file. 66 * 67 * @return the name of the file. 68 */ fileName()69 public String fileName() { 70 return fileName; 71 } 72 73 /** 74 * Get the full path where the file locates. 75 * 76 * @return the full path 77 */ path()78 public String path() { 79 return path; 80 } 81 82 /** 83 * Get the file size in bytes. 84 * 85 * @return file size 86 */ size()87 public long size() { 88 return size; 89 } 90 91 /** 92 * Get the smallest sequence number in file. 93 * 94 * @return the smallest sequence number 95 */ smallestSeqno()96 public long smallestSeqno() { 97 return smallestSeqno; 98 } 99 100 /** 101 * Get the largest sequence number in file. 102 * 103 * @return the largest sequence number 104 */ largestSeqno()105 public long largestSeqno() { 106 return largestSeqno; 107 } 108 109 /** 110 * Get the smallest user defined key in the file. 111 * 112 * @return the smallest user defined key 113 */ smallestKey()114 public byte[] smallestKey() { 115 return smallestKey; 116 } 117 118 /** 119 * Get the largest user defined key in the file. 120 * 121 * @return the largest user defined key 122 */ largestKey()123 public byte[] largestKey() { 124 return largestKey; 125 } 126 127 /** 128 * Get the number of times the file has been read. 129 * 130 * @return the number of times the file has been read 131 */ numReadsSampled()132 public long numReadsSampled() { 133 return numReadsSampled; 134 } 135 136 /** 137 * Returns true if the file is currently being compacted. 138 * 139 * @return true if the file is currently being compacted, false otherwise. 140 */ beingCompacted()141 public boolean beingCompacted() { 142 return beingCompacted; 143 } 144 145 /** 146 * Get the number of entries. 147 * 148 * @return the number of entries. 149 */ numEntries()150 public long numEntries() { 151 return numEntries; 152 } 153 154 /** 155 * Get the number of deletions. 156 * 157 * @return the number of deletions. 158 */ numDeletions()159 public long numDeletions() { 160 return numDeletions; 161 } 162 } 163