-
Notifications
You must be signed in to change notification settings - Fork 779
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
History cache per partes #3589
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
2efe930
cleanup: refreshing latest version in the cache should not be necessary
f6142a0
add repository to the log message
5f5fe33
introduce getPerPartesCount()
fcb55a5
update comment
fb94b74
finish removal of per directory cache
8edaf1e
introduce boundary changesets
f445546
restore renamed file handling
33ec202
restore renamed file handling
159aa8c
cleanup history remnants
29b43c8
remove unused import
10c1cdf
address Windows
e010100
add basic test for boundary changesets
50a1f9b
also test non null sinceRevision
6152897
add from,to reivision to the log entry
e7cc3e2
cleanup unused
7e03023
logging changes
564c243
add getHistory() test w.r.t. boundary changesets
c6d71d5
add TODO
7722e30
history of renamed files has to be handled specially for per partes
36275ac
avoid warning
7eaaf0d
add test for renamed file handling with per partes
e914fb9
remove unused import
0a28130
make sure the renamed was detected
3bd931f
do not produce list of files for history of single file
dd391e5
add tests for GitRepository.getHistory(file, sinceRev, tillRev)
1f89bfb
update Javadoc
ce2e23b
cleanup renamed file handling remnants
a4318dd
remove unused import
91d3199
cleanup
7244ebf
cleanup
b9d18d4
cleanup
2f0e568
remove unused imports
3a6c20b
add javadoc
4549566
update doc
331e234
remove TODO
abef0ad
add changesets to the comment
a75402c
add comment
66c385c
fix explanation
fc289a1
add comment
c0a2f1e
add comment
063389b
fix comment
442d527
remove extra blank line
7ab00e6
another extra blank line
40a1044
fix comments
2c05efb
add test for single incoming changeset
e97ca3e
cleanup
12f5629
fix javadoc
1d8d051
add missing log argument
a33f93e
introduce constants for maximum changeset count
5348963
remove lastId, it is not actually used
d3aaf8b
restore final for renamedFiles
28e0c85
refactor getFilesForCommit(), add javadoc
380f2dd
use Arrays.asList(), fix javadoc
16a9285
rename interface name
2c423cb
fix javadoc
2e64b55
use Consumer instead of the visitor interface
ed04e63
remove unused import
f4ccdec
cleanup git version check
a891ef4
more JGit related cleanup
7672dc8
remove unused import
e90f4dc
add missing @throws to javadoc
8f7ac7f
fix javadoc
345832e
remove stale reference from javadoc
1b97072
use List.copyOf() to return results
8e67531
revert List.copyOf()
692b14e
refactor cache creation to avoid instanceOf
e102e45
remove unused import
0d4e166
List.copyOf() redux
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
opengrok-indexer/src/main/java/org/opengrok/indexer/history/BoundaryChangesets.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.