Search in sources :

Example 1 with GitFileDiffCacheKey

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);
}
Also used : GitFileDiffCacheKey(com.google.gerrit.server.patch.gitfilediff.GitFileDiffCacheKey) Test(org.junit.Test)

Example 2 with GitFileDiffCacheKey

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();
}
Also used : GitFileDiffCacheKey(com.google.gerrit.server.patch.gitfilediff.GitFileDiffCacheKey) GitFileDiff(com.google.gerrit.server.patch.gitfilediff.GitFileDiff) GitFileDiffCacheKey(com.google.gerrit.server.patch.gitfilediff.GitFileDiffCacheKey) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

GitFileDiffCacheKey (com.google.gerrit.server.patch.gitfilediff.GitFileDiffCacheKey)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 GitFileDiff (com.google.gerrit.server.patch.gitfilediff.GitFileDiff)1 Test (org.junit.Test)1