keyValue = new KeyValue(bb.array(), underlyingArrayOffset, kvLength); if (includesMvccVersion) { long mvccVersion = ByteBufferUtils.readVLong(bb); keyValue.setSequenceId(mvccVersion);
memstoreTS = ByteBufferUtils.readVLong(in);
(int) KeyValue.getKeyValueDataStructureSize(klen, vlen, tagsLen)); if (meta.isIncludesMvcc()) { long mvccVersion = ByteBufferUtils.readVLong(decompressedData); kv.setSequenceId(mvccVersion);
@Test public void testReadWriteVLong() { for (long l : testNumbers) { ByteBuffer b = ByteBuffer.allocate(MAX_VLONG_LENGTH); ByteBufferUtils.writeVLong(b, l); b.flip(); assertEquals(l, ByteBufferUtils.readVLong(b)); } }
protected final void afterEncodingKeyValue(ByteBuffer in, DataOutputStream out, boolean includesMemstoreTS) { if (includesMemstoreTS) { // Copy memstore timestamp from the byte buffer to the output stream. long memstoreTS = -1; try { memstoreTS = ByteBufferUtils.readVLong(in); WritableUtils.writeVLong(out, memstoreTS); } catch (IOException ex) { throw new RuntimeException("Unable to copy memstore timestamp " + memstoreTS + " after encoding a key/value"); } } }
@Override protected void decodeNext() { current.keyLength = currentBuffer.getInt(); current.valueLength = currentBuffer.getInt(); current.ensureSpaceForKey(); currentBuffer.get(current.keyBuffer, 0, current.keyLength); current.valueOffset = currentBuffer.position(); ByteBufferUtils.skip(currentBuffer, current.valueLength); if (includesMemstoreTS) { current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer); } else { current.memstoreTS = 0; } current.nextKvOffset = currentBuffer.position(); }
@Override protected void decodeNext() { current.keyLength = currentBuffer.getInt(); current.valueLength = currentBuffer.getInt(); current.ensureSpaceForKey(); currentBuffer.get(current.keyBuffer, 0, current.keyLength); current.valueOffset = currentBuffer.position(); ByteBufferUtils.skip(currentBuffer, current.valueLength); if (includesTags()) { // Read short as unsigned, high byte first current.tagsLength = ((currentBuffer.get() & 0xff) << 8) ^ (currentBuffer.get() & 0xff); ByteBufferUtils.skip(currentBuffer, current.tagsLength); } if (includesMvcc()) { current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer); } else { current.memstoreTS = 0; } current.nextKvOffset = currentBuffer.position(); }
keyValue = new KeyValue(bb.array(), underlyingArrayOffset, kvLength); if (includesMvccVersion) { long mvccVersion = ByteBufferUtils.readVLong(bb); keyValue.setSequenceId(mvccVersion);
keyValue = new KeyValue(bb.array(), underlyingArrayOffset, kvLength); if (includesMvccVersion) { long mvccVersion = ByteBufferUtils.readVLong(bb); keyValue.setSequenceId(mvccVersion);
keyValue = new KeyValue(bb.array(), underlyingArrayOffset, kvLength); if (includesMvccVersion) { long mvccVersion = ByteBufferUtils.readVLong(bb); keyValue.setSequenceId(mvccVersion);
@Override protected void decodeNext() { current.keyLength = ByteBufferUtils.readCompressedInt(currentBuffer); current.valueLength = ByteBufferUtils.readCompressedInt(currentBuffer); current.lastCommonPrefix = ByteBufferUtils.readCompressedInt(currentBuffer); current.keyLength += current.lastCommonPrefix; current.ensureSpaceForKey(); currentBuffer.get(current.keyBuffer, current.lastCommonPrefix, current.keyLength - current.lastCommonPrefix); current.valueOffset = currentBuffer.position(); ByteBufferUtils.skip(currentBuffer, current.valueLength); if (includesMemstoreTS) { current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer); } else { current.memstoreTS = 0; } current.nextKvOffset = currentBuffer.position(); }
@Override public Cell next() { if (decompressedData == null) { try { decompressedData = dataBlockEncoder.decodeKeyValues(dis, dataBlockEncoder .newDataBlockDecodingContext(meta)); } catch (IOException e) { throw new RuntimeException("Problem with data block encoder, " + "most likely it requested more bytes than are available.", e); } decompressedData.rewind(); } int offset = decompressedData.position(); int klen = decompressedData.getInt(); int vlen = decompressedData.getInt(); int tagsLen = 0; ByteBufferUtils.skip(decompressedData, klen + vlen); // Read the tag length in case when steam contain tags if (meta.isIncludesTags()) { tagsLen = ((decompressedData.get() & 0xff) << 8) ^ (decompressedData.get() & 0xff); ByteBufferUtils.skip(decompressedData, tagsLen); } KeyValue kv = new KeyValue(decompressedData.array(), offset, (int) KeyValue.getKeyValueDataStructureSize(klen, vlen, tagsLen)); if (meta.isIncludesMvcc()) { long mvccVersion = ByteBufferUtils.readVLong(decompressedData); kv.setSequenceId(mvccVersion); } return kv; }
memstoreTS = ByteBufferUtils.readVLong(in);
@Override public Cell next() { if (decompressedData == null) { try { decompressedData = dataBlockEncoder.decodeKeyValues(dis, dataBlockEncoder .newDataBlockDecodingContext(meta)); } catch (IOException e) { throw new RuntimeException("Problem with data block encoder, " + "most likely it requested more bytes than are available.", e); } decompressedData.rewind(); } int offset = decompressedData.position(); int klen = decompressedData.getInt(); int vlen = decompressedData.getInt(); int tagsLen = 0; ByteBufferUtils.skip(decompressedData, klen + vlen); // Read the tag length in case when steam contain tags if (meta.isIncludesTags()) { tagsLen = ((decompressedData.get() & 0xff) << 8) ^ (decompressedData.get() & 0xff); ByteBufferUtils.skip(decompressedData, tagsLen); } KeyValue kv = new KeyValue(decompressedData.array(), offset, (int) KeyValue.getKeyValueDataStructureSize(klen, vlen, tagsLen)); if (meta.isIncludesMvcc()) { long mvccVersion = ByteBufferUtils.readVLong(decompressedData); kv.setSequenceId(mvccVersion); } return kv; }
(int) KeyValue.getKeyValueDataStructureSize(klen, vlen, tagsLen)); if (meta.isIncludesMvcc()) { long mvccVersion = ByteBufferUtils.readVLong(decompressedData); kv.setSequenceId(mvccVersion);
memstoreTS = ByteBufferUtils.readVLong(in);
memstoreTS = ByteBufferUtils.readVLong(in);
@Test public void testReadWriteVLong() { for (long l : testNumbers) { ByteBuffer b = ByteBuffer.allocate(MAX_VLONG_LENGTH); ByteBufferUtils.writeVLong(b, l); b.flip(); assertEquals(l, ByteBufferUtils.readVLong(b)); } }
@Test public void testReadWriteVLong() { for (long l : testNumbers) { ByteBuffer b = ByteBuffer.allocate(MAX_VLONG_LENGTH); ByteBufferUtils.writeVLong(b, l); b.flip(); assertEquals(l, ByteBufferUtils.readVLong(b)); } }
@Override protected void decodeNext() { current.keyLength = ByteBufferUtils.readCompressedInt(currentBuffer); current.valueLength = ByteBufferUtils.readCompressedInt(currentBuffer); current.lastCommonPrefix = ByteBufferUtils.readCompressedInt(currentBuffer); current.keyLength += current.lastCommonPrefix; current.ensureSpaceForKey(); currentBuffer.get(current.keyBuffer, current.lastCommonPrefix, current.keyLength - current.lastCommonPrefix); current.valueOffset = currentBuffer.position(); ByteBufferUtils.skip(currentBuffer, current.valueLength); if (includesTags()) { decodeTags(); } if (includesMvcc()) { current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer); } else { current.memstoreTS = 0; } current.nextKvOffset = currentBuffer.position(); }