@Override public ObjectStream openStream() throws MissingObjectException, IOException { PackChunk pc = firstChunk; if (pc != null) firstChunk = null; else pc = ctx.getChunk(ChunkKey.fromString(meta.getFragment(0))); InputStream in = new ChunkInputStream(meta, ctx, pos, pc); in = new BufferedInputStream(new InflaterInputStream(in), 8192); return new ObjectStream.Filter(type, sz, in); }
@Override public ObjectStream openStream() throws MissingObjectException, IOException { PackChunk pc = firstChunk; if (pc != null) firstChunk = null; else pc = ctx.getChunk(ChunkKey.fromString(meta.getFragment(0))); InputStream in = new ChunkInputStream(meta, ctx, pos, pc); in = new BufferedInputStream(new InflaterInputStream(in), 8192); return new ObjectStream.Filter(type, sz, in); }
@Override public ObjectLoader open(AnyObjectId objId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException { ObjectLoader ldr = recentChunks.open(repo, objId, typeHint); if (ldr != null) return ldr; ChunkAndOffset p = getChunk(objId, typeHint, false); ldr = PackChunk.read(p.chunk, p.offset, this, typeHint); recentChunk(p.chunk); return ldr; }
@Override public ObjectLoader open(AnyObjectId objId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException { ObjectLoader ldr = recentChunks.open(repo, objId, typeHint); if (ldr != null) return ldr; ChunkAndOffset p = getChunk(objId, typeHint, false); ldr = PackChunk.read(p.chunk, p.offset, this, typeHint); recentChunk(p.chunk); return ldr; }
@Override public int read(byte[] dstbuf, int dstptr, int dstlen) throws IOException { if (0 == dstlen) return 0; int n = pc.read(ptr, dstbuf, dstptr, dstlen); if (n == 0) { if (fragment == meta.getFragmentCount()) return -1; pc = ctx.getChunk(ChunkKey.fromString( meta.getFragment(++fragment))); ptr = 0; n = pc.read(ptr, dstbuf, dstptr, dstlen); if (n == 0) return -1; } ptr += n; return n; }
@Override public int read(byte[] dstbuf, int dstptr, int dstlen) throws IOException { if (0 == dstlen) return 0; int n = pc.read(ptr, dstbuf, dstptr, dstlen); if (n == 0) { if (fragment == meta.getFragmentCount()) return -1; pc = ctx.getChunk(ChunkKey.fromString( meta.getFragment(++fragment))); ptr = 0; n = pc.read(ptr, dstbuf, dstptr, dstlen); if (n == 0) return -1; } ptr += n; return n; }
if (meta.getFragmentCount() <= nextChunk) break; pc = reader.getChunk(ChunkKey.fromString( meta.getFragment(nextChunk++))); if (meta.getFragmentCount() == nextChunk)
if (meta.getFragmentCount() <= nextChunk) break; pc = reader.getChunk(ChunkKey.fromString( meta.getFragment(nextChunk++))); if (meta.getFragmentCount() == nextChunk)
public void copyObjectAsIs(PackOutputStream out, ObjectToPack otp, boolean validate) throws IOException, StoredObjectRepresentationNotAvailableException { DhtObjectToPack obj = (DhtObjectToPack) otp; try { PackChunk chunk = recentChunks.get(obj.chunk); if (chunk == null) { chunk = prefetcher.get(obj.chunk); if (chunk == null) { // This should never happen during packing, it implies // the fetch plan was incorrect. Unfortunately that can // occur if objects need to be recompressed on the fly. // stats.access(obj.chunk).cntCopyObjectAsIs_PrefetchMiss++; chunk = getChunk(obj.chunk); } if (!chunk.isFragment()) recentChunk(chunk); } chunk.copyObjectAsIs(out, obj, validate, this); } catch (DhtMissingChunkException missingChunk) { stats.access(missingChunk.getChunkKey()).cntCopyObjectAsIs_InvalidChunk++; throw new StoredObjectRepresentationNotAvailableException(otp); } }
int cnt = meta.getFragmentCount(); for (int fragId = 1; fragId < cnt; fragId++) { PackChunk pc = ctx.getChunk(ChunkKey.fromString( meta.getFragment(fragId))); pc.copyEntireChunkAsIs(out, obj, validate);
int cnt = meta.getFragmentCount(); for (int fragId = 1; fragId < cnt; fragId++) { PackChunk pc = ctx.getChunk(ChunkKey.fromString( meta.getFragment(fragId))); pc.copyEntireChunkAsIs(out, obj, validate);
public void copyObjectAsIs(PackOutputStream out, ObjectToPack otp, boolean validate) throws IOException, StoredObjectRepresentationNotAvailableException { DhtObjectToPack obj = (DhtObjectToPack) otp; try { PackChunk chunk = recentChunks.get(obj.chunk); if (chunk == null) { chunk = prefetcher.get(obj.chunk); if (chunk == null) { // This should never happen during packing, it implies // the fetch plan was incorrect. Unfortunately that can // occur if objects need to be recompressed on the fly. // stats.access(obj.chunk).cntCopyObjectAsIs_PrefetchMiss++; chunk = getChunk(obj.chunk); } if (!chunk.isFragment()) recentChunk(chunk); } chunk.copyObjectAsIs(out, obj, validate, this); } catch (DhtMissingChunkException missingChunk) { stats.access(missingChunk.getChunkKey()).cntCopyObjectAsIs_InvalidChunk++; throw new StoredObjectRepresentationNotAvailableException(otp); } }