Source:
public void truncateToSequenceNumber(final long truncationSeqNo) throws IOException { assert(m_memoryDeque.isEmpty()); m_persistentDeque.parseAndTruncate(new BinaryDequeTruncator() { @Override public TruncatorResponse parse(BBContainer bbc) { ByteBuffer b = bbc.b(); ByteOrder endianness = b.order(); b.order(ByteOrder.LITTLE_ENDIAN); try { final long startSequenceNumber = b.getLong(); if (startSequenceNumber > truncationSeqNo) { return PersistentBinaryDeque.fullTruncateResponse(); } final long committedSequenceNumber = b.getLong(); final int tupleCountPos = b.position(); final int tupleCount = b.getInt(); final long lastSequenceNumber = startSequenceNumber + tupleCount - 1; if (lastSequenceNumber <= truncationSeqNo) { return null; } b.getLong(); int offset = 0; while (b.hasRemaining()) { if (startSequenceNumber + offset > truncationSeqNo) { b.limit(b.position()); b.putInt(tupleCountPos, offset - 1); b.position(0); return new ByteBufferTruncatorResponse(b); } offset++; final int rowLength = b.getInt(); b.position(b.position() + rowLength); } return null; } finally { b.order(endianness); } } }); m_persistentDeque.close(); CatalogContext catalogContext = VoltDB.instance().getCatalogContext(); Table streamTable = VoltDB.instance().getCatalogContext().database.getTables().get(m_streamName); ExportRowSchema schema = ExportRowSchema.create(streamTable, m_partitionId, catalogContext.m_genId); ExportRowSchemaSerializer ds = new ExportRowSchemaSerializer(); m_persistentDeque = PersistentBinaryDeque.builder(m_nonce, new VoltFile(m_path), exportLog) .initialExtraHeader(schema, ds) .compression(!DISABLE_COMPRESSION).build(); m_reader = m_persistentDeque.openForRead(m_nonce); exportLog.info("After truncate, PBD size is " + (m_reader.sizeInBytes() - (8 * m_reader.getNumObjects()))); }

Target:
public void truncateToSequenceNumber(final long truncationSeqNo) throws IOException { assert(m_memoryDeque.isEmpty()); m_persistentDeque.parseAndTruncate(new BinaryDequeTruncator() { @Override public TruncatorResponse parse(BBContainer bbc) { ByteBuffer b = bbc.b(); ByteOrder endianness = b.order(); b.order(ByteOrder.LITTLE_ENDIAN); try { final long startSequenceNumber = b.getLong(); if (startSequenceNumber > truncationSeqNo) { return PersistentBinaryDeque.fullTruncateResponse(); } final long committedSequenceNumber = b.getLong(); final int tupleCountPos = b.position(); final int tupleCount = b.getInt(); final long lastSequenceNumber = startSequenceNumber + tupleCount - 1; if (lastSequenceNumber <= truncationSeqNo) { return null; } b.getLong(); int offset = 0; while (b.hasRemaining()) { if (startSequenceNumber + offset > truncationSeqNo) { b.limit(b.position()); b.putInt(tupleCountPos, offset - 1); b.position(0); return new ByteBufferTruncatorResponse(b); } offset++; final int rowLength = b.getInt(); b.position(b.position() + rowLength); } return null; } finally { b.order(endianness); } } }); m_persistentDeque.close(); CatalogContext catalogContext = VoltDB.instance().getCatalogContext(); Table streamTable = VoltDB.instance().getCatalogContext().database.getTables().get(m_streamName); ExportRowSchema schema = ExportRowSchema.create(streamTable, m_partitionId, catalogContext.m_genId); ExportRowSchemaSerializer serializer = new ExportRowSchemaSerializer(); m_persistentDeque = PersistentBinaryDeque.builder(m_nonce, new VoltFile(m_path), exportLog) .initialExtraHeader(schema, serializer) .compression(!DISABLE_COMPRESSION).build(); m_reader = m_persistentDeque.openForRead(m_nonce); exportLog.info("After truncate, PBD size is " + (m_reader.sizeInBytes() - (8 * m_reader.getNumObjects()))); }