/** {@inheritDoc} */ @Override public DfsReader newReader() { return new DfsReader(this); }
/** {@inheritDoc} */ @Override public ObjectLoader open(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException { ObjectLoader ldr; if (last != null && !skipGarbagePack(last)) { ldr = last.get(this, objectId); if (ldr != null) { return checkType(ldr, objectId, typeHint); } } PackList packList = db.getPackList(); ldr = openImpl(packList, objectId); if (ldr != null) { return checkType(ldr, objectId, typeHint); } if (packList.dirty()) { stats.scanPacks++; ldr = openImpl(db.scanPacks(packList), objectId); if (ldr != null) { return checkType(ldr, objectId, typeHint); } } if (typeHint == OBJ_ANY) throw new MissingObjectException(objectId.copy(), JGitText.get().unknownObjectType2); throw new MissingObjectException(objectId.copy(), typeHint); }
@Override public ObjectStream openStream() throws IOException { @SuppressWarnings("resource") // Explicitly closed below final DfsReader ctx = db.newReader(); if (srcPack != packKey) { try { // Post DfsInserter.flush() use the normal code path. // The newly created pack is registered in the cache. return ctx.open(id, type).openStream(); } finally { ctx.close(); } } int bufsz = 8192; final Inflater inf = ctx.inflater(); return new ObjectStream.Filter(type, size, new BufferedInputStream(new InflaterInputStream( new ReadBackStream(pos), inf, bufsz), bufsz)) { @Override public void close() throws IOException { ctx.close(); super.close(); } }; }
/** {@inheritDoc} */ @Override public long getObjectSize(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException { if (last != null && !skipGarbagePack(last)) { long sz = last.getObjectSize(this, objectId); if (0 <= sz) { return sz; } } PackList packList = db.getPackList(); long sz = getObjectSizeImpl(packList, objectId); if (0 <= sz) { return sz; } if (packList.dirty()) { sz = getObjectSizeImpl(packList, objectId); if (0 <= sz) { return sz; } } if (typeHint == OBJ_ANY) { throw new MissingObjectException(objectId.copy(), JGitText.get().unknownObjectType2); } throw new MissingObjectException(objectId.copy(), typeHint); }
@Override public ObjectStream openStream() throws IOException { final DfsReader ctx = new DfsReader(db); if (srcPack != packKey) { try { // Post DfsInserter.flush() use the normal code path. // The newly created pack is registered in the cache. return ctx.open(id, type).openStream(); } finally { ctx.close(); } } int bufsz = 8192; final Inflater inf = ctx.inflater(); return new ObjectStream.Filter(type, size, new BufferedInputStream(new InflaterInputStream( new ReadBackStream(pos), inf, bufsz), bufsz)) { @Override public void close() throws IOException { ctx.close(); super.close(); } }; }
@Override public void close() { ctx.close(); } }
if (sz < ctx.getStreamFileThreshold()) { data = decompress(pos + p, (int) sz, ctx); if (data != null) break SEARCH; DeltaBaseCache.Entry e = ctx.getDeltaBaseCache().get(key, base); if (e != null) { type = e.type; break SEARCH; DeltaBaseCache.Entry e = ctx.getDeltaBaseCache().get(key, base); if (e != null) { type = e.type; cached = false; else if (delta.next == null) ctx.getDeltaBaseCache().put(key, delta.basePos, type, data);
@Override public void adviseSequentialRead(long start, long end) { int sz = ctx.getOptions().getStreamPackBufferSize(); if (sz > 0) { readAhead = (int) Math.min(sz, end - start); } }
/** {@inheritDoc} */ @Override public int read(byte[] b, int off, int len) throws IOException { int n = ctx.copy(pack, pos, b, off, len); pos += n; return n; }
@Override public ObjectLoader open(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException { ObjectLoader ldr; if (last != null) { ldr = last.get(this, objectId); if (ldr != null) { return checkType(ldr, objectId, typeHint); } } PackList packList = db.getPackList(); boolean noGarbage = avoidUnreachable; ldr = openImpl(packList, objectId, noGarbage); if (ldr != null) { return checkType(ldr, objectId, typeHint); } if (packList.dirty()) { ldr = openImpl(db.scanPacks(packList), objectId, noGarbage); if (ldr != null) { return checkType(ldr, objectId, typeHint); } } if (typeHint == OBJ_ANY) throw new MissingObjectException(objectId.copy(), JGitText.get().unknownObjectType2); throw new MissingObjectException(objectId.copy(), typeHint); }
IOException error = null; try { order = findAll(objectIds); } catch (IOException e) { order = Collections.emptyList();
private <T extends ObjectId> Iterable<FoundObject<T>> findAll( Iterable<T> objectIds) throws IOException { Collection<T> pending = new LinkedList<>(); for (T id : objectIds) { pending.add(id); } PackList packList = db.getPackList(); List<FoundObject<T>> r = new ArrayList<>(); findAllImpl(packList, pending, r); if (!pending.isEmpty() && packList.dirty()) { stats.scanPacks++; findAllImpl(db.scanPacks(packList), pending, r); } for (T t : pending) { r.add(new FoundObject<>(t)); } Collections.sort(r, FOUND_OBJECT_SORT); return r; }
private void trySelectRepresentation(PackWriter packer, ProgressMonitor monitor, Iterable<ObjectToPack> objects, List<DfsPackFile> packs, boolean skipFound) throws IOException { for (DfsPackFile pack : packs) { List<DfsObjectToPack> tmp = findAllFromPack(pack, objects, skipFound); if (tmp.isEmpty()) continue; Collections.sort(tmp, OFFSET_SORT); PackReverseIndex rev = pack.getReverseIdx(this); DfsObjectRepresentation rep = new DfsObjectRepresentation(pack); for (DfsObjectToPack otp : tmp) { pack.representation(rep, otp.getOffset(), this, rev); otp.setOffset(0); packer.select(otp, rep); if (!otp.isFound()) { otp.setFound(); monitor.update(1); } } } }
@Override public long getObjectSize(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException { if (last != null) { long sz = last.getObjectSize(this, objectId); if (0 <= sz) { return sz; } } PackList packList = db.getPackList(); long sz = getObjectSizeImpl(packList, objectId); if (0 <= sz) { return sz; } if (packList.dirty()) { sz = getObjectSizeImpl(packList, objectId); if (0 <= sz) { return sz; } } if (typeHint == OBJ_ANY) { throw new MissingObjectException(objectId.copy(), JGitText.get().unknownObjectType2); } throw new MissingObjectException(objectId.copy(), typeHint); }
@Override public ObjectStream openStream() throws MissingObjectException, IOException { DfsReader ctx = new DfsReader(db); InputStream in; try { return ctx.open(obj, type).openStream(); } finally { ctx.close(); ctx.close(); new InflaterInputStream(in, ctx.inflater(), bufsz), bufsz); return new ObjectStream.Filter(type, size, in);
/** {@inheritDoc} */ @Override public void close() { ctx.close(); } }
if (sz < ctx.getStreamFileThreshold()) { data = decompress(pos + p, (int) sz, ctx); if (data != null) break SEARCH; DeltaBaseCache.Entry e = ctx.getDeltaBaseCache().get(key, base); if (e != null) { type = e.type; break SEARCH; DeltaBaseCache.Entry e = ctx.getDeltaBaseCache().get(key, base); if (e != null) { type = e.type; cached = false; else if (delta.next == null) ctx.getDeltaBaseCache().put(key, delta.basePos, type, data);
DeltaBaseCache(DfsReader reader) { this(reader.getOptions().getDeltaBaseCacheLimit()); }
private void readFully(long position, byte[] dstbuf, int dstoff, int cnt, DfsReader ctx) throws IOException { if (ctx.copy(this, position, dstbuf, dstoff, cnt) != cnt) throw new EOFException(); }
IOException error = null; try { order = findAll(objectIds); } catch (IOException e) { order = Collections.emptyList();