@Override public int internalEncode(Cell cell, HFileBlockDefaultEncodingContext encodingContext, DataOutputStream out) throws IOException { int klength = KeyValueUtil.keyLength(cell); int vlength = cell.getValueLength(); EncodingState state = encodingContext.getEncodingState(); if (state.prevCell == null) { // copy the key, there is no common prefix with none ByteBufferUtils.putCompressedInt(out, klength); ByteBufferUtils.putCompressedInt(out, vlength); ByteBufferUtils.putCompressedInt(out, 0); PrivateCellUtil.writeFlatKey(cell, (DataOutput)out); } else { // find a common prefix and skip it int common = PrivateCellUtil.findCommonPrefixInFlatKey(cell, state.prevCell, true, true); ByteBufferUtils.putCompressedInt(out, klength - common); ByteBufferUtils.putCompressedInt(out, vlength); ByteBufferUtils.putCompressedInt(out, common); writeKeyExcludingCommon(cell, common, out); } // Write the value part PrivateCellUtil.writeValue(out, cell, vlength); int size = klength + vlength + KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE; size += afterEncodingKeyValue(cell, out, encodingContext); state.prevCell = cell; return size; }
private void testCompressedInt(int value) throws IOException { int parsedValue = 0; ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteBufferUtils.putCompressedInt(bos, value); ByteArrayInputStream bis = new ByteArrayInputStream( bos.toByteArray()); parsedValue = ByteBufferUtils.readCompressedInt(bis); assertEquals(value, parsedValue); }
ByteBufferUtils.putCompressedInt(out, kLength); ByteBufferUtils.putCompressedInt(out, vLength); ByteBufferUtils.putCompressedInt(out, 0); PrivateCellUtil.writeFlatKey(cell, (DataOutput)out); ByteBufferUtils.putCompressedInt(out, kLength); ByteBufferUtils.putCompressedInt(out, vLength); ByteBufferUtils.putCompressedInt(out, commonPrefix); short rLen = cell.getRowLength(); if (commonPrefix < rLen + KeyValue.ROW_LENGTH_SIZE) {
ByteBufferUtils.putCompressedInt(out, kLength); ByteBufferUtils.putCompressedInt(out, vLength); ByteBufferUtils.putCompressedInt(out, commonPrefix); short rLen = cell.getRowLength(); if (commonPrefix < rLen + KeyValue.ROW_LENGTH_SIZE) {
if (encodingCtx.getHFileContext().isIncludesTags()) { int tagsLength = cell.getTagsLength(); ByteBufferUtils.putCompressedInt(out, tagsLength);
private int addKV(int prevKeyOffset, DataOutputStream out, ByteBuffer in, int prevKeyLength) throws IOException { int keyLength = in.getInt(); int valueLength = in.getInt(); if (prevKeyOffset == -1) { // copy the key, there is no common prefix with none ByteBufferUtils.putCompressedInt(out, keyLength); ByteBufferUtils.putCompressedInt(out, valueLength); ByteBufferUtils.putCompressedInt(out, 0); ByteBufferUtils.moveBufferToStream(out, in, keyLength + valueLength); } else { // find a common prefix and skip it int common = ByteBufferUtils.findCommonPrefix( in, prevKeyOffset + KeyValue.ROW_OFFSET, in.position(), Math.min(prevKeyLength, keyLength)); ByteBufferUtils.putCompressedInt(out, keyLength - common); ByteBufferUtils.putCompressedInt(out, valueLength); ByteBufferUtils.putCompressedInt(out, common); ByteBufferUtils.skip(in, common); ByteBufferUtils.moveBufferToStream(out, in, keyLength - common + valueLength); } return keyLength; }
@Override public int internalEncode(Cell cell, HFileBlockDefaultEncodingContext encodingContext, DataOutputStream out) throws IOException { int klength = KeyValueUtil.keyLength(cell); int vlength = cell.getValueLength(); EncodingState state = encodingContext.getEncodingState(); if (state.prevCell == null) { // copy the key, there is no common prefix with none ByteBufferUtils.putCompressedInt(out, klength); ByteBufferUtils.putCompressedInt(out, vlength); ByteBufferUtils.putCompressedInt(out, 0); PrivateCellUtil.writeFlatKey(cell, (DataOutput)out); } else { // find a common prefix and skip it int common = PrivateCellUtil.findCommonPrefixInFlatKey(cell, state.prevCell, true, true); ByteBufferUtils.putCompressedInt(out, klength - common); ByteBufferUtils.putCompressedInt(out, vlength); ByteBufferUtils.putCompressedInt(out, common); writeKeyExcludingCommon(cell, common, out); } // Write the value part PrivateCellUtil.writeValue(out, cell, vlength); int size = klength + vlength + KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE; size += afterEncodingKeyValue(cell, out, encodingContext); state.prevCell = cell; return size; }
@Override public int internalEncode(Cell cell, HFileBlockDefaultEncodingContext encodingContext, DataOutputStream out) throws IOException { int klength = KeyValueUtil.keyLength(cell); int vlength = cell.getValueLength(); EncodingState state = encodingContext.getEncodingState(); if (state.prevCell == null) { // copy the key, there is no common prefix with none ByteBufferUtils.putCompressedInt(out, klength); ByteBufferUtils.putCompressedInt(out, vlength); ByteBufferUtils.putCompressedInt(out, 0); PrivateCellUtil.writeFlatKey(cell, (DataOutput)out); } else { // find a common prefix and skip it int common = PrivateCellUtil.findCommonPrefixInFlatKey(cell, state.prevCell, true, true); ByteBufferUtils.putCompressedInt(out, klength - common); ByteBufferUtils.putCompressedInt(out, vlength); ByteBufferUtils.putCompressedInt(out, common); writeKeyExcludingCommon(cell, common, out); } // Write the value part PrivateCellUtil.writeValue(out, cell, vlength); int size = klength + vlength + KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE; size += afterEncodingKeyValue(cell, out, encodingContext); state.prevCell = cell; return size; }
@Override public int internalEncode(Cell cell, HFileBlockDefaultEncodingContext encodingContext, DataOutputStream out) throws IOException { int klength = KeyValueUtil.keyLength(cell); int vlength = cell.getValueLength(); EncodingState state = encodingContext.getEncodingState(); if (state.prevCell == null) { // copy the key, there is no common prefix with none ByteBufferUtils.putCompressedInt(out, klength); ByteBufferUtils.putCompressedInt(out, vlength); ByteBufferUtils.putCompressedInt(out, 0); CellUtil.writeFlatKey(cell, out); } else { // find a common prefix and skip it int common = CellUtil.findCommonPrefixInFlatKey(cell, state.prevCell, true, true); ByteBufferUtils.putCompressedInt(out, klength - common); ByteBufferUtils.putCompressedInt(out, vlength); ByteBufferUtils.putCompressedInt(out, common); writeKeyExcludingCommon(cell, common, out); } // Write the value part out.write(cell.getValueArray(), cell.getValueOffset(), vlength); int size = klength + vlength + KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE; size += afterEncodingKeyValue(cell, out, encodingContext); state.prevCell = cell; return size; }
private void testCompressedInt(int value) throws IOException { int parsedValue = 0; ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteBufferUtils.putCompressedInt(bos, value); ByteArrayInputStream bis = new ByteArrayInputStream( bos.toByteArray()); parsedValue = ByteBufferUtils.readCompressedInt(bis); assertEquals(value, parsedValue); }
private void testCompressedInt(int value) throws IOException { int parsedValue = 0; ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteBufferUtils.putCompressedInt(bos, value); ByteArrayInputStream bis = new ByteArrayInputStream( bos.toByteArray()); parsedValue = ByteBufferUtils.readCompressedInt(bis); assertEquals(value, parsedValue); }
ByteBufferUtils.putCompressedInt(out, keyLength); ByteBufferUtils.putCompressedInt(out, valueLength); ByteBufferUtils.putCompressedInt(out, 0); ByteBufferUtils.putCompressedInt(out, keyLength); ByteBufferUtils.putCompressedInt(out, valueLength); ByteBufferUtils.putCompressedInt(out, commonPrefix);
ByteBufferUtils.putCompressedInt(out, kLength); ByteBufferUtils.putCompressedInt(out, vLength); ByteBufferUtils.putCompressedInt(out, 0); PrivateCellUtil.writeFlatKey(cell, (DataOutput)out); ByteBufferUtils.putCompressedInt(out, kLength); ByteBufferUtils.putCompressedInt(out, vLength); ByteBufferUtils.putCompressedInt(out, commonPrefix); short rLen = cell.getRowLength(); if (commonPrefix < rLen + KeyValue.ROW_LENGTH_SIZE) {
ByteBufferUtils.putCompressedInt(out, kLength); ByteBufferUtils.putCompressedInt(out, vLength); ByteBufferUtils.putCompressedInt(out, 0); PrivateCellUtil.writeFlatKey(cell, (DataOutput)out); ByteBufferUtils.putCompressedInt(out, kLength); ByteBufferUtils.putCompressedInt(out, vLength); ByteBufferUtils.putCompressedInt(out, commonPrefix); short rLen = cell.getRowLength(); if (commonPrefix < rLen + KeyValue.ROW_LENGTH_SIZE) {
ByteBufferUtils.putCompressedInt(out, kLength); ByteBufferUtils.putCompressedInt(out, vLength); ByteBufferUtils.putCompressedInt(out, 0); CellUtil.writeFlatKey(cell, out); ByteBufferUtils.putCompressedInt(out, kLength); ByteBufferUtils.putCompressedInt(out, vLength); ByteBufferUtils.putCompressedInt(out, commonPrefix); short rLen = cell.getRowLength(); if (commonPrefix < rLen + KeyValue.ROW_LENGTH_SIZE) {
ByteBufferUtils.putCompressedInt(out, kLength); ByteBufferUtils.putCompressedInt(out, vLength); ByteBufferUtils.putCompressedInt(out, commonPrefix); short rLen = cell.getRowLength(); if (commonPrefix < rLen + KeyValue.ROW_LENGTH_SIZE) {
ByteBufferUtils.putCompressedInt(out, kLength); ByteBufferUtils.putCompressedInt(out, vLength); ByteBufferUtils.putCompressedInt(out, commonPrefix); short rLen = cell.getRowLength(); if (commonPrefix < rLen + KeyValue.ROW_LENGTH_SIZE) {
if (encodingCtx.getHFileContext().isIncludesTags()) { int tagsLength = cell.getTagsLength(); ByteBufferUtils.putCompressedInt(out, tagsLength);
if (encodingCtx.getHFileContext().isIncludesTags()) { int tagsLength = cell.getTagsLength(); ByteBufferUtils.putCompressedInt(out, tagsLength);
if (encodingCtx.getHFileContext().isIncludesTags()) { int tagsLength = cell.getTagsLength(); ByteBufferUtils.putCompressedInt(out, tagsLength);