if (otp.isEdge()) return; if ((nFmt == PACK_WHOLE) | (nFmt == PACK_DELTA)) { for (CachedPack pack : cachedPacks) { if (pack.hasObject(otp, next)) { otp.setEdge(); otp.clearDeltaBase(); otp.clearReuseAsIs(); pruneCurrentObjectList = true; return; ObjectId baseId = next.getDeltaBase(); ObjectToPack ptr = objectsMap.get(baseId); if (ptr != null && !ptr.isEdge()) { otp.setDeltaBase(ptr); otp.setReuseAsIs(); } else if (thin && have(ptr, baseId)) { otp.setDeltaBase(baseId); otp.setReuseAsIs(); } else { otp.clearDeltaBase(); otp.clearReuseAsIs(); if (otp.isReuseAsIs() && !otp.isDeltaRepresentation()) { if (otp.getWeight() <= nWeight) return; otp.clearDeltaBase();
private void add(AnyObjectId id, int objectType, int pathHash) { ObjectToPack obj = new ObjectToPack(id, objectType); obj.setEdge(); obj.setPathHash(pathHash); if (objectsMap.addIfAbsent(obj) == obj) { edgeObjects.add(obj); progress.update(1); } }
private void cutDeltaChains(BlockList<ObjectToPack> list) throws IOException { int max = config.getMaxDeltaDepth(); for (int idx = list.size() - 1; idx >= 0; idx--) { int d = 0; ObjectToPack b = list.get(idx).getDeltaBase(); while (b != null) { if (d < b.getChainLength()) break; b.setChainLength(++d); if (d >= max && b.isDeltaRepresentation()) { reselectNonDelta(b); break; } b = b.getDeltaBase(); } } if (config.isDeltaCompress()) { for (ObjectToPack otp : list) otp.clearChainLength(); } }
static int getAdjustedWeight(ObjectToPack o) { // Edge objects and those with reused deltas do not need to be // compressed. For compression calculations, ignore their weights. if (o.isEdge() || o.doNotAttemptDelta()) { return 0; } return o.getWeight(); }
private void reselectNonDelta(ObjectToPack otp) throws IOException { otp.clearDeltaBase(); otp.clearReuseAsIs(); boolean old = reuseDeltas; reuseDeltas = false; reuseSupport.selectObjectRepresentation(this, NullProgressMonitor.INSTANCE, Collections.singleton(otp)); reuseDeltas = old; }
private void writeObjectImpl(PackOutputStream out, ObjectToPack otp) throws IOException { if (otp.wantWrite()) { otp.markWantWrite(); while (otp.isReuseAsIs()) { writeBase(out, otp.getDeltaBase()); if (otp.isWritten()) return; // Delta chain cycle caused this to write already. otp.setOffset(out.length()); try { reuseSupport.copyObjectAsIs(out, otp, reuseValidate); out.endObject(); otp.setCRC((int) crc32.getValue()); typeStats.reusedObjects++; if (otp.isDeltaRepresentation()) { typeStats.reusedDeltas++; typeStats.deltaBytes += out.length() - otp.getOffset(); if (otp.getOffset() == out.length()) { otp.setOffset(0); otp.clearDeltaBase(); otp.clearReuseAsIs(); reuseSupport.selectObjectRepresentation(this, NullProgressMonitor.INSTANCE, if (otp.isDeltaRepresentation()) writeDeltaObjectDeflate(out, otp);
if (srcObj.isEdge()) { resObj.setDeltaBase(srcObj.copy()); } else { resObj.setDeltaBase(srcObj); int depth = srcObj.getDeltaDepth() + 1; resObj.setDeltaDepth(depth); resObj.clearReuseAsIs(); cacheDelta(srcObj, resObj);
private void writeDeltaObjectDeflate(PackOutputStream out, final ObjectToPack otp) throws IOException { writeBase(out, otp.getDeltaBase()); crc32.reset(); otp.setOffset(out.length()); DeltaCache.Ref ref = otp.popCachedDelta(); if (ref != null) { byte[] zbuf = ref.get(); if (zbuf != null) { out.writeHeader(otp, otp.getCachedSize()); out.write(zbuf); typeStats.cntDeltas++; typeStats.deltaBytes += out.length() - otp.getOffset(); return; } } try (TemporaryBuffer.Heap delta = delta(otp)) { out.writeHeader(otp, delta.length()); Deflater deflater = deflater(); deflater.reset(); DeflaterOutputStream dst = new DeflaterOutputStream(out, deflater); delta.writeTo(dst, null); dst.finish(); } typeStats.cntDeltas++; typeStats.deltaBytes += out.length() - otp.getOffset(); }
private void addObject( final AnyObjectId src, final int type, final int pathHashCode) { final ObjectToPack otp; if (reuseSupport != null) otp = reuseSupport.newObjectToPack(src, type); else otp = new ObjectToPack(src, type); otp.setPathHash(pathHashCode); objectsLists[type].add(otp); objectsMap.add(otp); }
/** {@inheritDoc} */ @Override protected void clearReuseAsIs() { super.clearReuseAsIs(); pack = null; }
@Override public void select(ObjectToPack otp, StoredObjectRepresentation next) { otp.select(next); } };
final int getWeight() { return getCRC(); }
/** * Computes SHA-1 of lexicographically sorted objects ids written in this * pack, as used to name a pack file in repository. * * @return ObjectId representing SHA-1 name of a pack that was created. */ public ObjectId computeName() { final byte[] buf = new byte[OBJECT_ID_LENGTH]; final MessageDigest md = Constants.newMessageDigest(); for (ObjectToPack otp : sortByName()) { otp.copyRawTo(buf, 0); md.update(buf, 0, OBJECT_ID_LENGTH); } return ObjectId.fromRaw(md.digest()); }
private void writeObjectImpl(PackOutputStream out, ObjectToPack otp) throws IOException { if (otp.wantWrite()) { otp.markWantWrite(); while (otp.isReuseAsIs()) { writeBase(out, otp.getDeltaBase()); if (otp.isWritten()) return; // Delta chain cycle caused this to write already. otp.setOffset(out.length()); try { reuseSupport.copyObjectAsIs(out, otp, reuseValidate); out.endObject(); otp.setCRC((int) crc32.getValue()); typeStats.reusedObjects++; if (otp.isDeltaRepresentation()) { typeStats.reusedDeltas++; typeStats.deltaBytes += out.length() - otp.getOffset(); if (otp.getOffset() == out.length()) { otp.setOffset(0); otp.clearDeltaBase(); otp.clearReuseAsIs(); reuseSupport.selectObjectRepresentation(this, NullProgressMonitor.INSTANCE, if (otp.isDeltaRepresentation()) writeDeltaObjectDeflate(out, otp);
if (srcObj.isEdge()) { resObj.setDeltaBase(srcObj.copy()); } else { resObj.setDeltaBase(srcObj); int depth = srcObj.getDeltaDepth() + 1; resObj.setDeltaDepth(depth); resObj.clearReuseAsIs(); cacheDelta(srcObj, resObj);
private void writeDeltaObjectDeflate(PackOutputStream out, final ObjectToPack otp) throws IOException { writeBase(out, otp.getDeltaBase()); crc32.reset(); otp.setOffset(out.length()); DeltaCache.Ref ref = otp.popCachedDelta(); if (ref != null) { byte[] zbuf = ref.get(); if (zbuf != null) { out.writeHeader(otp, otp.getCachedSize()); out.write(zbuf); typeStats.cntDeltas++; typeStats.deltaBytes += out.length() - otp.getOffset(); return; } } TemporaryBuffer.Heap delta = delta(otp); out.writeHeader(otp, delta.length()); Deflater deflater = deflater(); deflater.reset(); DeflaterOutputStream dst = new DeflaterOutputStream(out, deflater); delta.writeTo(dst, null); dst.finish(); typeStats.cntDeltas++; typeStats.deltaBytes += out.length() - otp.getOffset(); }
clearWindowOnTypeSwitch(); if (res.object.isEdge() || res.object.doNotAttemptDelta()) { } else { if (bytesPerUnit <= (bytesProcessed += next.getWeight())) { int d = (int) (bytesProcessed / bytesPerUnit); monitor.update(d);
private void addObject( final AnyObjectId src, final int type, final int pathHashCode) { final ObjectToPack otp; if (reuseSupport != null) otp = reuseSupport.newObjectToPack(src, type); else otp = new ObjectToPack(src, type); otp.setPathHash(pathHashCode); objectsLists[type].add(otp); objectsMap.add(otp); }
private void reselectNonDelta(ObjectToPack otp) throws IOException { otp.clearDeltaBase(); otp.clearReuseAsIs(); boolean old = reuseDeltas; reuseDeltas = false; reuseSupport.selectObjectRepresentation(this, NullProgressMonitor.INSTANCE, Collections.singleton(otp)); reuseDeltas = old; }
/** {@inheritDoc} */ @Override protected void clearReuseAsIs() { super.clearReuseAsIs(); pack = null; }