Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0FFFE200C7A for ; Wed, 12 Apr 2017 05:56:57 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0EAEB160B9B; Wed, 12 Apr 2017 03:56:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A1FA7160BAD for ; Wed, 12 Apr 2017 05:56:54 +0200 (CEST) Received: (qmail 91850 invoked by uid 500); 12 Apr 2017 03:56:53 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 91188 invoked by uid 99); 12 Apr 2017 03:56:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Apr 2017 03:56:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D33D5E0117; Wed, 12 Apr 2017 03:56:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: git-site-role@apache.org To: commits@hbase.apache.org Date: Wed, 12 Apr 2017 03:56:58 -0000 Message-Id: In-Reply-To: <76191be0242a4f03acd3ebd2b32818e7@git.apache.org> References: <76191be0242a4f03acd3ebd2b32818e7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [07/10] hbase-site git commit: Published site at 3aadc675b0f02c3c13be625b40d72fbf6a844964. archived-at: Wed, 12 Apr 2017 03:56:57 -0000 http://git-wip-us.apache.org/repos/asf/hbase-site/blob/3fb12ee1/devapidocs/org/apache/hadoop/hbase/util/ClassSize.html ---------------------------------------------------------------------- diff --git a/devapidocs/org/apache/hadoop/hbase/util/ClassSize.html b/devapidocs/org/apache/hadoop/hbase/util/ClassSize.html index 8d0442a..2675a8f 100644 --- a/devapidocs/org/apache/hadoop/hbase/util/ClassSize.html +++ b/devapidocs/org/apache/hadoop/hbase/util/ClassSize.html @@ -18,7 +18,7 @@ catch(err) { } //--> -var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9}; +var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9}; var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; @@ -110,7 +110,7 @@ var activeTableTab = "activeTableTab";

@InterfaceAudience.Private
-public class ClassSize
+public class ClassSize
 extends Object
Class for determining the "size" of a class, an attempt to calculate the actual bytes that an object of this class will occupy in memory @@ -347,6 +347,10 @@ extends Overhead for TreeMap
+ +private static boolean +USE_UNSAFE_LAYOUT  + @@ -430,6 +434,10 @@ extends sizeOf(byte[] b, int len)  + +static boolean +useUnsafeLayout()  + @@ -467,7 +475,7 @@ extends
  • ARRAY

    -
    public static final int ARRAY
    +
    public static final int ARRAY
    Array overhead
  • @@ -477,7 +485,7 @@ extends
  • ARRAYLIST

    -
    public static final int ARRAYLIST
    +
    public static final int ARRAYLIST
    Overhead for ArrayList(0)
  • @@ -487,7 +495,7 @@ extends
  • LINKEDLIST

    -
    public static final int LINKEDLIST
    +
    public static final int LINKEDLIST
    Overhead for LinkedList(0)
  • @@ -497,7 +505,7 @@ extends
  • LINKEDLIST_ENTRY

    -
    public static final int LINKEDLIST_ENTRY
    +
    public static final int LINKEDLIST_ENTRY
    Overhead for a single entry in LinkedList
  • @@ -507,7 +515,7 @@ extends
  • BYTE_BUFFER

    -
    public static final int BYTE_BUFFER
    +
    public static final int BYTE_BUFFER
    Overhead for ByteBuffer
  • @@ -517,7 +525,7 @@ extends
  • INTEGER

    -
    public static final int INTEGER
    +
    public static final int INTEGER
    Overhead for an Integer
  • @@ -527,7 +535,7 @@ extends
  • MAP_ENTRY

    -
    public static final int MAP_ENTRY
    +
    public static final int MAP_ENTRY
    Overhead for entry in map
  • @@ -537,7 +545,7 @@ extends
  • OBJECT

    -
    public static final int OBJECT
    +
    public static final int OBJECT
    Object overhead is minimum 2 * reference size (8 bytes on 64-bit)
  • @@ -547,7 +555,7 @@ extends
  • REFERENCE

    -
    public static final int REFERENCE
    +
    public static final int REFERENCE
    Reference size is 8 bytes on 64-bit, 4 bytes on 32-bit
  • @@ -557,7 +565,7 @@ extends
  • STRING

    -
    public static final int STRING
    +
    public static final int STRING
    String overhead
  • @@ -567,7 +575,7 @@ extends
  • TREEMAP

    -
    public static final int TREEMAP
    +
    public static final int TREEMAP
    Overhead for TreeMap
  • @@ -577,7 +585,7 @@ extends
  • CONCURRENT_HASHMAP

    -
    public static final int CONCURRENT_HASHMAP
    +
    public static final int CONCURRENT_HASHMAP
    Overhead for ConcurrentHashMap
  • @@ -587,7 +595,7 @@ extends
  • CONCURRENT_HASHMAP_ENTRY

    -
    public static final int CONCURRENT_HASHMAP_ENTRY
    +
    public static final int CONCURRENT_HASHMAP_ENTRY
    Overhead for ConcurrentHashMap.Entry
  • @@ -597,7 +605,7 @@ extends
  • CONCURRENT_HASHMAP_SEGMENT

    -
    public static final int CONCURRENT_HASHMAP_SEGMENT
    +
    public static final int CONCURRENT_HASHMAP_SEGMENT
    Overhead for ConcurrentHashMap.Segment
  • @@ -607,7 +615,7 @@ extends
  • CONCURRENT_SKIPLISTMAP

    -
    public static final int CONCURRENT_SKIPLISTMAP
    +
    public static final int CONCURRENT_SKIPLISTMAP
    Overhead for ConcurrentSkipListMap
  • @@ -617,7 +625,7 @@ extends
  • CONCURRENT_SKIPLISTMAP_ENTRY

    -
    public static final int CONCURRENT_SKIPLISTMAP_ENTRY
    +
    public static final int CONCURRENT_SKIPLISTMAP_ENTRY
    Overhead for ConcurrentSkipListMap Entry
  • @@ -627,7 +635,7 @@ extends
  • CELL_ARRAY_MAP

    -
    public static final int CELL_ARRAY_MAP
    +
    public static final int CELL_ARRAY_MAP
    Overhead for CellArrayMap
  • @@ -637,7 +645,7 @@ extends
  • CELL_ARRAY_MAP_ENTRY

    -
    public static final int CELL_ARRAY_MAP_ENTRY
    +
    public static final int CELL_ARRAY_MAP_ENTRY
    Overhead for Cell Array Entry
  • @@ -647,7 +655,7 @@ extends
  • REENTRANT_LOCK

    -
    public static final int REENTRANT_LOCK
    +
    public static final int REENTRANT_LOCK
    Overhead for ReentrantReadWriteLock
  • @@ -657,7 +665,7 @@ extends
  • ATOMIC_LONG

    -
    public static final int ATOMIC_LONG
    +
    public static final int ATOMIC_LONG
    Overhead for AtomicLong
  • @@ -667,7 +675,7 @@ extends
  • ATOMIC_INTEGER

    -
    public static final int ATOMIC_INTEGER
    +
    public static final int ATOMIC_INTEGER
    Overhead for AtomicInteger
  • @@ -677,7 +685,7 @@ extends
  • ATOMIC_BOOLEAN

    -
    public static final int ATOMIC_BOOLEAN
    +
    public static final int ATOMIC_BOOLEAN
    Overhead for AtomicBoolean
  • @@ -687,7 +695,7 @@ extends
  • ATOMIC_REFERENCE

    -
    public static final int ATOMIC_REFERENCE
    +
    public static final int ATOMIC_REFERENCE
    Overhead for AtomicReference
  • @@ -697,7 +705,7 @@ extends
  • COPYONWRITE_ARRAYSET

    -
    public static final int COPYONWRITE_ARRAYSET
    +
    public static final int COPYONWRITE_ARRAYSET
    Overhead for CopyOnWriteArraySet
  • @@ -707,7 +715,7 @@ extends
  • COPYONWRITE_ARRAYLIST

    -
    public static final int COPYONWRITE_ARRAYLIST
    +
    public static final int COPYONWRITE_ARRAYLIST
    Overhead for CopyOnWriteArrayList
  • @@ -717,7 +725,7 @@ extends
  • TIMERANGE

    -
    public static final int TIMERANGE
    +
    public static final int TIMERANGE
    Overhead for timerange
  • @@ -727,7 +735,7 @@ extends
  • TIMERANGE_TRACKER

    -
    public static final int TIMERANGE_TRACKER
    +
    public static final int TIMERANGE_TRACKER
    Overhead for TimeRangeTracker
  • @@ -737,7 +745,7 @@ extends
  • CELL_SET

    -
    public static final int CELL_SET
    +
    public static final int CELL_SET
    Overhead for CellSkipListSet
  • @@ -747,7 +755,7 @@ extends
  • STORE_SERVICES

    -
    public static final int STORE_SERVICES
    +
    public static final int STORE_SERVICES
  • @@ -756,16 +764,25 @@ extends
  • JDK7

    -
    private static final boolean JDK7
    +
    private static final boolean JDK7
  • - @@ -799,7 +816,16 @@ extends
  • getMemoryLayout

    -
    private static ClassSize.MemoryLayout getMemoryLayout()
    +
    private static ClassSize.MemoryLayout getMemoryLayout()
    +
  • + + + + + @@ -808,7 +834,7 @@ extends
  • getSizeCoefficients

    -
    private static int[] getSizeCoefficients(Class cl,
    +
    private static int[] getSizeCoefficients(Class cl,
                                              boolean debug)
    The estimate of the size of a class instance depends on whether the JVM uses 32 or 64 bit addresses, that is it depends on the size of an object @@ -834,7 +860,7 @@ extends
  • estimateBaseFromCoefficients

    -
    private static long estimateBaseFromCoefficients(int[] coeff,
    +
    private static long estimateBaseFromCoefficients(int[] coeff,
                                                      boolean debug)
    Estimate the static space taken up by a class instance given the coefficients returned by getSizeCoefficients.
    @@ -853,7 +879,7 @@ extends
  • estimateBase

    -
    public static long estimateBase(Class cl,
    +
    public static long estimateBase(Class cl,
                                     boolean debug)
    Estimate the static space taken up by the fields of a class. This includes the space taken up by by references (the pointer) but not by the referenced @@ -875,7 +901,7 @@ extends
  • align

    -
    public static int align(int num)
    +
    public static int align(int num)
    Aligns a number to 8.
    Parameters:
    @@ -891,7 +917,7 @@ extends
  • align

    -
    public static long align(long num)
    +
    public static long align(long num)
    Aligns a number to 8.
    Parameters:
    @@ -907,7 +933,7 @@ extends
  • is32BitJVM

    -
    public static boolean is32BitJVM()
    +
    public static boolean is32BitJVM()
    Determines if we are running in a 32-bit JVM. Some unit tests need to know this too.
  • @@ -918,7 +944,7 @@ extends
  • sizeOf

    -
    public static long sizeOf(byte[] b,
    +
    public static long sizeOf(byte[] b,
                               int len)
  • http://git-wip-us.apache.org/repos/asf/hbase-site/blob/3fb12ee1/devapidocs/org/apache/hadoop/hbase/util/package-tree.html ---------------------------------------------------------------------- diff --git a/devapidocs/org/apache/hadoop/hbase/util/package-tree.html b/devapidocs/org/apache/hadoop/hbase/util/package-tree.html index a3dccc9..23d4070 100644 --- a/devapidocs/org/apache/hadoop/hbase/util/package-tree.html +++ b/devapidocs/org/apache/hadoop/hbase/util/package-tree.html @@ -519,14 +519,14 @@ http://git-wip-us.apache.org/repos/asf/hbase-site/blob/3fb12ee1/devapidocs/src-html/org/apache/hadoop/hbase/Version.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/Version.html b/devapidocs/src-html/org/apache/hadoop/hbase/Version.html index 04549a8..b1d1435 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/Version.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/Version.html @@ -16,11 +16,11 @@ 008@InterfaceAudience.Private 009public class Version { 010 public static final String version = "2.0.0-SNAPSHOT"; -011 public static final String revision = "d7ddc79198679d8c642e7d8ad5141ba518f8d9f3"; +011 public static final String revision = "3aadc675b0f02c3c13be625b40d72fbf6a844964"; 012 public static final String user = "jenkins"; -013 public static final String date = "Wed Apr 12 01:10:58 UTC 2017"; +013 public static final String date = "Wed Apr 12 03:37:14 UTC 2017"; 014 public static final String url = "git://asf920.gq1.ygridcore.net/home/jenkins/jenkins-slave/workspace/hbase_generate_website/hbase"; -015 public static final String srcChecksum = "bc97f2543d573a2ee58f8273c9132a89"; +015 public static final String srcChecksum = "0c5c8fa1337ca2c05e1ebdd7e5cdbd2c"; 016} http://git-wip-us.apache.org/repos/asf/hbase-site/blob/3fb12ee1/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/Segment.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/Segment.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/Segment.html index cdc02b3..7527f43 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/Segment.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/Segment.html @@ -56,309 +56,310 @@ 048@InterfaceAudience.Private 049public abstract class Segment { 050 -051 final static long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT -052 + 5 * ClassSize.REFERENCE // cellSet, comparator, memStoreLAB, size, timeRangeTracker -053 + Bytes.SIZEOF_LONG // minSequenceId -054 + Bytes.SIZEOF_BOOLEAN); // tagsPresent -055 public final static long DEEP_OVERHEAD = FIXED_OVERHEAD + ClassSize.ATOMIC_REFERENCE -056 + ClassSize.CELL_SET + ClassSize.ATOMIC_LONG + ClassSize.TIMERANGE_TRACKER; -057 -058 private AtomicReference<CellSet> cellSet= new AtomicReference<>(); -059 private final CellComparator comparator; -060 protected long minSequenceId; -061 private MemStoreLAB memStoreLAB; -062 // Sum of sizes of all Cells added to this Segment. Cell's heapSize is considered. This is not -063 // including the heap overhead of this class. -064 protected final AtomicLong dataSize; -065 protected final AtomicLong heapSize; -066 protected final TimeRangeTracker timeRangeTracker; -067 protected volatile boolean tagsPresent; -068 -069 // Empty constructor to be used when Segment is used as interface, -070 // and there is no need in true Segments state -071 protected Segment(CellComparator comparator) { -072 this.comparator = comparator; -073 this.dataSize = new AtomicLong(0); -074 this.heapSize = new AtomicLong(0); -075 this.timeRangeTracker = new TimeRangeTracker(); -076 } -077 -078 // This constructor is used to create empty Segments. -079 protected Segment(CellSet cellSet, CellComparator comparator, MemStoreLAB memStoreLAB) { -080 this.cellSet.set(cellSet); -081 this.comparator = comparator; -082 this.minSequenceId = Long.MAX_VALUE; -083 this.memStoreLAB = memStoreLAB; -084 this.dataSize = new AtomicLong(0); -085 this.heapSize = new AtomicLong(0); -086 this.tagsPresent = false; -087 this.timeRangeTracker = new TimeRangeTracker(); -088 } -089 -090 protected Segment(Segment segment) { -091 this.cellSet.set(segment.getCellSet()); -092 this.comparator = segment.getComparator(); -093 this.minSequenceId = segment.getMinSequenceId(); -094 this.memStoreLAB = segment.getMemStoreLAB(); -095 this.dataSize = new AtomicLong(segment.keySize()); -096 this.heapSize = new AtomicLong(segment.heapSize.get()); -097 this.tagsPresent = segment.isTagsPresent(); -098 this.timeRangeTracker = segment.getTimeRangeTracker(); -099 } -100 -101 /** -102 * Creates the scanner for the given read point -103 * @return a scanner for the given read point -104 */ -105 protected KeyValueScanner getScanner(long readPoint) { -106 return new SegmentScanner(this, readPoint); -107 } -108 -109 /** -110 * Creates the scanner for the given read point, and a specific order in a list -111 * @return a scanner for the given read point -112 */ -113 public KeyValueScanner getScanner(long readPoint, long order) { -114 return new SegmentScanner(this, readPoint, order); -115 } -116 -117 public List<KeyValueScanner> getScanners(long readPoint, long order) { -118 return Collections.singletonList(new SegmentScanner(this, readPoint, order)); -119 } -120 -121 /** -122 * @return whether the segment has any cells -123 */ -124 public boolean isEmpty() { -125 return getCellSet().isEmpty(); -126 } -127 -128 /** -129 * @return number of cells in segment -130 */ -131 public int getCellsCount() { -132 return getCellSet().size(); -133 } -134 -135 /** -136 * @return the first cell in the segment that has equal or greater key than the given cell -137 */ -138 public Cell getFirstAfter(Cell cell) { -139 SortedSet<Cell> snTailSet = tailSet(cell); -140 if (!snTailSet.isEmpty()) { -141 return snTailSet.first(); -142 } -143 return null; -144 } -145 -146 /** -147 * Closing a segment before it is being discarded -148 */ -149 public void close() { -150 if (this.memStoreLAB != null) { -151 this.memStoreLAB.close(); -152 } -153 // do not set MSLab to null as scanners may still be reading the data here and need to decrease -154 // the counter when they finish -155 } -156 -157 /** -158 * If the segment has a memory allocator the cell is being cloned to this space, and returned; -159 * otherwise the given cell is returned -160 * @return either the given cell or its clone -161 */ -162 public Cell maybeCloneWithAllocator(Cell cell) { -163 if (this.memStoreLAB == null) { -164 return cell; -165 } -166 -167 Cell cellFromMslab = this.memStoreLAB.copyCellInto(cell); -168 return (cellFromMslab != null) ? cellFromMslab : cell; -169 } -170 -171 /** -172 * Get cell length after serialized in {@link KeyValue} -173 */ -174 @VisibleForTesting -175 static int getCellLength(Cell cell) { -176 return KeyValueUtil.length(cell); -177 } -178 -179 public abstract boolean shouldSeek(Scan scan, long oldestUnexpiredTS); -180 -181 public abstract long getMinTimestamp(); -182 -183 public boolean isTagsPresent() { -184 return tagsPresent; -185 } -186 -187 public void incScannerCount() { -188 if (this.memStoreLAB != null) { -189 this.memStoreLAB.incScannerCount(); -190 } -191 } -192 -193 public void decScannerCount() { -194 if (this.memStoreLAB != null) { -195 this.memStoreLAB.decScannerCount(); -196 } -197 } -198 -199 /** -200 * Setting the CellSet of the segment - used only for flat immutable segment for setting -201 * immutable CellSet after its creation in immutable segment constructor -202 * @return this object -203 */ -204 -205 protected Segment setCellSet(CellSet cellSetOld, CellSet cellSetNew) { -206 this.cellSet.compareAndSet(cellSetOld, cellSetNew); -207 return this; -208 } -209 -210 /** -211 * @return Sum of all cell's size. -212 */ -213 public long keySize() { -214 return this.dataSize.get(); -215 } -216 -217 /** -218 * @return The heap size of this segment. -219 */ -220 public long heapSize() { -221 return this.heapSize.get(); -222 } -223 -224 /** -225 * Updates the size counters of the segment by the given delta -226 */ -227 //TODO -228 protected void incSize(long delta, long heapOverhead) { -229 this.dataSize.addAndGet(delta); -230 this.heapSize.addAndGet(heapOverhead); -231 } -232 -233 public long getMinSequenceId() { -234 return minSequenceId; -235 } -236 -237 public TimeRangeTracker getTimeRangeTracker() { -238 return this.timeRangeTracker; -239 } -240 -241 //*** Methods for SegmentsScanner -242 public Cell last() { -243 return getCellSet().last(); -244 } -245 -246 public Iterator<Cell> iterator() { -247 return getCellSet().iterator(); -248 } -249 -250 public SortedSet<Cell> headSet(Cell firstKeyOnRow) { -251 return getCellSet().headSet(firstKeyOnRow); -252 } -253 -254 public int compare(Cell left, Cell right) { -255 return getComparator().compare(left, right); -256 } -257 -258 public int compareRows(Cell left, Cell right) { -259 return getComparator().compareRows(left, right); -260 } -261 -262 /** -263 * @return a set of all cells in the segment -264 */ -265 protected CellSet getCellSet() { -266 return cellSet.get(); -267 } -268 -269 /** -270 * Returns the Cell comparator used by this segment -271 * @return the Cell comparator used by this segment -272 */ -273 protected CellComparator getComparator() { -274 return comparator; -275 } -276 -277 protected void internalAdd(Cell cell, boolean mslabUsed, MemstoreSize memstoreSize) { -278 boolean succ = getCellSet().add(cell); -279 updateMetaInfo(cell, succ, mslabUsed, memstoreSize); -280 } -281 -282 protected void updateMetaInfo(Cell cellToAdd, boolean succ, boolean mslabUsed, -283 MemstoreSize memstoreSize) { -284 long cellSize = 0; -285 // If there's already a same cell in the CellSet and we are using MSLAB, we must count in the -286 // MSLAB allocation size as well, or else there will be memory leak (occupied heap size larger -287 // than the counted number) -288 if (succ || mslabUsed) { -289 cellSize = getCellLength(cellToAdd); -290 } -291 long heapSize = heapSizeChange(cellToAdd, succ); -292 incSize(cellSize, heapSize); -293 if (memstoreSize != null) { -294 memstoreSize.incMemstoreSize(cellSize, heapSize); -295 } -296 getTimeRangeTracker().includeTimestamp(cellToAdd); -297 minSequenceId = Math.min(minSequenceId, cellToAdd.getSequenceId()); -298 // In no tags case this NoTagsKeyValue.getTagsLength() is a cheap call. -299 // When we use ACL CP or Visibility CP which deals with Tags during -300 // mutation, the TagRewriteCell.getTagsLength() is a cheaper call. We do not -301 // parse the byte[] to identify the tags length. -302 if (cellToAdd.getTagsLength() > 0) { -303 tagsPresent = true; -304 } -305 } -306 -307 /** -308 * @return The increase in heap size because of this cell addition. This includes this cell POJO's -309 * heap size itself and additional overhead because of addition on to CSLM. -310 */ -311 protected long heapSizeChange(Cell cell, boolean succ) { -312 if (succ) { -313 return ClassSize -314 .align(ClassSize.CONCURRENT_SKIPLISTMAP_ENTRY + CellUtil.estimatedHeapSizeOf(cell)); -315 } -316 return 0; -317 } -318 -319 /** -320 * Returns a subset of the segment cell set, which starts with the given cell -321 * @param firstCell a cell in the segment -322 * @return a subset of the segment cell set, which starts with the given cell -323 */ -324 protected SortedSet<Cell> tailSet(Cell firstCell) { -325 return getCellSet().tailSet(firstCell); -326 } -327 -328 @VisibleForTesting -329 MemStoreLAB getMemStoreLAB() { -330 return memStoreLAB; -331 } -332 -333 // Debug methods -334 /** -335 * Dumps all cells of the segment into the given log -336 */ -337 void dump(Log log) { -338 for (Cell cell: getCellSet()) { -339 log.debug(cell); -340 } -341 } -342 -343 @Override -344 public String toString() { -345 String res = "Store segment of type "+this.getClass().getName()+"; "; -346 res += "isEmpty "+(isEmpty()?"yes":"no")+"; "; -347 res += "cellsCount "+getCellsCount()+"; "; -348 res += "cellsSize "+keySize()+"; "; -349 res += "totalHeapSize "+heapSize()+"; "; -350 res += "Min ts "+getMinTimestamp()+"; "; -351 return res; -352 } -353} +051 public final static long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT +052 + 6 * ClassSize.REFERENCE // cellSet, comparator, memStoreLAB, dataSize, +053 // heapSize, and timeRangeTracker +054 + Bytes.SIZEOF_LONG // minSequenceId +055 + Bytes.SIZEOF_BOOLEAN); // tagsPresent +056 public final static long DEEP_OVERHEAD = FIXED_OVERHEAD + ClassSize.ATOMIC_REFERENCE +057 + ClassSize.CELL_SET + 2 * ClassSize.ATOMIC_LONG + ClassSize.TIMERANGE_TRACKER; +058 +059 private AtomicReference<CellSet> cellSet= new AtomicReference<>(); +060 private final CellComparator comparator; +061 protected long minSequenceId; +062 private MemStoreLAB memStoreLAB; +063 // Sum of sizes of all Cells added to this Segment. Cell's heapSize is considered. This is not +064 // including the heap overhead of this class. +065 protected final AtomicLong dataSize; +066 protected final AtomicLong heapSize; +067 protected final TimeRangeTracker timeRangeTracker; +068 protected volatile boolean tagsPresent; +069 +070 // Empty constructor to be used when Segment is used as interface, +071 // and there is no need in true Segments state +072 protected Segment(CellComparator comparator) { +073 this.comparator = comparator; +074 this.dataSize = new AtomicLong(0); +075 this.heapSize = new AtomicLong(0); +076 this.timeRangeTracker = new TimeRangeTracker(); +077 } +078 +079 // This constructor is used to create empty Segments. +080 protected Segment(CellSet cellSet, CellComparator comparator, MemStoreLAB memStoreLAB) { +081 this.cellSet.set(cellSet); +082 this.comparator = comparator; +083 this.minSequenceId = Long.MAX_VALUE; +084 this.memStoreLAB = memStoreLAB; +085 this.dataSize = new AtomicLong(0); +086 this.heapSize = new AtomicLong(0); +087 this.tagsPresent = false; +088 this.timeRangeTracker = new TimeRangeTracker(); +089 } +090 +091 protected Segment(Segment segment) { +092 this.cellSet.set(segment.getCellSet()); +093 this.comparator = segment.getComparator(); +094 this.minSequenceId = segment.getMinSequenceId(); +095 this.memStoreLAB = segment.getMemStoreLAB(); +096 this.dataSize = new AtomicLong(segment.keySize()); +097 this.heapSize = new AtomicLong(segment.heapSize.get()); +098 this.tagsPresent = segment.isTagsPresent(); +099 this.timeRangeTracker = segment.getTimeRangeTracker(); +100 } +101 +102 /** +103 * Creates the scanner for the given read point +104 * @return a scanner for the given read point +105 */ +106 protected KeyValueScanner getScanner(long readPoint) { +107 return new SegmentScanner(this, readPoint); +108 } +109 +110 /** +111 * Creates the scanner for the given read point, and a specific order in a list +112 * @return a scanner for the given read point +113 */ +114 public KeyValueScanner getScanner(long readPoint, long order) { +115 return new SegmentScanner(this, readPoint, order); +116 } +117 +118 public List<KeyValueScanner> getScanners(long readPoint, long order) { +119 return Collections.singletonList(new SegmentScanner(this, readPoint, order)); +120 } +121 +122 /** +123 * @return whether the segment has any cells +124 */ +125 public boolean isEmpty() { +126 return getCellSet().isEmpty(); +127 } +128 +129 /** +130 * @return number of cells in segment +131 */ +132 public int getCellsCount() { +133 return getCellSet().size(); +134 } +135 +136 /** +137 * @return the first cell in the segment that has equal or greater key than the given cell +138 */ +139 public Cell getFirstAfter(Cell cell) { +140 SortedSet<Cell> snTailSet = tailSet(cell); +141 if (!snTailSet.isEmpty()) { +142 return snTailSet.first(); +143 } +144 return null; +145 } +146 +147 /** +148 * Closing a segment before it is being discarded +149 */ +150 public void close() { +151 if (this.memStoreLAB != null) { +152 this.memStoreLAB.close(); +153 } +154 // do not set MSLab to null as scanners may still be reading the data here and need to decrease +155 // the counter when they finish +156 } +157 +158 /** +159 * If the segment has a memory allocator the cell is being cloned to this space, and returned; +160 * otherwise the given cell is returned +161 * @return either the given cell or its clone +162 */ +163 public Cell maybeCloneWithAllocator(Cell cell) { +164 if (this.memStoreLAB == null) { +165 return cell; +166 } +167 +168 Cell cellFromMslab = this.memStoreLAB.copyCellInto(cell); +169 return (cellFromMslab != null) ? cellFromMslab : cell; +170 } +171 +172 /** +173 * Get cell length after serialized in {@link KeyValue} +174 */ +175 @VisibleForTesting +176 static int getCellLength(Cell cell) { +177 return KeyValueUtil.length(cell); +178 } +179 +180 public abstract boolean shouldSeek(Scan scan, long oldestUnexpiredTS); +181 +182 public abstract long getMinTimestamp(); +183 +184 public boolean isTagsPresent() { +185 return tagsPresent; +186 } +187 +188 public void incScannerCount() { +189 if (this.memStoreLAB != null) { +190 this.memStoreLAB.incScannerCount(); +191 } +192 } +193 +194 public void decScannerCount() { +195 if (this.memStoreLAB != null) { +196 this.memStoreLAB.decScannerCount(); +197 } +198 } +199 +200 /** +201 * Setting the CellSet of the segment - used only for flat immutable segment for setting +202 * immutable CellSet after its creation in immutable segment constructor +203 * @return this object +204 */ +205 +206 protected Segment setCellSet(CellSet cellSetOld, CellSet cellSetNew) { +207 this.cellSet.compareAndSet(cellSetOld, cellSetNew); +208 return this; +209 } +210 +211 /** +212 * @return Sum of all cell's size. +213 */ +214 public long keySize() { +215 return this.dataSize.get(); +216 } +217 +218 /** +219 * @return The heap size of this segment. +220 */ +221 public long heapSize() { +222 return this.heapSize.get(); +223 } +224 +225 /** +226 * Updates the size counters of the segment by the given delta +227 */ +228 //TODO +229 protected void incSize(long delta, long heapOverhead) { +230 this.dataSize.addAndGet(delta); +231 this.heapSize.addAndGet(heapOverhead); +232 } +233 +234 public long getMinSequenceId() { +235 return minSequenceId; +236 } +237 +238 public TimeRangeTracker getTimeRangeTracker() { +239 return this.timeRangeTracker; +240 } +241 +242 //*** Methods for SegmentsScanner +243 public Cell last() { +244 return getCellSet().last(); +245 } +246 +247 public Iterator<Cell> iterator() { +248 return getCellSet().iterator(); +249 } +250 +251 public SortedSet<Cell> headSet(Cell firstKeyOnRow) { +252 return getCellSet().headSet(firstKeyOnRow); +253 } +254 +255 public int compare(Cell left, Cell right) { +256 return getComparator().compare(left, right); +257 } +258 +259 public int compareRows(Cell left, Cell right) { +260 return getComparator().compareRows(left, right); +261 } +262 +263 /** +264 * @return a set of all cells in the segment +265 */ +266 protected CellSet getCellSet() { +267 return cellSet.get(); +268 } +269 +270 /** +271 * Returns the Cell comparator used by this segment +272 * @return the Cell comparator used by this segment +273 */ +274 protected CellComparator getComparator() { +275 return comparator; +276 } +277 +278 protected void internalAdd(Cell cell, boolean mslabUsed, MemstoreSize memstoreSize) { +279 boolean succ = getCellSet().add(cell); +280 updateMetaInfo(cell, succ, mslabUsed, memstoreSize); +281 } +282 +283 protected void updateMetaInfo(Cell cellToAdd, boolean succ, boolean mslabUsed, +284 MemstoreSize memstoreSize) { +285 long cellSize = 0; +286 // If there's already a same cell in the CellSet and we are using MSLAB, we must count in the +287 // MSLAB allocation size as well, or else there will be memory leak (occupied heap size larger +288 // than the counted number) +289 if (succ || mslabUsed) { +290 cellSize = getCellLength(cellToAdd); +291 } +292 long heapSize = heapSizeChange(cellToAdd, succ); +293 incSize(cellSize, heapSize); +294 if (memstoreSize != null) { +295 memstoreSize.incMemstoreSize(cellSize, heapSize); +296 } +297 getTimeRangeTracker().includeTimestamp(cellToAdd); +298 minSequenceId = Math.min(minSequenceId, cellToAdd.getSequenceId()); +299 // In no tags case this NoTagsKeyValue.getTagsLength() is a cheap call. +300 // When we use ACL CP or Visibility CP which deals with Tags during +301 // mutation, the TagRewriteCell.getTagsLength() is a cheaper call. We do not +302 // parse the byte[] to identify the tags length. +303 if (cellToAdd.getTagsLength() > 0) { +304 tagsPresent = true; +305 } +306 } +307 +308 /** +309 * @return The increase in heap size because of this cell addition. This includes this cell POJO's +310 * heap size itself and additional overhead because of addition on to CSLM. +311 */ +312 protected long heapSizeChange(Cell cell, boolean succ) { +313 if (succ) { +314 return ClassSize +315 .align(ClassSize.CONCURRENT_SKIPLISTMAP_ENTRY + CellUtil.estimatedHeapSizeOf(cell)); +316 } +317 return 0; +318 } +319 +320 /** +321 * Returns a subset of the segment cell set, which starts with the given cell +322 * @param firstCell a cell in the segment +323 * @return a subset of the segment cell set, which starts with the given cell +324 */ +325 protected SortedSet<Cell> tailSet(Cell firstCell) { +326 return getCellSet().tailSet(firstCell); +327 } +328 +329 @VisibleForTesting +330 MemStoreLAB getMemStoreLAB() { +331 return memStoreLAB; +332 } +333 +334 // Debug methods +335 /** +336 * Dumps all cells of the segment into the given log +337 */ +338 void dump(Log log) { +339 for (Cell cell: getCellSet()) { +340 log.debug(cell); +341 } +342 } +343 +344 @Override +345 public String toString() { +346 String res = "Store segment of type "+this.getClass().getName()+"; "; +347 res += "isEmpty "+(isEmpty()?"yes":"no")+"; "; +348 res += "cellsCount "+getCellsCount()+"; "; +349 res += "cellsSize "+keySize()+"; "; +350 res += "totalHeapSize "+heapSize()+"; "; +351 res += "Min ts "+getMinTimestamp()+"; "; +352 return res; +353 } +354}