use of com.google.gerrit.server.patch.gitfilediff.GitFileDiffCacheKey in project gerrit by GerritCodeReview.
the class GitFileDiffKeySerializerTest method roundTrip.
@Test
public void roundTrip() {
GitFileDiffCacheKey key = GitFileDiffCacheKey.builder().project(Project.nameKey("project/x")).oldTree(TREE_ID_1).newTree(TREE_ID_2).newFilePath("some_file.txt").renameScore(65).diffAlgorithm(DiffAlgorithm.HISTOGRAM_WITH_FALLBACK_MYERS).whitespace(Whitespace.IGNORE_ALL).useTimeout(true).build();
byte[] serialized = GitFileDiffCacheKey.Serializer.INSTANCE.serialize(key);
assertThat(GitFileDiffCacheKey.Serializer.INSTANCE.deserialize(serialized)).isEqualTo(key);
}
use of com.google.gerrit.server.patch.gitfilediff.GitFileDiffCacheKey in project gerrit by GerritCodeReview.
the class AllDiffsEvaluator method computeGitFileDiffs.
/**
* Computes the git diff for the git keys of the input map {@code keys} parameter. The computation
* uses the underlying {@link GitFileDiffCache}.
*/
private Map<FileDiffCacheKey, GitDiffEntity> computeGitFileDiffs(Map<FileDiffCacheKey, GitFileDiffCacheKey> keys) throws DiffNotAvailableException {
ImmutableMap.Builder<FileDiffCacheKey, GitDiffEntity> result = ImmutableMap.builderWithExpectedSize(keys.size());
ImmutableMap<GitFileDiffCacheKey, GitFileDiff> gitDiffs = gitCache.getAll(keys.values());
for (FileDiffCacheKey key : keys.keySet()) {
GitFileDiffCacheKey gitKey = keys.get(key);
GitFileDiff gitFileDiff = gitDiffs.get(gitKey);
result.put(key, GitDiffEntity.create(gitKey, gitFileDiff));
}
return result.build();
}
Aggregations