int findOffset(RepositoryKey repo, AnyObjectId objId) { if (key.getRepositoryId() == repo.asInt() && index != null) return index.findOffset(objId); return -1; }
@Override public void walkAdviceBeginCommits(RevWalk rw, Collection<RevCommit> roots) throws IOException { endPrefetch(); // Don't assign the prefetcher right away. Delay until its // configured as push might invoke our own methods that may // try to call back into the active prefetcher. // Prefetcher p = prefetch(OBJ_COMMIT, readerOptions.getWalkCommitsPrefetchRatio()); p.push(this, roots); prefetcher = p; }
PackChunk getChunk(ChunkKey key) throws DhtException { PackChunk chunk = recentChunks.get(key); if (chunk != null) return chunk; chunk = load(key); if (chunk != null) return chunk; throw new DhtMissingChunkException(key); }
DhtReader(DhtObjDatabase objdb) { this.repository = objdb.getRepository(); this.repo = objdb.getRepository().getRepositoryKey(); this.db = objdb.getDatabase(); this.readerOptions = objdb.getReaderOptions(); this.inserterOptions = objdb.getInserterOptions(); this.stats = new Statistics(); this.recentInfo = new RecentInfoCache(getOptions()); this.recentChunks = new RecentChunks(this); this.deltaBaseCache = new DeltaBaseCache(this); }
ChunkKey findChunk(AnyObjectId objId) throws DhtException { if (objId instanceof RefDataUtil.IdWithChunk) return ((RefDataUtil.IdWithChunk) objId).getChunkKey(); ChunkKey key = repository.getRefDatabase().findChunk(objId); if (key != null) return key; ChunkAndOffset r = recentChunks.find(repo, objId); if (r != null) return r.chunk.getChunkKey(); for (ObjectInfo link : find(objId)) return link.getChunkKey(); return null; }
@Override public void release() { reader.getRecentChunks().setMaxBytes(reader.getOptions().getChunkLimit()); prefetcher = null; currChunk = null; }
@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; }
private ChunkFormatter openChunk(int typeCode) throws DhtException { if (typeCode == 0) throw new DhtException("Invalid internal typeCode 0"); ChunkFormatter w = openChunks[typeCode]; if (w == null) { w = new ChunkFormatter(repo, options); w.setSource(GitStore.ChunkInfo.Source.RECEIVE); w.setObjectType(typeCode); openChunks[typeCode] = w; } return w; }
DeltaBaseCache(DhtReader reader) { stats = reader.getStatistics(); DhtReaderOptions options = reader.getOptions(); maxByteCount = options.getDeltaBaseCacheLimit(); table = new Slot[options.getDeltaBaseCacheSize()]; }
private Prefetcher prefetch(final int type, final int ratio) { int limit = readerOptions.getChunkLimit(); int prefetchLimit = (int) (limit * (ratio / 100.0)); recentChunks.setMaxBytes(limit - prefetchLimit); return new Prefetcher(this, type, prefetchLimit); }
@Override protected void onEndWholeObject(PackedObjectInfo info) throws IOException { boolean fragmented = currFragments != null; endOneObject(); DhtInfo oe = (DhtInfo) info; oe.chunkPtr = currChunkPtr; oe.packedSize = currPackedSize; oe.inflatedSize = currInflatedSize; oe.setType(currType); if (fragmented) oe.setFragmented(); }
@Override @SuppressWarnings("unchecked") public R build() throws IllegalArgumentException, DhtException, RepositoryNotFoundException { return (R) new DhtRepository(setup()); }
boolean has(RepositoryKey repo, AnyObjectId objId) { for (Node n = lruHead; n != null; n = n.next) { int pos = n.chunk.findOffset(repo, objId); if (0 <= pos) { hit(n); stats.recentChunks_Hits++; return true; } } return false; }
DhtReader(DhtObjDatabase objdb) { this.repository = objdb.getRepository(); this.repo = objdb.getRepository().getRepositoryKey(); this.db = objdb.getDatabase(); this.readerOptions = objdb.getReaderOptions(); this.inserterOptions = objdb.getInserterOptions(); this.stats = new Statistics(); this.recentInfo = new RecentInfoCache(getOptions()); this.recentChunks = new RecentChunks(this); this.deltaBaseCache = new DeltaBaseCache(this); }
@Override public void walkAdviceBeginCommits(RevWalk rw, Collection<RevCommit> roots) throws IOException { endPrefetch(); // Don't assign the prefetcher right away. Delay until its // configured as push might invoke our own methods that may // try to call back into the active prefetcher. // Prefetcher p = prefetch(OBJ_COMMIT, readerOptions.getWalkCommitsPrefetchRatio()); p.push(this, roots); prefetcher = p; }
int findOffset(RepositoryKey repo, AnyObjectId objId) { if (key.getRepositoryId() == repo.asInt() && index != null) return index.findOffset(objId); return -1; }
private Prefetcher prefetch(final int type, final int ratio) { int limit = readerOptions.getChunkLimit(); int prefetchLimit = (int) (limit * (ratio / 100.0)); recentChunks.setMaxBytes(limit - prefetchLimit); return new Prefetcher(this, type, prefetchLimit); }