static DeltaWindowEntry createWindow(int cnt) { // C Git increases the window size supplied by the user by 1. // We don't know why it does this, but if the user asks for // window=10, it actually processes with window=11. Because // the window size has the largest direct impact on the final // pack file size, we match this odd behavior here to give us // a better chance of producing a similar sized pack as C Git. // // We would prefer to directly honor the user's request since // PackWriter has a minimum of 2 for the window size, but then // users might complain that JGit is creating a bigger pack file. DeltaWindowEntry res = new DeltaWindowEntry(); DeltaWindowEntry p = res; for (int i = 0; i < cnt; i++) { DeltaWindowEntry e = new DeltaWindowEntry(); e.prev = p; p.next = e; p = e; } p.next = res; res.prev = p; return res; } }
DeltaWindow(PackConfig pc, DeltaCache dc, ObjectReader or, ProgressMonitor pm, long bpu, ObjectToPack[] in, int beginIndex, int endIndex) { config = pc; deltaCache = dc; reader = or; monitor = pm; bytesPerUnit = bpu; toSearch = in; cur = beginIndex; end = endIndex; maxMemory = Math.max(0, config.getDeltaSearchMemoryLimit()); maxDepth = config.getMaxDeltaDepth(); res = DeltaWindowEntry.createWindow(config.getDeltaSearchWindowSize()); }
private int deltaSizeLimit(DeltaWindowEntry src) { if (bestBase == null) { // Any delta should be no more than 50% of the original size // (for text files deflate of whole form should shrink 50%). int n = res.size() >>> 1; // Evenly distribute delta size limits over allowed depth. // If src is non-delta (depth = 0), delta <= 50% of original. // If src is almost at limit (9/10), delta <= 10% of original. return n * (maxDepth - src.depth()) / maxDepth; } // With a delta base chosen any new delta must be "better". // Retain the distribution described above. int d = bestBase.depth(); int n = deltaLen; // If src is whole (depth=0) and base is near limit (depth=9/10) // any delta using src can be 10x larger and still be better. // // If src is near limit (depth=9/10) and base is whole (depth=0) // a new delta dependent on src must be 1/10th the size. return n * (maxDepth - src.depth()) / (maxDepth - d); }
private void clear(DeltaWindowEntry ent) { if (ent.index != null) loaded -= ent.index.getIndexSize(); else if (ent.buffer != null) loaded -= ent.buffer.length; ent.set(null); }
private byte[] buffer(DeltaWindowEntry ent) throws MissingObjectException, IncorrectObjectTypeException, IOException, LargeObjectException { byte[] buf = ent.buffer; if (buf == null) { checkLoadable(ent, ent.size()); buf = PackWriter.buffer(config, reader, ent.object); if (maxMemory != 0) loaded += buf.length; ent.buffer = buf; } return buf; }
clear(n); res.set(next); clearWindowOnTypeSwitch();
private int deltaSizeLimit(DeltaWindowEntry src) { if (bestBase == null) { // Any delta should be no more than 50% of the original size // (for text files deflate of whole form should shrink 50%). int n = res.size() >>> 1; // Evenly distribute delta size limits over allowed depth. // If src is non-delta (depth = 0), delta <= 50% of original. // If src is almost at limit (9/10), delta <= 10% of original. return n * (maxDepth - src.depth()) / maxDepth; } // With a delta base chosen any new delta must be "better". // Retain the distribution described above. int d = bestBase.depth(); int n = deltaLen; // If src is whole (depth=0) and base is near limit (depth=9/10) // any delta using src can be 10x larger and still be better. // // If src is near limit (depth=9/10) and base is whole (depth=0) // a new delta dependent on src must be 1/10th the size. return n * (maxDepth - src.depth()) / (maxDepth - d); }
private void clear(DeltaWindowEntry ent) { if (ent.index != null) loaded -= ent.index.getIndexSize(); else if (ent.buffer != null) loaded -= ent.buffer.length; ent.set(null); }
private byte[] buffer(DeltaWindowEntry ent) throws MissingObjectException, IncorrectObjectTypeException, IOException, LargeObjectException { byte[] buf = ent.buffer; if (buf == null) { checkLoadable(ent, ent.size()); buf = PackWriter.buffer(config, reader, ent.object); if (maxMemory != 0) loaded += buf.length; ent.buffer = buf; } return buf; }
DeltaWindow(PackConfig pc, DeltaCache dc, ObjectReader or, ProgressMonitor pm, long bpu, ObjectToPack[] in, int beginIndex, int endIndex) { config = pc; deltaCache = dc; reader = or; monitor = pm; bytesPerUnit = bpu; toSearch = in; cur = beginIndex; end = endIndex; maxMemory = Math.max(0, config.getDeltaSearchMemoryLimit()); maxDepth = config.getMaxDeltaDepth(); res = DeltaWindowEntry.createWindow(config.getDeltaSearchWindowSize()); }
static DeltaWindowEntry createWindow(int cnt) { // C Git increases the window size supplied by the user by 1. // We don't know why it does this, but if the user asks for // window=10, it actually processes with window=11. Because // the window size has the largest direct impact on the final // pack file size, we match this odd behavior here to give us // a better chance of producing a similar sized pack as C Git. // // We would prefer to directly honor the user's request since // PackWriter has a minimum of 2 for the window size, but then // users might complain that JGit is creating a bigger pack file. DeltaWindowEntry res = new DeltaWindowEntry(); DeltaWindowEntry p = res; for (int i = 0; i < cnt; i++) { DeltaWindowEntry e = new DeltaWindowEntry(); e.prev = p; p.next = e; p = e; } p.next = res; res.prev = p; return res; } }
private int deltaSizeLimit(DeltaWindowEntry src) { if (bestBase == null) { // Any delta should be no more than 50% of the original size // (for text files deflate of whole form should shrink 50%). int n = res.size() >>> 1; // Evenly distribute delta size limits over allowed depth. // If src is non-delta (depth = 0), delta <= 50% of original. // If src is almost at limit (9/10), delta <= 10% of original. return n * (maxDepth - src.depth()) / maxDepth; } // With a delta base chosen any new delta must be "better". // Retain the distribution described above. int d = bestBase.depth(); int n = deltaLen; // If src is whole (depth=0) and base is near limit (depth=9/10) // any delta using src can be 10x larger and still be better. // // If src is near limit (depth=9/10) and base is whole (depth=0) // a new delta dependent on src must be 1/10th the size. return n * (maxDepth - src.depth()) / (maxDepth - d); }
private void clear(DeltaWindowEntry ent) { if (ent.index != null) loaded -= ent.index.getIndexSize(); else if (ent.buffer != null) loaded -= ent.buffer.length; ent.set(null); }