/** * If the segment has a memory allocator the cell is being cloned to this space, and returned; * otherwise the given cell is returned * * When a cell's size is too big (bigger than maxAlloc), it is not allocated on MSLAB. * Since the process of flattening to CellChunkMap assumes that all cells * are allocated on MSLAB, during this process, the input parameter * forceCloneOfBigCell is set to 'true' and the cell is copied into MSLAB. * * @return either the given cell or its clone */ public Cell maybeCloneWithAllocator(Cell cell, boolean forceCloneOfBigCell) { if (this.memStoreLAB == null) { return cell; } Cell cellFromMslab; if (forceCloneOfBigCell) { cellFromMslab = this.memStoreLAB.forceCopyOfBigCellInto(cell); } else { cellFromMslab = this.memStoreLAB.copyCellInto(cell); } return (cellFromMslab != null) ? cellFromMslab : cell; }
@Override public void run() { MemStoreLAB memStoreLAB = new MemStoreLABImpl(conf); for (int i = 0; i < maxCount; i++) { memStoreLAB.copyCellInto(kv);// Try allocate size = chunkSize. Means every // allocate call will result in a new chunk } // Close MemStoreLAB so that all chunks will be tried to be put back to pool memStoreLAB.close(); } };
@Override public void doAnAction() throws Exception { int valSize = r.nextInt(3); KeyValue kv = new KeyValue(rk, cf, q, new byte[valSize]); int size = kv.getSerializedSize(); ByteBufferKeyValue newCell = (ByteBufferKeyValue) mslab.copyCellInto(kv); totalAllocated.addAndGet(size); allocsByThisThread.add(new AllocRecord(newCell.getBuffer(), newCell.getOffset(), size)); } };
@Test public void testLABLargeAllocation() { MemStoreLAB mslab = new MemStoreLABImpl(); KeyValue kv = new KeyValue(rk, cf, q, new byte[2 * 1024 * 1024]); Cell newCell = mslab.copyCellInto(kv); assertNull("2MB allocation shouldn't be satisfied by LAB.", newCell); }
KeyValue kv = new KeyValue(rk, cf, q, new byte[valSize]); int size = kv.getSerializedSize(); ByteBufferKeyValue newKv = (ByteBufferKeyValue) mslab.copyCellInto(kv); if (newKv.getBuffer() != lastBuffer) { expectedOff = 4; mslab.copyCellInto(kv); assertEquals(chunkCount - 1, chunkCreator.getPoolSize());
KeyValue kv = new KeyValue(rk, cf, q, new byte[valSize]); int size = kv.getSerializedSize(); ByteBufferKeyValue newKv = (ByteBufferKeyValue) mslab.copyCellInto(kv); if (newKv.getBuffer() != lastBuffer) {
KeyValue kv = new KeyValue(rk, cf, q, new byte[valSize]); int size = kv.getSerializedSize(); ByteBufferKeyValue newKv = (ByteBufferKeyValue) mslab.copyCellInto(kv); if (newKv.getBuffer() != lastBuffer) {
@Override public void run() { MemStoreLAB memStoreLAB = new MemStoreLABImpl(conf); for (int i = 0; i < maxCount; i++) { memStoreLAB.copyCellInto(kv);// Try allocate size = chunkSize. Means every // allocate call will result in a new chunk } // Close MemStoreLAB so that all chunks will be tried to be put back to pool memStoreLAB.close(); } };
@Override public void doAnAction() throws Exception { int valSize = r.nextInt(3); KeyValue kv = new KeyValue(rk, cf, q, new byte[valSize]); int size = KeyValueUtil.length(kv); ByteBufferKeyValue newCell = (ByteBufferKeyValue) mslab.copyCellInto(kv); totalAllocated.addAndGet(size); allocsByThisThread.add(new AllocRecord(newCell.getBuffer(), newCell.getOffset(), size)); } };
@Test public void testLABLargeAllocation() { MemStoreLAB mslab = new MemStoreLABImpl(); KeyValue kv = new KeyValue(rk, cf, q, new byte[2 * 1024 * 1024]); Cell newCell = mslab.copyCellInto(kv); assertNull("2MB allocation shouldn't be satisfied by LAB.", newCell); }
KeyValue kv = new KeyValue(rk, cf, q, new byte[valSize]); int size = KeyValueUtil.length(kv); ByteBufferKeyValue newKv = (ByteBufferKeyValue) mslab.copyCellInto(kv); if (newKv.getBuffer() != lastBuffer) { expectedOff = 4; mslab.copyCellInto(kv); assertEquals(chunkCount - 1, chunkCreator.getPoolSize());
KeyValue kv = new KeyValue(rk, cf, q, new byte[valSize]); int size = KeyValueUtil.length(kv); ByteBufferKeyValue newKv = (ByteBufferKeyValue) mslab.copyCellInto(kv); if (newKv.getBuffer() != lastBuffer) {
KeyValue kv = new KeyValue(rk, cf, q, new byte[valSize]); int size = KeyValueUtil.length(kv); ByteBufferKeyValue newKv = (ByteBufferKeyValue) mslab.copyCellInto(kv); if (newKv.getBuffer() != lastBuffer) {