CommitGraphWriter: Move bloom filter calculation out of createChunks
It looks confusing that the createChunks method calculates bloom filters. Make the calculations before and pass the result to the method. Change-Id: If6e3c0e644f7f940f268ca7266f577f012278ff3
This commit is contained in:
parent
e0bd4882fb
commit
f1a9d92a30
|
@ -40,6 +40,7 @@
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import org.eclipse.jgit.annotations.NonNull;
|
import org.eclipse.jgit.annotations.NonNull;
|
||||||
|
import org.eclipse.jgit.annotations.Nullable;
|
||||||
import org.eclipse.jgit.errors.CorruptObjectException;
|
import org.eclipse.jgit.errors.CorruptObjectException;
|
||||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||||
import org.eclipse.jgit.errors.MissingObjectException;
|
import org.eclipse.jgit.errors.MissingObjectException;
|
||||||
|
@ -122,7 +123,14 @@ public Stats write(@NonNull ProgressMonitor monitor,
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ChunkHeader> chunks = createChunks(stats);
|
BloomFilterChunks bloomFilterChunks = generateChangedPathFilters
|
||||||
|
? computeBloomFilterChunks(stats)
|
||||||
|
: null;
|
||||||
|
List<ChunkHeader> chunks = new ArrayList<>();
|
||||||
|
chunks.addAll(createCoreChunks(hashsz, graphCommits));
|
||||||
|
chunks.addAll(createBloomFilterChunkHeaders(bloomFilterChunks));
|
||||||
|
chunks = Collections.unmodifiableList(chunks);
|
||||||
|
|
||||||
long expectedSize = calculateExpectedSize(chunks);
|
long expectedSize = calculateExpectedSize(chunks);
|
||||||
long writeCount = 256 + 2 * graphCommits.size()
|
long writeCount = 256 + 2 * graphCommits.size()
|
||||||
+ graphCommits.getExtraEdgeCnt();
|
+ graphCommits.getExtraEdgeCnt();
|
||||||
|
@ -151,7 +159,7 @@ public Stats write(@NonNull ProgressMonitor monitor,
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ChunkHeader> createChunks(Stats stats)
|
private static List<ChunkHeader> createCoreChunks(int hashsz, GraphCommits graphCommits)
|
||||||
throws MissingObjectException,
|
throws MissingObjectException,
|
||||||
IncorrectObjectTypeException, CorruptObjectException, IOException {
|
IncorrectObjectTypeException, CorruptObjectException, IOException {
|
||||||
List<ChunkHeader> chunks = new ArrayList<>();
|
List<ChunkHeader> chunks = new ArrayList<>();
|
||||||
|
@ -164,9 +172,13 @@ private List<ChunkHeader> createChunks(Stats stats)
|
||||||
chunks.add(new ChunkHeader(CHUNK_ID_EXTRA_EDGE_LIST,
|
chunks.add(new ChunkHeader(CHUNK_ID_EXTRA_EDGE_LIST,
|
||||||
graphCommits.getExtraEdgeCnt() * 4));
|
graphCommits.getExtraEdgeCnt() * 4));
|
||||||
}
|
}
|
||||||
if (generateChangedPathFilters) {
|
return Collections.unmodifiableList(chunks);
|
||||||
BloomFilterChunks bloomFilterChunks = computeBloomFilterChunks(
|
}
|
||||||
stats);
|
|
||||||
|
private static List<ChunkHeader> createBloomFilterChunkHeaders(
|
||||||
|
@Nullable BloomFilterChunks bloomFilterChunks) {
|
||||||
|
List<ChunkHeader> chunks = new ArrayList<>();
|
||||||
|
if (bloomFilterChunks != null) {
|
||||||
chunks.add(new ChunkHeader(CHUNK_ID_BLOOM_FILTER_INDEX,
|
chunks.add(new ChunkHeader(CHUNK_ID_BLOOM_FILTER_INDEX,
|
||||||
bloomFilterChunks.index));
|
bloomFilterChunks.index));
|
||||||
chunks.add(new ChunkHeader(CHUNK_ID_BLOOM_FILTER_DATA,
|
chunks.add(new ChunkHeader(CHUNK_ID_BLOOM_FILTER_DATA,
|
||||||
|
|
Loading…
Reference in New Issue