Top Fields Constructors Methods
org.eclipse.jgit.diff

pack-priv Class SimilarityRenameDetector

extends Object
Class Inheritance
Static Imports
org.eclipse.jgit.diff.DiffEntry.Side.NEW, .DiffEntry.Side.OLD, org.eclipse.jgit.storage.pack.PackConfig.DEFAULT_BIG_FILE_THRESHOLD

Field Summary

Modifier and TypeField and Description
private int
bigFileThreshold

File size threshold (in bytes) for detecting renames.

private static final int
BITS_PER_INDEX

Number of bits we need to express an index into src or dst list.

private List<DiffEntry>
dsts

All destinations to consider looking for a rename.

private static final int
private long[]
matrix

Matrix of all examined file pairs, and their scores.

private List<DiffEntry>
private ContentSource.Pair
private int
renameScore

Score a pair must exceed to be considered a rename.

private static final int
private boolean
skipBinaryFiles

Skip content renames for binary files.

private List<DiffEntry>
srcs

All sources to consider for copies or renames.

private boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private int
private static List<DiffEntry>
private static List<DiffEntry>
pack-priv void
private static int
decodeFile(int v)

pack-priv static int
dstFile(long value)

pack-priv static long
encode(int score, int srcIdx, int dstIdx)

private static long
encodeFile(int idx)

pack-priv List<DiffEntry>
pack-priv List<DiffEntry>
pack-priv List<DiffEntry>
private SimilarityIndex
hash(ObjectLoader objectLoader)

private static boolean
pack-priv boolean
pack-priv static int
private static int
score(long value)

pack-priv void
setBigFileThreshold(int threshold)

pack-priv void
setRenameScore(int score)

pack-priv void
setSkipBinaryFiles(boolean value)

private long
pack-priv static int
srcFile(long value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bigFileThresholdback to summary
private int bigFileThreshold

File size threshold (in bytes) for detecting renames. Files larger than this size will not be processed for renames.

BITS_PER_INDEXback to summary
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.

dstsback to summary
private List<DiffEntry> dsts

All destinations to consider looking for a rename.

A destination is typically an ChangeType#ADD, as the name has just come into existence, and we want to discover where its initial content came from.

INDEX_MASKback to summary
private static final int INDEX_MASK
matrixback to summary
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 srcs and dsts are 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.

outback to summary
private List<DiffEntry> out
readerback to summary
private ContentSource.Pair reader
renameScoreback to summary
private int renameScore

Score a pair must exceed to be considered a rename.

SCORE_SHIFTback to summary
private static final int SCORE_SHIFT
skipBinaryFilesback to summary
private boolean skipBinaryFiles

Skip content renames for binary files.

srcsback to summary
private List<DiffEntry> srcs

All sources to consider for copies or renames.

A source is typically a ChangeType#DELETE change, but could be another type when trying to perform copy detection concurrently with rename detection.

tableOverflowback to summary
private boolean tableOverflow

Set if any SimilarityIndex.TableFullException occurs.

Constructor Detail

SimilarityRenameDetectorback to summary
pack-priv SimilarityRenameDetector(ContentSource.Pair reader, List<DiffEntry> srcs, List<DiffEntry> dsts)

Method Detail

buildMatrixback to summary
private int buildMatrix(ProgressMonitor pm) throws IOException, CanceledException
compactDstListback to summary
private static List<DiffEntry> compactDstList(List<DiffEntry> in)
compactSrcListback to summary
private static List<DiffEntry> compactSrcList(List<DiffEntry> in)
computeback to summary
pack-priv void compute(ProgressMonitor pm) throws IOException, CanceledException
decodeFileback to summary
private static int decodeFile(int v)
Annotations
@SuppressWarnings:IntLongMath
dstFileback to summary
pack-priv static int dstFile(long value)
encodeback to summary
pack-priv static long encode(int score, int srcIdx, int dstIdx)
encodeFileback to summary
private static long encodeFile(int idx)
Annotations
@SuppressWarnings:IntLongMath
getLeftOverDestinationsback to summary
pack-priv List<DiffEntry> getLeftOverDestinations()
getLeftOverSourcesback to summary
pack-priv List<DiffEntry> getLeftOverSources()
getMatchesback to summary
pack-priv List<DiffEntry> getMatches()
hashback to summary
private SimilarityIndex hash(ObjectLoader objectLoader) throws IOException, TableFullException
isFileback to summary
private static boolean isFile(FileMode mode)
isTableOverflowback to summary
pack-priv boolean isTableOverflow()
nameScoreback to summary
pack-priv static int nameScore(String a, String b)
scoreback to summary
private static int score(long value)
setBigFileThresholdback to summary
pack-priv void setBigFileThreshold(int threshold)
setRenameScoreback to summary
pack-priv void setRenameScore(int score)
setSkipBinaryFilesback to summary
pack-priv void setSkipBinaryFiles(boolean value)
sizeback to summary
private long size(DiffEntry.Side side, DiffEntry ent) throws IOException
srcFileback to summary
pack-priv static int srcFile(long value)