Pack: open reverse index from file if present
The reverse index for a pack is still always computed if needed, which is slower than parsing it from a file. Supply the file path where the reverse index file might be so that it parsed instead of computed if the file is present. Change-Id: I8c60d970fd587341dfb2763fb87f1c586279f2a5 Signed-off-by: Anna Papitto <annapapitto@google.com>
This commit is contained in:
parent
2eba4e5b41
commit
f196c7a0e8
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
import static org.eclipse.jgit.internal.storage.pack.PackExt.INDEX;
|
import static org.eclipse.jgit.internal.storage.pack.PackExt.INDEX;
|
||||||
import static org.eclipse.jgit.internal.storage.pack.PackExt.KEEP;
|
import static org.eclipse.jgit.internal.storage.pack.PackExt.KEEP;
|
||||||
|
import static org.eclipse.jgit.internal.storage.pack.PackExt.REVERSE_INDEX;
|
||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -1150,8 +1151,15 @@ synchronized PackBitmapIndex getBitmapIndex() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized PackReverseIndex getReverseIdx() throws IOException {
|
private synchronized PackReverseIndex getReverseIdx() throws IOException {
|
||||||
if (reverseIdx == null)
|
if (invalid) {
|
||||||
reverseIdx = PackReverseIndexFactory.computeFromIndex(idx());
|
throw new PackInvalidException(packFile, invalidatingCause);
|
||||||
|
}
|
||||||
|
if (reverseIdx == null) {
|
||||||
|
PackFile reverseIndexFile = packFile.create(REVERSE_INDEX);
|
||||||
|
reverseIdx = PackReverseIndexFactory.openOrCompute(reverseIndexFile,
|
||||||
|
getObjectCount(), () -> getIndex());
|
||||||
|
reverseIdx.verifyPackChecksum(getPackFile().getPath());
|
||||||
|
}
|
||||||
return reverseIdx;
|
return reverseIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue