public void addDiskRange(DiskRange diskRange) { diskRanges.add(diskRange); totalLength += diskRange.getLength(); }
private void copyDiskDataToCacheBuffer(byte[] diskData, int offsetInDiskData, int sizeToCopy, ByteBuffer cacheBuffer, DiskRange[] cacheRanges, int cacheRangeIx, long cacheRangeStart) { int bbPos = cacheBuffer.position(); long cacheRangeEnd = cacheRangeStart + sizeToCopy; if (LOG.isTraceEnabled()) { LOG.trace("Caching [" + cacheRangeStart + ", " + cacheRangeEnd + ")"); } cacheRanges[cacheRangeIx] = new DiskRange(cacheRangeStart, cacheRangeEnd); cacheBuffer.put(diskData, offsetInDiskData, sizeToCopy); cacheBuffer.position(bbPos); }
public void logValidUncompresseedChunk(int totalLength, DiskRange chunk) { if (log == null) return; int offset = this.offset; if (offset + 2 > log.length) return; log[offset] = makeIntPair(VALID_UNCOMPRESSEED_CHUNK, totalLength); log[offset + 1] = chunk.hasData() ? System.identityHashCode(chunk.getData()) : 0; this.offset += 2; }
if (curRange.getOffset() <= desired && (desired - curRange.getOffset()) < curRange.getLength()) { currentOffset = desired; currentRange = i; this.range = curRange.getData().duplicate(); int pos = range.position(); pos += (int)(desired - curRange.getOffset()); // this is why we duplicate this.range.position(pos); return; if (segments != 0 && desired == bytes.get(segments - 1).getEnd()) { currentOffset = desired; currentRange = segments - 1; DiskRange curRange = bytes.get(currentRange); this.range = curRange.getData().duplicate(); int pos = range.position(); pos += (int)(desired - curRange.getOffset()); // this is why we duplicate this.range.position(pos); return;
private void seek(long desired) throws IOException { if (desired == 0 && bytes.isEmpty()) { return; } int i = 0; for (DiskRange range : bytes) { if (range.getOffset() <= desired && desired < range.getEnd()) { currentRange = i; compressed = range.getData().duplicate(); int pos = compressed.position(); pos += (int)(desired - range.getOffset()); compressed.position(pos); currentOffset = desired; return; } ++i; } // if they are seeking to the precise end, go ahead and let them go there int segments = bytes.size(); if (segments != 0 && desired == bytes.get(segments - 1).getEnd()) { DiskRange range = bytes.get(segments - 1); currentRange = segments - 1; compressed = range.getData().duplicate(); compressed.position(compressed.limit()); currentOffset = desired; return; } throw new IOException("Seek outside of data in " + this + " to " + desired); }
private void setOffset(List<DiskRange> list) { currentOffset = list.isEmpty() ? 0 : list.get(0).getOffset(); } }
compressed = range.getData().duplicate(); if (compressed.remaining() >= len) { slice = compressed.slice();
@Override public boolean equals(Object other) { if (other == null || other.getClass() != getClass()) { return false; } return equalRange((DiskRange) other); }
if (desired == 0 && curRange.getData().remaining() == 0) { logEmptySeek(name); return; if (curRange.getOffset() <= desired && (desired - curRange.getOffset()) < curRange.getLength()) { currentOffset = desired; currentRange = i; this.range = curRange.getData().duplicate(); int pos = range.position(); pos += (int)(desired - curRange.getOffset()); // this is why we duplicate this.range.position(pos); return; if (segments != 0 && desired == bytes.get(segments - 1).getEnd()) { currentOffset = desired; currentRange = segments - 1; DiskRange curRange = bytes.get(currentRange); this.range = curRange.getData().duplicate(); int pos = range.position(); pos += (int)(desired - curRange.getOffset()); // this is why we duplicate this.range.position(pos); return;
private void seek(long desired) throws IOException { if (desired == 0 && bytes.isEmpty()) { logEmptySeek(name); return; } int i = 0; for (DiskRange range : bytes) { if (range.getOffset() <= desired && desired < range.getEnd()) { currentRange = i; compressed = range.getData().duplicate(); int pos = compressed.position(); pos += (int)(desired - range.getOffset()); compressed.position(pos); currentOffset = desired; return; } ++i; } // if they are seeking to the precise end, go ahead and let them go there int segments = bytes.size(); if (segments != 0 && desired == bytes.get(segments - 1).getEnd()) { DiskRange range = bytes.get(segments - 1); currentRange = segments - 1; compressed = range.getData().duplicate(); compressed.position(compressed.limit()); currentOffset = desired; return; } throw new IOException("Seek outside of data in " + this + " to " + desired); }
private void setOffset(List<DiskRange> list) { currentOffset = list.isEmpty() ? 0 : list.get(0).getOffset(); } }
compressed = range.getData().duplicate(); if (compressed.remaining() >= len) { slice = compressed.slice();
@Override public boolean equals(Object other) { if (other == null || other.getClass() != getClass()) { return false; } return equalRange((DiskRange) other); }
public void addDiskRange(DiskRange diskRange) { diskRanges.add(diskRange); totalLength += diskRange.getLength(); }