private List<DfsPackFile> garbagePacksForSelectRepresentation() throws IOException { DfsPackFile[] packs = db.getPacks(); List<DfsPackFile> garbage = new ArrayList<>(packs.length); for (DfsPackFile p : packs) { if (p.getPackDescription().getPackSource() == UNREACHABLE_GARBAGE) { garbage.add(p); } } return garbage; }
private List<DfsPackFile> sortPacksForSelectRepresentation() throws IOException { DfsPackFile[] packs = db.getPacks(); List<DfsPackFile> sorted = new ArrayList<>(packs.length); for (DfsPackFile p : packs) { if (p.getPackDescription().getPackSource() != UNREACHABLE_GARBAGE) { sorted.add(p); } } Collections.sort(sorted, PACK_SORT_FOR_REUSE); return sorted; }
/** {@inheritDoc} */ @Override public BitmapIndex getBitmapIndex() throws IOException { for (DfsPackFile pack : db.getPacks()) { PackBitmapIndex bitmapIndex = pack.getBitmapIndex(this); if (bitmapIndex != null) return new BitmapIndexImpl(bitmapIndex); } return null; }
/** {@inheritDoc} */ @Override public Collection<CachedPack> getCachedPacksAndUpdate( BitmapBuilder needBitmap) throws IOException { for (DfsPackFile pack : db.getPacks()) { PackBitmapIndex bitmapIndex = pack.getBitmapIndex(this); if (needBitmap.removeAllOrNone(bitmapIndex)) return Collections.<CachedPack> singletonList( new DfsCachedPack(pack)); } return Collections.emptyList(); }
private void readPacksBefore() throws IOException { DfsPackFile[] packs = objdb.getPacks(); packsBefore = new ArrayList<>(packs.length); expiredGarbagePacks = new ArrayList<>(packs.length); long now = SystemReader.getInstance().getCurrentTime(); for (DfsPackFile p : packs) { DfsPackDescription d = p.getPackDescription(); if (d.getPackSource() != UNREACHABLE_GARBAGE) { packsBefore.add(p); } else if (packIsExpiredGarbage(d, now)) { expiredGarbagePacks.add(p); } else if (packIsCoalesceableGarbage(d, now)) { packsBefore.add(p); } } }
private void checkPacks(ProgressMonitor pm, FsckError errors) throws IOException, FileNotFoundException { try (DfsReader ctx = objdb.newReader()) { for (DfsPackFile pack : objdb.getPacks()) { DfsPackDescription packDesc = pack.getPackDescription(); if (packDesc.getPackSource() == PackSource.UNREACHABLE_GARBAGE) { continue; } try (ReadableChannel rc = objdb.openFile(packDesc, PACK)) { verifyPack(pm, errors, ctx, pack, rc); } catch (MissingObjectException e) { errors.getMissingObjects().add(e.getObjectId()); } catch (CorruptPackIndexException e) { errors.getCorruptIndices().add(new CorruptIndex( pack.getPackDescription().getFileName(INDEX), e.getErrorType())); } } } checkGitModules(pm, errors); }
/** * Automatically select pack and reftables to be included, and add them. * <p> * Packs are selected based on size, smaller packs get included while bigger * ones are omitted. * * @return {@code this} * @throws java.io.IOException * existing packs cannot be read. */ public DfsPackCompactor autoAdd() throws IOException { DfsObjDatabase objdb = repo.getObjectDatabase(); for (DfsPackFile pack : objdb.getPacks()) { DfsPackDescription d = pack.getPackDescription(); if (d.getFileSize(PACK) < autoAddSize) add(pack); else exclude(pack); } if (reftableConfig != null) { for (DfsReftable table : objdb.getReftables()) { DfsPackDescription d = table.getPackDescription(); if (d.getPackSource() != GC && d.getFileSize(REFTABLE) < autoAddSize) { add(table); } } } return this; }
private List<DfsPackFile> sortPacksForSelectRepresentation() throws IOException { DfsPackFile[] packs = db.getPacks(); List<DfsPackFile> sorted = new ArrayList<>(packs.length); for (DfsPackFile p : packs) { if (p.getPackDescription().getPackSource() != UNREACHABLE_GARBAGE) { sorted.add(p); } } Collections.sort(sorted, PACK_SORT_FOR_REUSE); return sorted; }
private List<DfsPackFile> garbagePacksForSelectRepresentation() throws IOException { DfsPackFile[] packs = db.getPacks(); List<DfsPackFile> garbage = new ArrayList<>(packs.length); for (DfsPackFile p : packs) { if (p.getPackDescription().getPackSource() == UNREACHABLE_GARBAGE) { garbage.add(p); } } return garbage; }
/** {@inheritDoc} */ @Override public Collection<CachedPack> getCachedPacksAndUpdate( BitmapBuilder needBitmap) throws IOException { for (DfsPackFile pack : db.getPacks()) { PackBitmapIndex bitmapIndex = pack.getBitmapIndex(this); if (needBitmap.removeAllOrNone(bitmapIndex)) return Collections.<CachedPack> singletonList( new DfsCachedPack(pack)); } return Collections.emptyList(); }
@Override public BitmapIndex getBitmapIndex() throws IOException { for (DfsPackFile pack : db.getPacks()) { PackBitmapIndex bitmapIndex = pack.getBitmapIndex(this); if (bitmapIndex != null) return new BitmapIndexImpl(bitmapIndex); } return null; }
public Collection<CachedPack> getCachedPacksAndUpdate( BitmapBuilder needBitmap) throws IOException { for (DfsPackFile pack : db.getPacks()) { PackBitmapIndex bitmapIndex = pack.getBitmapIndex(this); if (needBitmap.removeAllOrNone(bitmapIndex)) return Collections.<CachedPack> singletonList( new DfsCachedPack(pack)); } return Collections.emptyList(); }
/** {@inheritDoc} */ @Override public BitmapIndex getBitmapIndex() throws IOException { for (DfsPackFile pack : db.getPacks()) { PackBitmapIndex bitmapIndex = pack.getBitmapIndex(this); if (bitmapIndex != null) return new BitmapIndexImpl(bitmapIndex); } return null; }
private void readPacksBefore() throws IOException { DfsPackFile[] packs = objdb.getPacks(); packsBefore = new ArrayList<DfsPackFile>(packs.length); expiredGarbagePacks = new ArrayList<DfsPackFile>(packs.length); long mostRecentGC = mostRecentGC(packs); long now = System.currentTimeMillis(); for (DfsPackFile p : packs) { DfsPackDescription d = p.getPackDescription(); if (d.getPackSource() != UNREACHABLE_GARBAGE) { packsBefore.add(p); } else if (packIsExpiredGarbage(d, mostRecentGC, now)) { expiredGarbagePacks.add(p); } else if (d.getFileSize(PackExt.PACK) < coalesceGarbageLimit) { packsBefore.add(p); } } }
private void readPacksBefore() throws IOException { DfsPackFile[] packs = objdb.getPacks(); packsBefore = new ArrayList<>(packs.length); expiredGarbagePacks = new ArrayList<>(packs.length); long now = SystemReader.getInstance().getCurrentTime(); for (DfsPackFile p : packs) { DfsPackDescription d = p.getPackDescription(); if (d.getPackSource() != UNREACHABLE_GARBAGE) { packsBefore.add(p); } else if (packIsExpiredGarbage(d, now)) { expiredGarbagePacks.add(p); } else if (packIsCoalesceableGarbage(d, now)) { packsBefore.add(p); } } }
/** * Automatically select packs to be included, and add them. * <p> * Packs are selected based on size, smaller packs get included while bigger * ones are omitted. * * @return {@code this} * @throws IOException * existing packs cannot be read. */ public DfsPackCompactor autoAdd() throws IOException { DfsObjDatabase objdb = repo.getObjectDatabase(); for (DfsPackFile pack : objdb.getPacks()) { DfsPackDescription d = pack.getPackDescription(); if (d.getFileSize(PACK) < autoAddSize) add(pack); else exclude(pack); } return this; }
public void selectObjectRepresentation(PackWriter packer, ProgressMonitor monitor, Iterable<ObjectToPack> objects) throws IOException, MissingObjectException { // Don't check dirty bit on PackList; assume ObjectToPacks all came from the // current list. for (DfsPackFile pack : db.getPacks()) { List<DfsObjectToPack> tmp = findAllFromPack(pack, objects); 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); } } } }
private void checkPacks(ProgressMonitor pm, FsckError errors) throws IOException, FileNotFoundException { try (DfsReader ctx = objdb.newReader()) { for (DfsPackFile pack : objdb.getPacks()) { DfsPackDescription packDesc = pack.getPackDescription(); if (packDesc.getPackSource() == PackSource.UNREACHABLE_GARBAGE) { continue; } try (ReadableChannel rc = objdb.openFile(packDesc, PACK)) { verifyPack(pm, errors, ctx, pack, rc); } catch (MissingObjectException e) { errors.getMissingObjects().add(e.getObjectId()); } catch (CorruptPackIndexException e) { errors.getCorruptIndices().add(new CorruptIndex( pack.getPackDescription().getFileName(INDEX), e.getErrorType())); } } } checkGitModules(pm, errors); }
/** * Automatically select pack and reftables to be included, and add them. * <p> * Packs are selected based on size, smaller packs get included while bigger * ones are omitted. * * @return {@code this} * @throws java.io.IOException * existing packs cannot be read. */ public DfsPackCompactor autoAdd() throws IOException { DfsObjDatabase objdb = repo.getObjectDatabase(); for (DfsPackFile pack : objdb.getPacks()) { DfsPackDescription d = pack.getPackDescription(); if (d.getFileSize(PACK) < autoAddSize) add(pack); else exclude(pack); } if (reftableConfig != null) { for (DfsReftable table : objdb.getReftables()) { DfsPackDescription d = table.getPackDescription(); if (d.getPackSource() != GC && d.getFileSize(REFTABLE) < autoAddSize) { add(table); } } } return this; }