void copyPackAsIs(PackOutputStream out, DfsReader ctx) throws IOException { // If the length hasn't been determined yet, pin to set it. if (length == -1) { ctx.pin(this, 0); ctx.unpin(); } if (cache.shouldCopyThroughCache(length)) copyPackThroughCache(out, ctx); else copyPackBypassCache(out, ctx); }
/** {@inheritDoc} */ @Override public BatchRefUpdate newBatchUpdate() { DfsObjDatabase odb = getRepository().getObjectDatabase(); return new ReftableBatchRefUpdate(this, odb); }
private byte[] insertBuffer(long len) { byte[] buf = buffer(); if (len <= buf.length) return buf; if (len < db.getReaderOptions().getStreamFileThreshold()) { try { return new byte[(int) len]; } catch (OutOfMemoryError noMem) { return buf; } } return buf; }
private long beginObject(int type, long len) throws IOException { if (packOut == null) beginPack(); long offset = packOut.getCount(); packOut.beginObject(type, len); return offset; }
@Override boolean exists() throws IOException { DfsObjDatabase odb = getRepository().getObjectDatabase(); return odb.getReftables().length > 0; }
/** * Initialize a new DfsReader * * @param db * parent DfsObjDatabase. */ protected DfsReader(DfsObjDatabase db) { this.db = db; this.streamFileThreshold = db.getReaderOptions().getStreamFileThreshold(); }
private int objectsBefore() { int cnt = 0; for (DfsPackFile p : packsBefore) cnt += p.getPackDescription().getObjectCount(); return cnt; }
/** * Initialize a DFS repository. * * @param builder * description of the repository. */ protected DfsRepository(DfsRepositoryBuilder builder) { super(builder); this.config = new DfsConfig(); this.description = builder.getRepositoryDescription(); }
InMemoryRepository(Builder builder) { super(builder); objdb = new MemObjDatabase(this); refdb = new MemRefDatabase(); }
/** {@inheritDoc} */ @Override public RefRename newRename(String fromName, String toName) throws IOException { RefUpdate src = newUpdate(fromName, true); RefUpdate dst = newUpdate(toName, true); return new DfsRefRename(src, dst); }
private void writePackIndex() throws IOException { List<PackedObjectInfo> list = getSortedObjectList(null /* by ObjectId */); packIndex = objins.writePackIndex(packDsc, packHash, list); } }
private boolean hasImpl(PackList packList, AnyObjectId objectId) throws IOException { for (DfsPackFile pack : packList.packs) { if (pack == last || skipGarbagePack(pack)) continue; if (pack.hasObject(this, objectId)) { last = pack; return true; } } return false; }
private void initOutDesc(DfsObjDatabase objdb) throws IOException { if (outDesc == null) { outDesc = objdb.newPack(COMPACT, estimatePackSize()); } }
void pin(BlockBasedFile file, long position) throws IOException { if (block == null || !block.contains(file.key, position)) { // If memory is low, we may need what is in our window field to // be cleaned up by the GC during the get for the next window. // So we always clear it, even though we are just going to set // it again. block = null; block = file.getOrLoadBlock(position, this); } }