int familyCommonPrefix = 0; int qualCommonPrefix = 0; previous.invalidate(); do { int comp; if (!previous.isValid()) { if (previous.isValid()) { moveToPrevious(); } else { previous.copyFromNext(current); decodeNext(); current.setKey(current.keyBuffer, current.memstoreTS); } else { break;
protected void decodeTags() { current.tagsLength = ByteBuff.readCompressedInt(currentBuffer); if (tagCompressionContext != null) { if (current.uncompressTags) { // Tag compression is been used. uncompress it into tagsBuffer current.ensureSpaceForTags(); try { current.tagsCompressedLength = tagCompressionContext.uncompressTags(currentBuffer, current.tagsBuffer, 0, current.tagsLength); } catch (IOException e) { throw new RuntimeException("Exception while uncompressing tags", e); } } else { currentBuffer.skip(current.tagsCompressedLength); current.uncompressTags = true;// Reset this. } current.tagsOffset = -1; } else { // When tag compress is not used, let us not do copying of tags bytes into tagsBuffer. // Just mark the tags Offset so as to create the KV buffer later in getKeyValueBuffer() current.tagsOffset = currentBuffer.position(); currentBuffer.skip(current.tagsLength); } }
public Cell toCell() { // Buffer backing the value and tags part from the HFileBlock's buffer // When tag compression in use, this will be only the value bytes area. ByteBuffer valAndTagsBuffer; int vOffset; int valAndTagsLength = this.valueLength; int tagsLenSerializationSize = 0; if (this.includeTags && this.tagCompressionContext == null) { // Include the tags part also. This will be the tags bytes + 2 bytes of for storing tags // length tagsLenSerializationSize = this.tagsOffset - (this.valueOffset + this.valueLength); valAndTagsLength += tagsLenSerializationSize + this.tagsLength; } this.currentBuffer.asSubByteBuffer(this.valueOffset, valAndTagsLength, this.tmpPair); valAndTagsBuffer = this.tmpPair.getFirst(); vOffset = this.tmpPair.getSecond();// This is the offset to value part in the BB if (valAndTagsBuffer.hasArray()) { return toOnheapCell(valAndTagsBuffer, vOffset, tagsLenSerializationSize); } else { return toOffheapCell(valAndTagsBuffer, vOffset, tagsLenSerializationSize); } }
int familyCommonPrefix = 0; int qualCommonPrefix = 0; previous.invalidate(); KeyValue.KeyOnlyKeyValue currentCell = new KeyValue.KeyOnlyKeyValue(); do { if (!previous.isValid()) { if (previous.isValid()) { moveToPrevious(); } else { previous.copyFromNext(current); decodeNext(); current.setKey(current.keyBuffer, current.memstoreTS); } else { break;
int familyCommonPrefix = 0; int qualCommonPrefix = 0; previous.invalidate(); do { int comp; if (!previous.isValid()) { if (previous.isValid()) { moveToPrevious(); } else { previous.copyFromNext(current); decodeNext(); current.setKey(current.keyBuffer, current.memstoreTS); } else { break;
int familyCommonPrefix = 0; int qualCommonPrefix = 0; previous.invalidate(); do { int comp; if (!previous.isValid()) { if (previous.isValid()) { moveToPrevious(); } else { previous.copyFromNext(current); decodeNext(); current.setKey(current.keyBuffer, current.memstoreTS); } else { break;
boolean seekBefore) { int commonPrefix = 0; previous.invalidate(); do { int comp; if (!previous.isValid()) { if (previous.isValid()) { moveToPrevious(); previous.copyFromNext(current); decodeNext(); } else {
if (keyBuffer.length != nextState.keyBuffer.length) { keyBuffer = nextState.keyBuffer.clone(); } else if (!isValid()) {
if (keyBuffer.length != nextState.keyBuffer.length) { keyBuffer = nextState.keyBuffer.clone(); } else if (!isValid()) {
if (keyBuffer.length != nextState.keyBuffer.length) { keyBuffer = nextState.keyBuffer.clone(); } else if (!isValid()) {
/** * Copy the state from the next one into this instance (the previous state * placeholder). Used to save the previous state when we are advancing the * seeker to the next key/value. */ protected void copyFromNext(SeekerState nextState) { if (keyBuffer.length != nextState.keyBuffer.length) { keyBuffer = nextState.keyBuffer.clone(); } else if (!isValid()) { // Note: we can only call isValid before we override our state, so this // comes before all the assignments at the end of this method. System.arraycopy(nextState.keyBuffer, 0, keyBuffer, 0, nextState.keyLength); } else { // don't copy the common prefix between this key and the previous one System.arraycopy(nextState.keyBuffer, nextState.lastCommonPrefix, keyBuffer, nextState.lastCommonPrefix, nextState.keyLength - nextState.lastCommonPrefix); } valueOffset = nextState.valueOffset; keyLength = nextState.keyLength; valueLength = nextState.valueLength; lastCommonPrefix = nextState.lastCommonPrefix; nextKvOffset = nextState.nextKvOffset; memstoreTS = nextState.memstoreTS; }
@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(); }
protected void decodeTags() { current.tagsLength = ByteBufferUtils.readCompressedInt(currentBuffer); if (tagCompressionContext != null) { if (current.uncompressTags) { // Tag compression is been used. uncompress it into tagsBuffer current.ensureSpaceForTags(); try { current.tagsCompressedLength = tagCompressionContext.uncompressTags(currentBuffer, current.tagsBuffer, 0, current.tagsLength); } catch (IOException e) { throw new RuntimeException("Exception while uncompressing tags", e); } } else { ByteBufferUtils.skip(currentBuffer, current.tagsCompressedLength); current.uncompressTags = true;// Reset this. } current.tagsOffset = -1; } else { // When tag compress is not used, let us not do copying of tags bytes into tagsBuffer. // Just mark the tags Offset so as to create the KV buffer later in getKeyValueBuffer() current.tagsOffset = currentBuffer.position(); ByteBufferUtils.skip(currentBuffer, current.tagsLength); } }
protected void decodeTags() { current.tagsLength = ByteBuff.readCompressedInt(currentBuffer); if (tagCompressionContext != null) { if (current.uncompressTags) { // Tag compression is been used. uncompress it into tagsBuffer current.ensureSpaceForTags(); try { current.tagsCompressedLength = tagCompressionContext.uncompressTags(currentBuffer, current.tagsBuffer, 0, current.tagsLength); } catch (IOException e) { throw new RuntimeException("Exception while uncompressing tags", e); } } else { currentBuffer.skip(current.tagsCompressedLength); current.uncompressTags = true;// Reset this. } current.tagsOffset = -1; } else { // When tag compress is not used, let us not do copying of tags bytes into tagsBuffer. // Just mark the tags Offset so as to create the KV buffer later in getKeyValueBuffer() current.tagsOffset = currentBuffer.position(); currentBuffer.skip(current.tagsLength); } }
@Override protected void decodeNext() { current.keyLength = ByteBuff.readCompressedInt(currentBuffer); current.valueLength = ByteBuff.readCompressedInt(currentBuffer); current.lastCommonPrefix = ByteBuff.readCompressedInt(currentBuffer); current.keyLength += current.lastCommonPrefix; current.ensureSpaceForKey(); currentBuffer.get(current.keyBuffer, current.lastCommonPrefix, current.keyLength - current.lastCommonPrefix); current.valueOffset = currentBuffer.position(); currentBuffer.skip(current.valueLength); if (includesTags()) { decodeTags(); } if (includesMvcc()) { current.memstoreTS = ByteBuff.readVLong(currentBuffer); } else { current.memstoreTS = 0; } current.nextKvOffset = currentBuffer.position(); }
protected void decodeTags() { current.tagsLength = ByteBuff.readCompressedInt(currentBuffer); if (tagCompressionContext != null) { if (current.uncompressTags) { // Tag compression is been used. uncompress it into tagsBuffer current.ensureSpaceForTags(); try { current.tagsCompressedLength = tagCompressionContext.uncompressTags(currentBuffer, current.tagsBuffer, 0, current.tagsLength); } catch (IOException e) { throw new RuntimeException("Exception while uncompressing tags", e); } } else { currentBuffer.skip(current.tagsCompressedLength); current.uncompressTags = true;// Reset this. } current.tagsOffset = -1; } else { // When tag compress is not used, let us not do copying of tags bytes into tagsBuffer. // Just mark the tags Offset so as to create the KV buffer later in getKeyValueBuffer() current.tagsOffset = currentBuffer.position(); currentBuffer.skip(current.tagsLength); } }
private void moveToPrevious() { if (!previous.isValid()) { throw new IllegalStateException( "Can move back only once and not in first key in the block."); } STATE tmp = previous; previous = current; current = tmp; // move after last key value currentBuffer.position(current.nextKvOffset); // Already decoded the tag bytes. We cache this tags into current state and also the total // compressed length of the tags bytes. For the next time decodeNext() we don't need to decode // the tags again. This might pollute the Data Dictionary what we use for the compression. // When current.uncompressTags is false, we will just reuse the current.tagsBuffer and skip // 'tagsCompressedLength' bytes of source stream. // See in decodeTags() current.tagsBuffer = previous.tagsBuffer; current.tagsCompressedLength = previous.tagsCompressedLength; current.uncompressTags = false; // The current key has to be reset with the previous Cell current.setKey(current.keyBuffer, current.memstoreTS); previous.invalidate(); }
private void moveToPrevious() { if (!previous.isValid()) { throw new IllegalStateException( "Can move back only once and not in first key in the block."); } STATE tmp = previous; previous = current; current = tmp; // move after last key value currentBuffer.position(current.nextKvOffset); // Already decoded the tag bytes. We cache this tags into current state and also the total // compressed length of the tags bytes. For the next time decodeNext() we don't need to decode // the tags again. This might pollute the Data Dictionary what we use for the compression. // When current.uncompressTags is false, we will just reuse the current.tagsBuffer and skip // 'tagsCompressedLength' bytes of source stream. // See in decodeTags() current.tagsBuffer = previous.tagsBuffer; current.tagsCompressedLength = previous.tagsCompressedLength; current.uncompressTags = false; current.setKey(current.keyBuffer, current.memstoreTS); previous.invalidate(); }
private void moveToPrevious() { if (!previous.isValid()) { throw new IllegalStateException( "Can move back only once and not in first key in the block."); } STATE tmp = previous; previous = current; current = tmp; // move after last key value currentBuffer.position(current.nextKvOffset); // Already decoded the tag bytes. We cache this tags into current state and also the total // compressed length of the tags bytes. For the next time decodeNext() we don't need to decode // the tags again. This might pollute the Data Dictionary what we use for the compression. // When current.uncompressTags is false, we will just reuse the current.tagsBuffer and skip // 'tagsCompressedLength' bytes of source stream. // See in decodeTags() current.tagsBuffer = previous.tagsBuffer; current.tagsCompressedLength = previous.tagsCompressedLength; current.uncompressTags = false; // The current key has to be reset with the previous Cell current.setKey(current.keyBuffer, current.memstoreTS); previous.invalidate(); }
public Cell toCell() { // Buffer backing the value and tags part from the HFileBlock's buffer // When tag compression in use, this will be only the value bytes area. ByteBuffer valAndTagsBuffer; int vOffset; int valAndTagsLength = this.valueLength; int tagsLenSerializationSize = 0; if (this.includeTags && this.tagCompressionContext == null) { // Include the tags part also. This will be the tags bytes + 2 bytes of for storing tags // length tagsLenSerializationSize = this.tagsOffset - (this.valueOffset + this.valueLength); valAndTagsLength += tagsLenSerializationSize + this.tagsLength; } this.currentBuffer.asSubByteBuffer(this.valueOffset, valAndTagsLength, this.tmpPair); valAndTagsBuffer = this.tmpPair.getFirst(); vOffset = this.tmpPair.getSecond();// This is the offset to value part in the BB if (valAndTagsBuffer.hasArray()) { return toOnheapCell(valAndTagsBuffer, vOffset, tagsLenSerializationSize); } else { return toOffheapCell(valAndTagsBuffer, vOffset, tagsLenSerializationSize); } }