static long calcEstimatedSize(Result rs) { long estimatedHeapSizeOfResult = 0; // We don't make Iterator here for (Cell cell : rs.rawCells()) { estimatedHeapSizeOfResult += PrivateCellUtil.estimatedSizeOfCell(cell); } return estimatedHeapSizeOfResult; }
/** * Get total size of raw cells * @param result * @return Total size. */ public static long getTotalSizeOfCells(Result result) { long size = 0; if (result.isEmpty()) { return size; } for (Cell c : result.rawCells()) { size += PrivateCellUtil.estimatedSizeOfCell(c); } return size; }
/** * @return Calculate what Mutation adds to class heap size. */ @Override public long heapSize() { long heapsize = MUTATION_OVERHEAD; // Adding row heapsize += ClassSize.align(ClassSize.ARRAY + this.row.length); // Adding map overhead heapsize += ClassSize.align(this.familyMap.size() * ClassSize.MAP_ENTRY); for(Map.Entry<byte [], List<Cell>> entry : this.familyMap.entrySet()) { //Adding key overhead heapsize += ClassSize.align(ClassSize.ARRAY + entry.getKey().length); //This part is kinds tricky since the JVM can reuse references if you //store the same value, but have a good match with SizeOf at the moment //Adding value overhead heapsize += ClassSize.align(ClassSize.ARRAYLIST); int size = entry.getValue().size(); heapsize += ClassSize.align(ClassSize.ARRAY + size * ClassSize.REFERENCE); for(Cell cell : entry.getValue()) { heapsize += PrivateCellUtil.estimatedSizeOfCell(cell); } } heapsize += getAttributeSize(); heapsize += extraHeapSize(); return ClassSize.align(heapsize); }
@Override public long heapSize() { return PrivateCellUtil.estimatedSizeOfCell(cell); }
@Override public long heapSize() { return PrivateCellUtil.estimatedSizeOfCell(cell); }
@Override public long heapSize() { long sum = HEAP_SIZE_OVERHEAD + estimatedSizeOfCell(cell); if (this.tags != null) { sum += ClassSize.sizeOf(this.tags); } return sum; }
static long calcEstimatedSize(Result rs) { long estimatedHeapSizeOfResult = 0; // We don't make Iterator here for (Cell cell : rs.rawCells()) { estimatedHeapSizeOfResult += PrivateCellUtil.estimatedSizeOfCell(cell); } return estimatedHeapSizeOfResult; }
@Override public long heapSize() { long sum = HEAP_SIZE_OVERHEAD + estimatedSizeOfCell(cell); if (this.tags != null) { sum += ClassSize.sizeOf(this.tags); } return sum; }
@Override public long heapSize() { long sum = HEAP_SIZE_OVERHEAD + estimatedSizeOfCell(cell); // this.tags is on heap byte[] if (this.tags != null) { sum += ClassSize.sizeOf(this.tags); } return sum; }
@Override public long heapSize() { long sum = HEAP_SIZE_OVERHEAD + estimatedSizeOfCell(cell); // this.tags is on heap byte[] if (this.tags != null) { sum += ClassSize.sizeOf(this.tags); } return sum; }
/** * Get total size of raw cells * @param result * @return Total size. */ public static long getTotalSizeOfCells(Result result) { long size = 0; if (result.isEmpty()) { return size; } for (Cell c : result.rawCells()) { size += PrivateCellUtil.estimatedSizeOfCell(c); } return size; }
/** * @return Calculate what Mutation adds to class heap size. */ @Override public long heapSize() { long heapsize = MUTATION_OVERHEAD; // Adding row heapsize += ClassSize.align(ClassSize.ARRAY + this.row.length); // Adding map overhead heapsize += ClassSize.align(this.familyMap.size() * ClassSize.MAP_ENTRY); for(Map.Entry<byte [], List<Cell>> entry : this.familyMap.entrySet()) { //Adding key overhead heapsize += ClassSize.align(ClassSize.ARRAY + entry.getKey().length); //This part is kinds tricky since the JVM can reuse references if you //store the same value, but have a good match with SizeOf at the moment //Adding value overhead heapsize += ClassSize.align(ClassSize.ARRAYLIST); int size = entry.getValue().size(); heapsize += ClassSize.align(ClassSize.ARRAY + size * ClassSize.REFERENCE); for(Cell cell : entry.getValue()) { heapsize += PrivateCellUtil.estimatedSizeOfCell(cell); } } heapsize += getAttributeSize(); heapsize += extraHeapSize(); return ClassSize.align(heapsize); }
/** * @return The approximate heap size of a cell in the test table. All cells should have * approximately the same heap size, so the value is cached to avoid repeating the * calculation * @throws Exception */ private long getCellHeapSize() throws Exception { if (CELL_HEAP_SIZE == -1) { // Do a partial scan that will return a single result with a single cell Scan scan = new Scan(); scan.setMaxResultSize(2); scan.setAllowPartialResults(true); ResultScanner scanner = TABLE.getScanner(scan); Result result = scanner.next(); assertTrue(result != null); assertTrue(result.rawCells() != null); assertTrue(result.rawCells().length == 1); // Estimate the cell heap size. One difference is that on server side, the KV Heap size is // estimated differently in case the cell is backed up by MSLAB byte[] (no overhead for // backing array). Thus below calculation is a bit brittle. CELL_HEAP_SIZE = PrivateCellUtil.estimatedSizeOfCell(result.rawCells()[0]) - (ClassSize.ARRAY+3); if (LOG.isInfoEnabled()) LOG.info("Cell heap size: " + CELL_HEAP_SIZE); scanner.close(); } return CELL_HEAP_SIZE; }
/** * @return The approximate heap size of a cell in the test table. All cells should have * approximately the same heap size, so the value is cached to avoid repeating the * calculation * @throws Exception */ private long getCellHeapSize() throws Exception { if (CELL_HEAP_SIZE == -1) { // Do a partial scan that will return a single result with a single cell Scan scan = new Scan(); scan.setMaxResultSize(1); scan.setAllowPartialResults(true); ResultScanner scanner = TABLE.getScanner(scan); Result result = scanner.next(); assertTrue(result != null); assertTrue(result.rawCells() != null); assertTrue(result.rawCells().length == 1); CELL_HEAP_SIZE = PrivateCellUtil.estimatedSizeOfCell(result.rawCells()[0]); scanner.close(); } return CELL_HEAP_SIZE; }