public long estimatedSerializedSizeOf() { long ret = 0; for (Cell cell: cells) { ret += PrivateCellUtil.estimatedSerializedSizeOf(cell); } return ret; }
@Override public int getSerializedSize(boolean withTags) { return PrivateCellUtil.estimatedSerializedSizeOf(cell) - Bytes.SIZEOF_INT; }
/** * Estimate based on keyvalue's serialization format in the RPC layer. Note that there is an extra * SIZEOF_INT added to the size here that indicates the actual length of the cell for cases where * cell's are serialized in a contiguous format (For eg in RPCs). * @param cell * @return Estimate of the <code>cell</code> size in bytes plus an extra SIZEOF_INT indicating the * actual cell length. * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. */ @Deprecated public static int estimatedSerializedSizeOf(final Cell cell) { return PrivateCellUtil.estimatedSerializedSizeOf(cell); }
@Override public void serialize(Cell kv) throws IOException { dos.writeInt(PrivateCellUtil.estimatedSerializedSizeOf(kv) - Bytes.SIZEOF_INT); PrivateCellUtil.writeCell(kv, dos, true); } }
static void updateResultsMetrics(ScanMetrics scanMetrics, Result[] rrs, boolean isRegionServerRemote) { if (scanMetrics == null || rrs == null || rrs.length == 0) { return; } long resultSize = 0; for (Result rr : rrs) { for (Cell cell : rr.rawCells()) { resultSize += PrivateCellUtil.estimatedSerializedSizeOf(cell); } } scanMetrics.countOfBytesInResults.addAndGet(resultSize); if (isRegionServerRemote) { scanMetrics.countOfBytesInRemoteResults.addAndGet(resultSize); } }
@Override public Result next() throws IOException { values.clear(); scanner.nextRaw(values); if (values.isEmpty()) { //we are done return null; } Result result = Result.create(values); if (this.scanMetrics != null) { long resultSize = 0; for (Cell cell : values) { resultSize += PrivateCellUtil.estimatedSerializedSizeOf(cell); } this.scanMetrics.countOfBytesInResults.addAndGet(resultSize); this.scanMetrics.countOfRowsScanned.incrementAndGet(); } return result; }
private void checkCellSizeLimit(final HRegion r, final Mutation m) throws IOException { if (r.maxCellSize > 0) { CellScanner cells = m.cellScanner(); while (cells.advance()) { int size = PrivateCellUtil.estimatedSerializedSizeOf(cells.current()); if (size > r.maxCellSize) { String msg = "Cell with size " + size + " exceeds limit of " + r.maxCellSize + " bytes"; if (LOG.isDebugEnabled()) { LOG.debug(msg); } throw new DoNotRetryIOException(msg); } } } }
private long postAppend(final Entry e, final long elapsedTime) throws IOException { long len = 0; if (!listeners.isEmpty()) { for (Cell cell : e.getEdit().getCells()) { len += PrivateCellUtil.estimatedSerializedSizeOf(cell); } for (WALActionsListener listener : listeners) { listener.postAppend(len, elapsedTime, e.getKey(), e.getEdit()); } } return len; }
@Override public long append(RegionInfo info, WALKeyImpl key, WALEdit edits, boolean inMemstore) throws IOException { WriteEntry writeEntry = key.getMvcc().begin(); if (!edits.isReplay()) { for (Cell cell : edits.getCells()) { PrivateCellUtil.setSequenceId(cell, writeEntry.getWriteNumber()); } } key.setWriteEntry(writeEntry); if (!this.listeners.isEmpty()) { final long start = System.nanoTime(); long len = 0; for (Cell cell : edits.getCells()) { len += PrivateCellUtil.estimatedSerializedSizeOf(cell); } final long elapsed = (System.nanoTime() - start) / 1000000L; for (WALActionsListener listener : this.listeners) { listener.postAppend(len, elapsed, key, edits); } } return -1; }
static CellScanner getSizedCellScanner(final Cell[] cells) { int size = -1; for (Cell cell : cells) { size += PrivateCellUtil.estimatedSerializedSizeOf(cell); } final int totalSize = ClassSize.align(size); final CellScanner cellScanner = CellUtil.createCellScanner(cells); return new SizedCellScanner() { @Override public long heapSize() { return totalSize; } @Override public Cell current() { return cellScanner.current(); } @Override public boolean advance() throws IOException { return cellScanner.advance(); } }; }
@Test public void testScanMetrics() throws Exception { Pair<List<Result>, ScanMetrics> pair = method.scan(new Scan().setScanMetricsEnabled(true)); List<Result> results = pair.getFirst(); assertEquals(3, results.size()); long bytes = results.stream().flatMap(r -> Arrays.asList(r.rawCells()).stream()) .mapToLong(c -> PrivateCellUtil.estimatedSerializedSizeOf(c)).sum(); ScanMetrics scanMetrics = pair.getSecond(); assertEquals(NUM_REGIONS, scanMetrics.countOfRegions.get()); assertEquals(bytes, scanMetrics.countOfBytesInResults.get()); assertEquals(NUM_REGIONS, scanMetrics.countOfRPCcalls.get()); // also assert a server side metric to ensure that we have published them into the client side // metrics. assertEquals(3, scanMetrics.countOfRowsScanned.get()); } }
if (context != null && r != null && !r.isEmpty()) { for (Cell c : r.rawCells()) { context.incrementResponseCellSize(PrivateCellUtil.estimatedSerializedSizeOf(c));
Cell c = scanner.peek(); if (c != null) { totalScannersSoughtBytes += PrivateCellUtil.estimatedSerializedSizeOf(c);
size += PrivateCellUtil.estimatedSerializedSizeOf(cell);
for (Result result : scanner.next(1)) { for (Cell cell: result.listCells()) { numBytes += PrivateCellUtil.estimatedSerializedSizeOf(cell); for (Result result : scanner.next(1)) { for (Cell cell: result.listCells()) { numBytes += PrivateCellUtil.estimatedSerializedSizeOf(cell);
scannerContext.incrementSizeProgress(PrivateCellUtil.estimatedSerializedSizeOf(cell), cell.heapSize());
static void updateResultsMetrics(ScanMetrics scanMetrics, Result[] rrs, boolean isRegionServerRemote) { if (scanMetrics == null || rrs == null || rrs.length == 0) { return; } long resultSize = 0; for (Result rr : rrs) { for (Cell cell : rr.rawCells()) { resultSize += PrivateCellUtil.estimatedSerializedSizeOf(cell); } } scanMetrics.countOfBytesInResults.addAndGet(resultSize); if (isRegionServerRemote) { scanMetrics.countOfBytesInRemoteResults.addAndGet(resultSize); } }
int cellSize = PrivateCellUtil.estimatedSerializedSizeOf(cell); bytesRead += cellSize; if (scanUsePread && readType == Scan.ReadType.DEFAULT &&
static CellScanner getSizedCellScanner(final Cell[] cells) { int size = -1; for (Cell cell : cells) { size += PrivateCellUtil.estimatedSerializedSizeOf(cell); } final int totalSize = ClassSize.align(size); final CellScanner cellScanner = CellUtil.createCellScanner(cells); return new SizedCellScanner() { @Override public long heapSize() { return totalSize; } @Override public Cell current() { return cellScanner.current(); } @Override public boolean advance() throws IOException { return cellScanner.advance(); } }; }
@Override public int getSerializedSize(boolean withTags) { return PrivateCellUtil.estimatedSerializedSizeOf(cell) - Bytes.SIZEOF_INT; }