Skip to content

History cache per partes #3589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 69 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
61a50bc
proof of concept: split history cache generation into chunks
Apr 16, 2021
2efe930
cleanup: refreshing latest version in the cache should not be necessary
Apr 16, 2021
f6142a0
add repository to the log message
Apr 19, 2021
5f5fe33
introduce getPerPartesCount()
Apr 19, 2021
fcb55a5
update comment
Apr 19, 2021
fb94b74
finish removal of per directory cache
Apr 19, 2021
8edaf1e
introduce boundary changesets
May 14, 2021
f445546
restore renamed file handling
May 14, 2021
33ec202
restore renamed file handling
May 14, 2021
159aa8c
cleanup history remnants
May 14, 2021
29b43c8
remove unused import
May 14, 2021
10c1cdf
address Windows
May 17, 2021
e010100
add basic test for boundary changesets
May 17, 2021
50a1f9b
also test non null sinceRevision
May 17, 2021
6152897
add from,to reivision to the log entry
May 17, 2021
e7cc3e2
cleanup unused
May 17, 2021
7e03023
logging changes
May 17, 2021
564c243
add getHistory() test w.r.t. boundary changesets
May 17, 2021
c6d71d5
add TODO
May 17, 2021
7722e30
history of renamed files has to be handled specially for per partes
May 17, 2021
36275ac
avoid warning
May 17, 2021
7eaaf0d
add test for renamed file handling with per partes
May 17, 2021
e914fb9
remove unused import
May 17, 2021
0a28130
make sure the renamed was detected
May 17, 2021
3bd931f
do not produce list of files for history of single file
May 18, 2021
dd391e5
add tests for GitRepository.getHistory(file, sinceRev, tillRev)
May 18, 2021
1f89bfb
update Javadoc
May 18, 2021
ce2e23b
cleanup renamed file handling remnants
May 18, 2021
a4318dd
remove unused import
May 18, 2021
91d3199
cleanup
May 18, 2021
7244ebf
cleanup
May 18, 2021
b9d18d4
cleanup
May 18, 2021
2f0e568
remove unused imports
May 18, 2021
3a6c20b
add javadoc
May 18, 2021
4549566
update doc
May 18, 2021
331e234
remove TODO
May 18, 2021
abef0ad
add changesets to the comment
May 18, 2021
a75402c
add comment
May 18, 2021
66c385c
fix explanation
May 18, 2021
fc289a1
add comment
May 18, 2021
c0a2f1e
add comment
May 18, 2021
063389b
fix comment
May 18, 2021
442d527
remove extra blank line
May 18, 2021
7ab00e6
another extra blank line
May 18, 2021
40a1044
fix comments
May 18, 2021
2c05efb
add test for single incoming changeset
May 18, 2021
e97ca3e
cleanup
May 18, 2021
12f5629
fix javadoc
May 18, 2021
1d8d051
add missing log argument
May 19, 2021
a33f93e
introduce constants for maximum changeset count
May 19, 2021
5348963
remove lastId, it is not actually used
May 19, 2021
d3aaf8b
restore final for renamedFiles
May 19, 2021
28e0c85
refactor getFilesForCommit(), add javadoc
May 19, 2021
380f2dd
use Arrays.asList(), fix javadoc
May 19, 2021
16a9285
rename interface name
May 19, 2021
2c423cb
fix javadoc
May 19, 2021
2e64b55
use Consumer instead of the visitor interface
May 19, 2021
ed04e63
remove unused import
May 19, 2021
f4ccdec
cleanup git version check
May 19, 2021
a891ef4
more JGit related cleanup
May 19, 2021
7672dc8
remove unused import
May 19, 2021
e90f4dc
add missing @throws to javadoc
May 19, 2021
8f7ac7f
fix javadoc
May 19, 2021
345832e
remove stale reference from javadoc
May 19, 2021
1b97072
use List.copyOf() to return results
May 19, 2021
8e67531
revert List.copyOf()
May 19, 2021
692b14e
refactor cache creation to avoid instanceOf
May 19, 2021
e102e45
remove unused import
May 19, 2021
0d4e166
List.copyOf() redux
May 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/

/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
*/
package org.opengrok.indexer.history;

import org.opengrok.indexer.logger.LoggerFactory;
import org.opengrok.indexer.util.Statistics;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* Helper class to split sequence of VCS changesets into number of intervals.
* This is then used in {@link Repository#createCache(HistoryCache, String)}
* to store history in chunks, for VCS repositories that support this.
*/
public class BoundaryChangesets {
private int cnt = 0;
private final List<String> result = new ArrayList<>();

private final int maxCount;
private final RepositoryWithPerPartesHistory repository;

private static final Logger LOGGER = LoggerFactory.getLogger(BoundaryChangesets.class);

public BoundaryChangesets(RepositoryWithPerPartesHistory repository) {
this.repository = repository;
this.maxCount = repository.getPerPartesCount();
if (maxCount <= 1) {
throw new RuntimeException(String.format("per partes count for repository ''%s'' " +
"must be stricly greater than 1", repository.getDirectoryName()));
}
}

private void reset() {
cnt = 0;
result.clear();
}

/**
* @param sinceRevision start revision ID
* @return immutable list of revision IDs denoting the intervals
* @throws HistoryException if there is problem traversing the changesets in the repository
*/
public synchronized List<String> getBoundaryChangesetIDs(String sinceRevision) throws HistoryException {
reset();

LOGGER.log(Level.FINE, "getting boundary changesets for ''{0}''", repository.getDirectoryName());
Statistics stat = new Statistics();

repository.accept(sinceRevision, this::visit);

// The changesets need to go from oldest to newest.
Collections.reverse(result);

stat.report(LOGGER, Level.FINE,
String.format("done getting boundary changesets for ''%s'' (%d entries)",
repository.getDirectoryName(), result.size()));

return List.copyOf(result);
}

private void visit(String id) {
if (cnt != 0 && cnt % maxCount == 0) {
result.add(id);
}
cnt++;
}
}
Loading