void hash(ObjectLoader obj) throws MissingObjectException, IOException, TableFullException { if (obj.isLarge()) { hashLargeObject(obj); } else { byte[] raw = obj.getCachedBytes(); hash(raw, 0, raw.length); } }
/** * Create a new similarity index for the given object * * @param obj * the object to hash * @return similarity index for this object * @throws java.io.IOException * file contents cannot be read from the repository. * @throws org.eclipse.jgit.diff.SimilarityIndex.TableFullException * object hashing overflowed the storage capacity of the * SimilarityIndex. */ public static SimilarityIndex create(ObjectLoader obj) throws IOException, TableFullException { SimilarityIndex idx = new SimilarityIndex(); idx.hash(obj); idx.sort(); return idx; }
private SimilarityIndex hash(DiffEntry.Side side, DiffEntry ent) throws IOException, TableFullException { SimilarityIndex r = new SimilarityIndex(); r.hash(reader.open(side, ent)); r.sort(); return r; }
void hash(ObjectLoader obj) throws MissingObjectException, IOException, TableFullException { if (obj.isLarge()) { hashLargeObject(obj); } else { byte[] raw = obj.getCachedBytes(); hash(raw, 0, raw.length); } }
private void hashLargeObject(ObjectLoader obj) throws IOException, TableFullException { boolean text; try (ObjectStream in1 = obj.openStream()) { text = !RawText.isBinary(in1); } try (ObjectStream in2 = obj.openStream()) { hash(in2, in2.getSize(), text); } }
void hash(ObjectLoader obj) throws MissingObjectException, IOException, TableFullException { if (obj.isLarge()) { hashLargeObject(obj); } else { byte[] raw = obj.getCachedBytes(); hash(raw, 0, raw.length); } }
private int calculateModifyScore(ContentSource.Pair reader, DiffEntry d) throws IOException { try { SimilarityIndex src = new SimilarityIndex(); src.hash(reader.open(OLD, d)); src.sort(); SimilarityIndex dst = new SimilarityIndex(); dst.hash(reader.open(NEW, d)); dst.sort(); return src.score(dst, 100); } catch (TableFullException tableFull) { // If either table overflowed while being constructed, don't allow // the pair to be broken. Returning 1 higher than breakScore will // ensure its not similar, but not quite dissimilar enough to break. // overRenameLimit = true; return breakScore + 1; } }
/** * Create a new similarity index for the given object * * @param obj * the object to hash * @return similarity index for this object * @throws IOException * file contents cannot be read from the repository. * @throws TableFullException * object hashing overflowed the storage capacity of the * SimilarityIndex. */ public static SimilarityIndex create(ObjectLoader obj) throws IOException, TableFullException { SimilarityIndex idx = new SimilarityIndex(); idx.hash(obj); idx.sort(); return idx; }
private SimilarityIndex hash(DiffEntry.Side side, DiffEntry ent) throws IOException, TableFullException { SimilarityIndex r = new SimilarityIndex(); r.hash(reader.open(side, ent)); r.sort(); return r; }
/** * Create a new similarity index for the given object * * @param obj * the object to hash * @return similarity index for this object * @throws java.io.IOException * file contents cannot be read from the repository. * @throws org.eclipse.jgit.diff.SimilarityIndex.TableFullException * object hashing overflowed the storage capacity of the * SimilarityIndex. */ public static SimilarityIndex create(ObjectLoader obj) throws IOException, TableFullException { SimilarityIndex idx = new SimilarityIndex(); idx.hash(obj); idx.sort(); return idx; }
private SimilarityIndex hash(DiffEntry.Side side, DiffEntry ent) throws IOException, TableFullException { SimilarityIndex r = new SimilarityIndex(); r.hash(reader.open(side, ent)); r.sort(); return r; }
private void hashLargeObject(ObjectLoader obj) throws IOException, TableFullException { boolean text; try (ObjectStream in1 = obj.openStream()) { text = !RawText.isBinary(in1); } try (ObjectStream in2 = obj.openStream()) { hash(in2, in2.getSize(), text); } }
private int calculateModifyScore(ContentSource.Pair reader, DiffEntry d) throws IOException { try { SimilarityIndex src = new SimilarityIndex(); src.hash(reader.open(OLD, d)); src.sort(); SimilarityIndex dst = new SimilarityIndex(); dst.hash(reader.open(NEW, d)); dst.sort(); return src.score(dst, 100); } catch (TableFullException tableFull) { // If either table overflowed while being constructed, don't allow // the pair to be broken. Returning 1 higher than breakScore will // ensure its not similar, but not quite dissimilar enough to break. // overRenameLimit = true; return breakScore + 1; } }
private int calculateModifyScore(ContentSource.Pair reader, DiffEntry d) throws IOException { try { SimilarityIndex src = new SimilarityIndex(); src.hash(reader.open(OLD, d)); src.sort(); SimilarityIndex dst = new SimilarityIndex(); dst.hash(reader.open(NEW, d)); dst.sort(); return src.score(dst, 100); } catch (TableFullException tableFull) { // If either table overflowed while being constructed, don't allow // the pair to be broken. Returning 1 higher than breakScore will // ensure its not similar, but not quite dissimilar enough to break. // overRenameLimit = true; return breakScore + 1; } }
private void hashLargeObject(ObjectLoader obj) throws IOException, TableFullException { ObjectStream in1 = obj.openStream(); boolean text; try { text = !RawText.isBinary(in1); } finally { in1.close(); } ObjectStream in2 = obj.openStream(); try { hash(in2, in2.getSize(), text); } finally { in2.close(); } }