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; }
private void logRange(DiskRange range, int currentOffset) { log[currentOffset] = range.getOffset(); log[currentOffset + 1] = range.getEnd(); log[currentOffset + 2] = range.hasData() ? System.identityHashCode(range.getData()) : 0; }
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 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); }
compressed = range.getData().duplicate(); if (compressed.remaining() >= len) { slice = compressed.slice();
compressed = range.getData().duplicate(); if (compressed.remaining() >= len) { slice = compressed.slice();
currentOffset = desired; currentRange = i; this.range = curRange.getData().duplicate(); int pos = range.position(); pos += (int)(desired - curRange.getOffset()); // this is why we duplicate 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
if (desired == 0 && curRange.getData().remaining() == 0) { logEmptySeek(name); return; currentOffset = desired; currentRange = i; this.range = curRange.getData().duplicate(); int pos = range.position(); pos += (int)(desired - curRange.getOffset()); // this is why we duplicate 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