/** * Scan and list all available pack files in the repository. * * @return list of available packs, with some additional metadata. The * returned array is shared with the implementation and must not be * modified by the caller. * @throws java.io.IOException * the pack list cannot be initialized. */ public PackList getPackList() throws IOException { return scanPacks(NO_PACKS); }
void addPack(DfsPackFile newPack) throws IOException { PackList o, n; do { o = packList.get(); if (o == NO_PACKS) { // The repository may not have needed any existing objects to // complete the current task of creating a pack (e.g. push of a // pack with no external deltas). Because we don't scan for // newly added packs on missed object lookups, scan now to // make sure all older packs are available in the packList. o = scanPacks(o); // Its possible the scan identified the pack we were asked to // add, as the pack was already committed via commitPack(). // If this is the case return without changing the list. for (DfsPackFile p : o.packs) { if (p.key.equals(newPack.key)) { return; } } } DfsPackFile[] packs = new DfsPackFile[1 + o.packs.length]; packs[0] = newPack; System.arraycopy(o.packs, 0, packs, 1, o.packs.length); n = new PackListImpl(packs, o.reftables); } while (!packList.compareAndSet(o, n)); }
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; }
void addReftable(DfsPackDescription add, Set<DfsPackDescription> remove) throws IOException { PackList o, n; do { o = packList.get(); if (o == NO_PACKS) { o = scanPacks(o); for (DfsReftable t : o.reftables) { if (t.getPackDescription().equals(add)) { return; } } } List<DfsReftable> tables = new ArrayList<>(1 + o.reftables.length); for (DfsReftable t : o.reftables) { if (!remove.contains(t.getPackDescription())) { tables.add(t); } } tables.add(new DfsReftable(add)); n = new PackListImpl(o.packs, tables.toArray(new DfsReftable[0])); } while (!packList.compareAndSet(o, n)); }
/** {@inheritDoc} */ @Override public Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException { if (id.isComplete()) return Collections.singleton(id.toObjectId()); HashSet<ObjectId> matches = new HashSet<>(4); PackList packList = db.getPackList(); resolveImpl(packList, id, matches); if (matches.size() < MAX_RESOLVE_MATCHES && packList.dirty()) { stats.scanPacks++; resolveImpl(db.scanPacks(packList), id, matches); } return matches; }
/** {@inheritDoc} */ @Override public boolean has(AnyObjectId objectId) throws IOException { if (last != null && !skipGarbagePack(last) && last.hasObject(this, objectId)) return true; PackList packList = db.getPackList(); if (hasImpl(packList, objectId)) { return true; } else if (packList.dirty()) { stats.scanPacks++; return hasImpl(db.scanPacks(packList), objectId); } return false; }
/** * Scan and list all available pack files in the repository. * * @return list of available packs, with some additional metadata. The * returned array is shared with the implementation and must not be * modified by the caller. * @throws IOException * the pack list cannot be initialized. */ public PackList getPackList() throws IOException { return scanPacks(NO_PACKS); }
/** * Scan and list all available pack files in the repository. * * @return list of available packs, with some additional metadata. The * returned array is shared with the implementation and must not be * modified by the caller. * @throws java.io.IOException * the pack list cannot be initialized. */ public PackList getPackList() throws IOException { return scanPacks(NO_PACKS); }
/** {@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); }
void addPack(DfsPackFile newPack) throws IOException { PackList o, n; do { o = packList.get(); if (o == NO_PACKS) { // The repository may not have needed any existing objects to // complete the current task of creating a pack (e.g. push of a // pack with no external deltas). Because we don't scan for // newly added packs on missed object lookups, scan now to // make sure all older packs are available in the packList. o = scanPacks(o); // Its possible the scan identified the pack we were asked to // add, as the pack was already committed via commitPack(). // If this is the case return without changing the list. for (DfsPackFile p : o.packs) { if (p == newPack) return; } } DfsPackFile[] packs = new DfsPackFile[1 + o.packs.length]; packs[0] = newPack; System.arraycopy(o.packs, 0, packs, 1, o.packs.length); n = new PackListImpl(packs); } while (!packList.compareAndSet(o, n)); }
void addPack(DfsPackFile newPack) throws IOException { PackList o, n; do { o = packList.get(); if (o == NO_PACKS) { // The repository may not have needed any existing objects to // complete the current task of creating a pack (e.g. push of a // pack with no external deltas). Because we don't scan for // newly added packs on missed object lookups, scan now to // make sure all older packs are available in the packList. o = scanPacks(o); // Its possible the scan identified the pack we were asked to // add, as the pack was already committed via commitPack(). // If this is the case return without changing the list. for (DfsPackFile p : o.packs) { if (p.key.equals(newPack.key)) { return; } } } DfsPackFile[] packs = new DfsPackFile[1 + o.packs.length]; packs[0] = newPack; System.arraycopy(o.packs, 0, packs, 1, o.packs.length); n = new PackListImpl(packs, o.reftables); } while (!packList.compareAndSet(o, n)); }
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()) { findAllImpl(db.scanPacks(packList), pending, r); } for (T t : pending) { r.add(new FoundObject<T>(t)); } Collections.sort(r, FOUND_OBJECT_SORT); return r; }
void addReftable(DfsPackDescription add, Set<DfsPackDescription> remove) throws IOException { PackList o, n; do { o = packList.get(); if (o == NO_PACKS) { o = scanPacks(o); for (DfsReftable t : o.reftables) { if (t.getPackDescription().equals(add)) { return; } } } List<DfsReftable> tables = new ArrayList<>(1 + o.reftables.length); for (DfsReftable t : o.reftables) { if (!remove.contains(t.getPackDescription())) { tables.add(t); } } tables.add(new DfsReftable(add)); n = new PackListImpl(o.packs, tables.toArray(new DfsReftable[0])); } while (!packList.compareAndSet(o, n)); }
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; }
@Override public Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException { if (id.isComplete()) return Collections.singleton(id.toObjectId()); boolean noGarbage = avoidUnreachable; HashSet<ObjectId> matches = new HashSet<ObjectId>(4); PackList packList = db.getPackList(); resolveImpl(packList, id, noGarbage, matches); if (matches.size() < MAX_RESOLVE_MATCHES && packList.dirty()) { resolveImpl(db.scanPacks(packList), id, noGarbage, matches); } return matches; }
/** {@inheritDoc} */ @Override public Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException { if (id.isComplete()) return Collections.singleton(id.toObjectId()); HashSet<ObjectId> matches = new HashSet<>(4); PackList packList = db.getPackList(); resolveImpl(packList, id, matches); if (matches.size() < MAX_RESOLVE_MATCHES && packList.dirty()) { stats.scanPacks++; resolveImpl(db.scanPacks(packList), id, matches); } return matches; }
@Override public boolean has(AnyObjectId objectId) throws IOException { if (last != null && last.hasObject(this, objectId)) return true; boolean noGarbage = avoidUnreachable; PackList packList = db.getPackList(); if (hasImpl(packList, objectId, noGarbage)) { return true; } else if (packList.dirty()) { return hasImpl(db.scanPacks(packList), objectId, noGarbage); } return false; }
/** {@inheritDoc} */ @Override public boolean has(AnyObjectId objectId) throws IOException { if (last != null && !skipGarbagePack(last) && last.hasObject(this, objectId)) return true; PackList packList = db.getPackList(); if (hasImpl(packList, objectId)) { return true; } else if (packList.dirty()) { stats.scanPacks++; return hasImpl(db.scanPacks(packList), objectId); } return false; }
@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); }
/** {@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); }