DfsPackDescription b = fb.getPackDescription();
// GC, COMPACT reftables first by higher category.
- int c = category(b) - category(a);
+ int c = b.getPackSource().category - a.getPackSource().category;
if (c != 0) {
return c;
}
};
}
- static int category(DfsPackDescription d) {
- PackSource s = d.getPackSource();
- return s != null ? s.category : 0;
- }
-
/**
* Clears the cached list of packs, forcing them to be scanned again.
*/
import java.util.Arrays;
+import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource;
import org.eclipse.jgit.internal.storage.pack.PackExt;
import org.eclipse.jgit.internal.storage.reftable.ReftableWriter;
* name of the pack file. Must end with ".pack".
* @param repoDesc
* description of the repo containing the pack file.
+ * @param packSource
+ * the source of the pack.
*/
- public DfsPackDescription(DfsRepositoryDescription repoDesc, String name) {
+ public DfsPackDescription(DfsRepositoryDescription repoDesc, String name,
+ @NonNull PackSource packSource) {
this.repoDesc = repoDesc;
int dot = name.lastIndexOf('.');
this.packName = (dot < 0) ? name : name.substring(0, dot);
+ this.packSource = packSource;
int extCnt = PackExt.values().length;
sizeMap = new long[extCnt];
*
* @return the source of the pack.
*/
+ @NonNull
public PackSource getPackSource() {
return packSource;
}
* the source of the pack.
* @return {@code this}
*/
- public DfsPackDescription setPackSource(PackSource source) {
+ public DfsPackDescription setPackSource(@NonNull PackSource source) {
packSource = source;
return this;
}
// Cluster by PackSource, pushing UNREACHABLE_GARBAGE to the end.
PackSource as = getPackSource();
PackSource bs = b.getPackSource();
- if (as != null && bs != null) {
- int cmp = as.category - bs.category;
- if (cmp != 0)
- return cmp;
+ int cmp = as.category - bs.category;
+ if (cmp != 0) {
+ return cmp;
}
// Tie break GC type packs by smallest first. There should be at most
// one of each source, but when multiple exist concurrent GCs may have
// run. Preferring the smaller file selects higher quality delta
// compression, placing less demand on the DfsBlockCache.
- if (as != null && as == bs && isGC(as)) {
- int cmp = Long.signum(getFileSize(PACK) - b.getFileSize(PACK));
+ if (as == bs && isGC(as)) {
+ cmp = Long.signum(getFileSize(PACK) - b.getFileSize(PACK));
if (cmp != 0) {
return cmp;
}
}
// Newer packs should sort first.
- int cmp = Long.signum(b.getLastModified() - getLastModified());
+ cmp = Long.signum(b.getLastModified() - getLastModified());
if (cmp != 0)
return cmp;
import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jgit.annotations.Nullable;
+import org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource;
import org.eclipse.jgit.internal.storage.pack.PackExt;
import org.eclipse.jgit.internal.storage.reftable.ReftableConfig;
import org.eclipse.jgit.lib.RefDatabase;
@Override
protected DfsPackDescription newPack(PackSource source) {
int id = packId.incrementAndGet();
- DfsPackDescription desc = new MemPack(
+ return new MemPack(
"pack-" + id + "-" + source.name(), //$NON-NLS-1$ //$NON-NLS-2$
- getRepository().getDescription());
- return desc.setPackSource(source);
+ getRepository().getDescription(),
+ source);
}
@Override
private static class MemPack extends DfsPackDescription {
final byte[][] fileMap = new byte[PackExt.values().length][];
- MemPack(String name, DfsRepositoryDescription repoDesc) {
- super(repoDesc, name);
+ MemPack(String name, DfsRepositoryDescription repoDesc, PackSource source) {
+ super(repoDesc, name, source);
}
void put(PackExt ext, byte[] data) {