Class SimilarityRenameDetector
- java.lang.Object
-
- org.eclipse.jgit.diff.SimilarityRenameDetector
-
class SimilarityRenameDetector extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static intBITS_PER_INDEXNumber of bits we need to express an index into src or dst list.private java.util.List<DiffEntry>dstsAll destinations to consider looking for a rename.private static intINDEX_MASKprivate long[]matrixMatrix of all examined file pairs, and their scores.private java.util.List<DiffEntry>outprivate ContentSource.Pairreaderprivate intrenameScoreScore a pair must exceed to be considered a rename.private static intSCORE_SHIFTprivate java.util.List<DiffEntry>srcsAll sources to consider for copies or renames.private booleantableOverflowSet if anySimilarityIndex.TableFullExceptionoccurs.
-
Constructor Summary
Constructors Constructor Description SimilarityRenameDetector(ContentSource.Pair reader, java.util.List<DiffEntry> srcs, java.util.List<DiffEntry> dsts)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private intbuildMatrix(ProgressMonitor pm)private static java.util.List<DiffEntry>compactDstList(java.util.List<DiffEntry> in)private static java.util.List<DiffEntry>compactSrcList(java.util.List<DiffEntry> in)(package private) voidcompute(ProgressMonitor pm)private static intdecodeFile(int v)(package private) static intdstFile(long value)(package private) static longencode(int score, int srcIdx, int dstIdx)private static longencodeFile(int idx)(package private) java.util.List<DiffEntry>getLeftOverDestinations()(package private) java.util.List<DiffEntry>getLeftOverSources()(package private) java.util.List<DiffEntry>getMatches()private SimilarityIndexhash(DiffEntry.Side side, DiffEntry ent)private static booleanisFile(FileMode mode)(package private) booleanisTableOverflow()(package private) static intnameScore(java.lang.String a, java.lang.String b)private static intscore(long value)(package private) voidsetRenameScore(int score)private longsize(DiffEntry.Side side, DiffEntry ent)(package private) static intsrcFile(long value)
-
-
-
Field Detail
-
BITS_PER_INDEX
private static final int BITS_PER_INDEX
Number of bits we need to express an index into src or dst list.This must be 28, giving us a limit of 2^28 entries in either list, which is an insane limit of 536,870,912 file names being considered in a single rename pass. The other 8 bits are used to store the score, while staying under 127 so the long doesn't go negative.
- See Also:
- Constant Field Values
-
INDEX_MASK
private static final int INDEX_MASK
- See Also:
- Constant Field Values
-
SCORE_SHIFT
private static final int SCORE_SHIFT
- See Also:
- Constant Field Values
-
reader
private ContentSource.Pair reader
-
srcs
private java.util.List<DiffEntry> srcs
All sources to consider for copies or renames.A source is typically a
DiffEntry.ChangeType.DELETEchange, but could be another type when trying to perform copy detection concurrently with rename detection.
-
dsts
private java.util.List<DiffEntry> dsts
All destinations to consider looking for a rename.A destination is typically an
DiffEntry.ChangeType.ADD, as the name has just come into existence, and we want to discover where its initial content came from.
-
matrix
private long[] matrix
Matrix of all examined file pairs, and their scores.The upper 8 bits of each long stores the score, but the score is bounded to be in the range (0, 128] so that the highest bit is never set, and all entries are therefore positive.
List indexes to an element of
srcsanddstsare encoded as the lower two groups of 28 bits, respectively, but the encoding is inverted, so that 0 is expressed as(1 << 28) - 1. This sorts lower list indices later in the matrix, giving precedence to files whose names sort earlier in the tree.
-
renameScore
private int renameScore
Score a pair must exceed to be considered a rename.
-
tableOverflow
private boolean tableOverflow
Set if anySimilarityIndex.TableFullExceptionoccurs.
-
out
private java.util.List<DiffEntry> out
-
-
Constructor Detail
-
SimilarityRenameDetector
SimilarityRenameDetector(ContentSource.Pair reader, java.util.List<DiffEntry> srcs, java.util.List<DiffEntry> dsts)
-
-
Method Detail
-
setRenameScore
void setRenameScore(int score)
-
compute
void compute(ProgressMonitor pm) throws java.io.IOException, CancelledException
- Throws:
java.io.IOExceptionCancelledException
-
getMatches
java.util.List<DiffEntry> getMatches()
-
getLeftOverSources
java.util.List<DiffEntry> getLeftOverSources()
-
getLeftOverDestinations
java.util.List<DiffEntry> getLeftOverDestinations()
-
isTableOverflow
boolean isTableOverflow()
-
compactSrcList
private static java.util.List<DiffEntry> compactSrcList(java.util.List<DiffEntry> in)
-
compactDstList
private static java.util.List<DiffEntry> compactDstList(java.util.List<DiffEntry> in)
-
buildMatrix
private int buildMatrix(ProgressMonitor pm) throws java.io.IOException, CancelledException
- Throws:
java.io.IOExceptionCancelledException
-
nameScore
static int nameScore(java.lang.String a, java.lang.String b)
-
hash
private SimilarityIndex hash(DiffEntry.Side side, DiffEntry ent) throws java.io.IOException, SimilarityIndex.TableFullException
- Throws:
java.io.IOExceptionSimilarityIndex.TableFullException
-
size
private long size(DiffEntry.Side side, DiffEntry ent) throws java.io.IOException
- Throws:
java.io.IOException
-
score
private static int score(long value)
-
srcFile
static int srcFile(long value)
-
dstFile
static int dstFile(long value)
-
encode
static long encode(int score, int srcIdx, int dstIdx)
-
encodeFile
private static long encodeFile(int idx)
-
decodeFile
private static int decodeFile(int v)
-
isFile
private static boolean isFile(FileMode mode)
-
-