@Override void writeValue(ReftableOutputStream os) throws IOException { int cnt = blockPos.size(); if (cnt == 0) { os.writeVarint(0); return; } if (cnt > VALUE_TYPE_MASK) { os.writeVarint(cnt); } os.writeVarint(blockPos.get(0)); for (int j = 1; j < cnt; j++) { long prior = blockPos.get(j - 1); long b = blockPos.get(j); os.writeVarint(b - prior); } } }
@Override int valueSize() { int cnt = blockPos.size(); if (cnt == 0) { return computeVarintSize(0); } int n = 0; if (cnt > VALUE_TYPE_MASK) { n += computeVarintSize(cnt); } n += computeVarintSize(blockPos.get(0)); for (int j = 1; j < cnt; j++) { long prior = blockPos.get(j - 1); long b = blockPos.get(j); n += computeVarintSize(b - prior); } return n; }
@Nullable LongList readBlockPositionList() { int n = valueType & VALUE_TYPE_MASK; if (n == 0) { n = readVarint32(); if (n == 0) { return null; } } LongList b = new LongList(n); b.add(readVarint64()); for (int j = 1; j < n; j++) { long prior = b.get(j - 1); b.add(prior + readVarint64()); } return b; }
long pos = blockPos.get(listIdx++); block = readBlock(pos, scanEnd);
return false; pos = blockPos.get(listIdx++); } else { pos = block.endPosition();
@Override int valueSize() { int cnt = blockPos.size(); if (cnt == 0) { return computeVarintSize(0); } int n = 0; if (cnt > VALUE_TYPE_MASK) { n += computeVarintSize(cnt); } n += computeVarintSize(blockPos.get(0)); for (int j = 1; j < cnt; j++) { long prior = blockPos.get(j - 1); long b = blockPos.get(j); n += computeVarintSize(b - prior); } return n; }
@Override void writeValue(ReftableOutputStream os) throws IOException { int cnt = blockPos.size(); if (cnt == 0) { os.writeVarint(0); return; } if (cnt > VALUE_TYPE_MASK) { os.writeVarint(cnt); } os.writeVarint(blockPos.get(0)); for (int j = 1; j < cnt; j++) { long prior = blockPos.get(j - 1); long b = blockPos.get(j); os.writeVarint(b - prior); } } }
private int findStreamIndex(long streamPosition) throws DhtException { int high = objStreamPos.size(); int low = 0; do { final int mid = (low + high) >>> 1; final long pos = objStreamPos.get(mid); if (streamPosition < pos) high = mid; else if (streamPosition == pos) return mid; else low = mid + 1; } while (low < high); throw new DhtException(MessageFormat.format( DhtText.get().noSavedTypeForBase, Long.valueOf(streamPosition))); }
private int findStreamIndex(long streamPosition) throws DhtException { int high = objStreamPos.size(); int low = 0; do { final int mid = (low + high) >>> 1; final long pos = objStreamPos.get(mid); if (streamPosition < pos) high = mid; else if (streamPosition == pos) return mid; else low = mid + 1; } while (low < high); throw new DhtException(MessageFormat.format( DhtText.get().noSavedTypeForBase, Long.valueOf(streamPosition))); }
@Nullable LongList readBlockPositionList() { int n = valueType & VALUE_TYPE_MASK; if (n == 0) { n = readVarint32(); if (n == 0) { return null; } } LongList b = new LongList(n); b.add(readVarint64()); for (int j = 1; j < n; j++) { long prior = b.get(j - 1); b.add(prior + readVarint64()); } return b; }
long pos = blockPos.get(listIdx++); block = readBlock(pos, scanEnd);
return false; pos = blockPos.get(listIdx++); } else { pos = block.endPosition();
@Override protected void onBeginOfsDelta(long deltaPos, long basePos, long inflatedSize) throws IOException { long basePtr = objChunkPtrs.get(findStreamIndex(basePos)); int type = typeOf(basePtr); currType = type; currPackedSize = 0; currInflatedSize = inflatedSize; currBasePtr = basePtr; objStreamPos.add(deltaPos); ChunkFormatter w = begin(type); if (isInCurrentChunk(basePtr)) { if (w.ofsDelta(inflatedSize, w.position() - offsetOf(basePtr))) { currDataPos = w.position(); return; } endChunk(type); w = begin(type); } if (!longOfsDelta(w, inflatedSize, basePtr)) { endChunk(type); w = begin(type); if (!longOfsDelta(w, inflatedSize, basePtr)) throw panicCannotInsert(); } currDataPos = w.position(); }
@Override protected void onBeginOfsDelta(long deltaPos, long basePos, long inflatedSize) throws IOException { long basePtr = objChunkPtrs.get(findStreamIndex(basePos)); int type = typeOf(basePtr); currType = type; currPackedSize = 0; currInflatedSize = inflatedSize; currBasePtr = basePtr; objStreamPos.add(deltaPos); ChunkFormatter w = begin(type); if (isInCurrentChunk(basePtr)) { if (w.ofsDelta(inflatedSize, w.position() - offsetOf(basePtr))) { currDataPos = w.position(); return; } endChunk(type); w = begin(type); } if (!longOfsDelta(w, inflatedSize, basePtr)) { endChunk(type); w = begin(type); if (!longOfsDelta(w, inflatedSize, basePtr)) throw panicCannotInsert(); } currDataPos = w.position(); }