PackBitmapIndex: Move BitmapCommit to a top-level class
Move BitmapCommit from inside the PackWriterBitmapPreparer to a new top-level class in preparation for improving the memory footprint of GC's bitmap generation phase. Change-Id: I4d404a5b3a34998b441d23105197f33d32d39670 Signed-off-by: Yunjie Li <yunjieli@google.com>
This commit is contained in:
parent
840e414d0b
commit
d23254ee57
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
import org.eclipse.jgit.internal.storage.file.GcTestCase;
|
import org.eclipse.jgit.internal.storage.file.GcTestCase;
|
||||||
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexBuilder;
|
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexBuilder;
|
||||||
import org.eclipse.jgit.internal.storage.pack.PackWriterBitmapPreparer.BitmapCommit;
|
|
||||||
import org.eclipse.jgit.junit.TestRepository.BranchBuilder;
|
import org.eclipse.jgit.junit.TestRepository.BranchBuilder;
|
||||||
import org.eclipse.jgit.junit.TestRepository.CommitBuilder;
|
import org.eclipse.jgit.junit.TestRepository.CommitBuilder;
|
||||||
import org.eclipse.jgit.lib.Constants;
|
import org.eclipse.jgit.lib.Constants;
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Google LLC and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Distribution License v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
package org.eclipse.jgit.internal.storage.pack;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.lib.AnyObjectId;
|
||||||
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A commit object for which a bitmap index should be built.
|
||||||
|
*/
|
||||||
|
public final class BitmapCommit extends ObjectId {
|
||||||
|
private final boolean reuseWalker;
|
||||||
|
private final int flags;
|
||||||
|
|
||||||
|
BitmapCommit(AnyObjectId objectId, boolean reuseWalker, int flags) {
|
||||||
|
super(objectId);
|
||||||
|
this.reuseWalker = reuseWalker;
|
||||||
|
this.flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isReuseWalker() {
|
||||||
|
return reuseWalker;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getFlags() {
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2313,14 +2313,14 @@ public boolean prepareBitmapIndex(ProgressMonitor pm) throws IOException {
|
||||||
PackWriterBitmapPreparer bitmapPreparer = new PackWriterBitmapPreparer(
|
PackWriterBitmapPreparer bitmapPreparer = new PackWriterBitmapPreparer(
|
||||||
reader, writeBitmaps, pm, stats.interestingObjects, config);
|
reader, writeBitmaps, pm, stats.interestingObjects, config);
|
||||||
|
|
||||||
Collection<PackWriterBitmapPreparer.BitmapCommit> selectedCommits = bitmapPreparer
|
Collection<BitmapCommit> selectedCommits = bitmapPreparer
|
||||||
.selectCommits(numCommits, excludeFromBitmapSelection);
|
.selectCommits(numCommits, excludeFromBitmapSelection);
|
||||||
|
|
||||||
beginPhase(PackingPhase.BUILDING_BITMAPS, pm, selectedCommits.size());
|
beginPhase(PackingPhase.BUILDING_BITMAPS, pm, selectedCommits.size());
|
||||||
|
|
||||||
BitmapWalker walker = bitmapPreparer.newBitmapWalker();
|
BitmapWalker walker = bitmapPreparer.newBitmapWalker();
|
||||||
AnyObjectId last = null;
|
AnyObjectId last = null;
|
||||||
for (PackWriterBitmapPreparer.BitmapCommit cmit : selectedCommits) {
|
for (BitmapCommit cmit : selectedCommits) {
|
||||||
if (!cmit.isReuseWalker()) {
|
if (!cmit.isReuseWalker()) {
|
||||||
walker = bitmapPreparer.newBitmapWalker();
|
walker = bitmapPreparer.newBitmapWalker();
|
||||||
}
|
}
|
||||||
|
|
|
@ -467,28 +467,6 @@ BitmapWalker newBitmapWalker() {
|
||||||
new ObjectWalk(reader), bitmapIndex, null);
|
new ObjectWalk(reader), bitmapIndex, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A commit object for which a bitmap index should be built.
|
|
||||||
*/
|
|
||||||
static final class BitmapCommit extends ObjectId {
|
|
||||||
private final boolean reuseWalker;
|
|
||||||
private final int flags;
|
|
||||||
|
|
||||||
BitmapCommit(AnyObjectId objectId, boolean reuseWalker, int flags) {
|
|
||||||
super(objectId);
|
|
||||||
this.reuseWalker = reuseWalker;
|
|
||||||
this.flags = flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isReuseWalker() {
|
|
||||||
return reuseWalker;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getFlags() {
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for state used in the first phase of selecting commits, which
|
* Container for state used in the first phase of selecting commits, which
|
||||||
* walks all of the reachable commits via the branch tips that are not
|
* walks all of the reachable commits via the branch tips that are not
|
||||||
|
|
Loading…
Reference in New Issue