private long makeObjectPointer(ChunkFormatter w, int typeCode) { List<ChunkKey> list = chunkByOrder[typeCode]; int idx = list == null ? 0 : list.size(); int ptr = w.position(); return (((long) typeCode) << 61) | (((long) idx) << 32) | ptr; }
private long makeObjectPointer(ChunkFormatter w, int typeCode) { List<ChunkKey> list = chunkByOrder[typeCode]; int idx = list == null ? 0 : list.size(); int ptr = w.position(); return (((long) typeCode) << 61) | (((long) idx) << 32) | ptr; }
private boolean longOfsDelta(ChunkFormatter w, long infSize, long basePtr) { final int type = typeOf(basePtr); final List<ChunkKey> infoList = chunkByOrder[type]; final int baseIdx = chunkIdx(basePtr); final ChunkInfo baseInfo = infoByKey.get(infoList.get(baseIdx)); // Go backwards to the start of the base's chunk. long relativeChunkStart = 0; for (int i = infoList.size() - 1; baseIdx <= i; i--) { GitStore.ChunkInfo info = infoByKey.get(infoList.get(i)).getData(); int packSize = info.getChunkSize() - ChunkFormatter.TRAILER_SIZE; relativeChunkStart += packSize; } // Offset to the base goes back to start of our chunk, then start of // the base chunk, but slide forward the distance of the base within // its own chunk. // long ofs = w.position() + relativeChunkStart - offsetOf(basePtr); if (w.ofsDelta(infSize, ofs)) { w.useBaseChunk(relativeChunkStart, baseInfo.getChunkKey()); return true; } return false; }
private boolean longOfsDelta(ChunkFormatter w, long infSize, long basePtr) { final int type = typeOf(basePtr); final List<ChunkKey> infoList = chunkByOrder[type]; final int baseIdx = chunkIdx(basePtr); final ChunkInfo baseInfo = infoByKey.get(infoList.get(baseIdx)); // Go backwards to the start of the base's chunk. long relativeChunkStart = 0; for (int i = infoList.size() - 1; baseIdx <= i; i--) { GitStore.ChunkInfo info = infoByKey.get(infoList.get(i)).getData(); int packSize = info.getChunkSize() - ChunkFormatter.TRAILER_SIZE; relativeChunkStart += packSize; } // Offset to the base goes back to start of our chunk, then start of // the base chunk, but slide forward the distance of the base within // its own chunk. // long ofs = w.position() + relativeChunkStart - offsetOf(basePtr); if (w.ofsDelta(infSize, ofs)) { w.useBaseChunk(relativeChunkStart, baseInfo.getChunkKey()); return true; } return false; }
@Override protected void onBeginOfsDelta(long deltaPos, long basePos, long inflatedSize) throws IOException { long basePtr = objChunkPtrs.get(findStreamIndex(basePos)); int type = typeOf(basePtr); currType = type; currPackedSize = 0; currInflatedSize = inflatedSize; currBasePtr = basePtr; objStreamPos.add(deltaPos); ChunkFormatter w = begin(type); if (isInCurrentChunk(basePtr)) { if (w.ofsDelta(inflatedSize, w.position() - offsetOf(basePtr))) { currDataPos = w.position(); return; } endChunk(type); w = begin(type); } if (!longOfsDelta(w, inflatedSize, basePtr)) { endChunk(type); w = begin(type); if (!longOfsDelta(w, inflatedSize, basePtr)) throw panicCannotInsert(); } currDataPos = w.position(); }
@Override protected void onBeginOfsDelta(long deltaPos, long basePos, long inflatedSize) throws IOException { long basePtr = objChunkPtrs.get(findStreamIndex(basePos)); int type = typeOf(basePtr); currType = type; currPackedSize = 0; currInflatedSize = inflatedSize; currBasePtr = basePtr; objStreamPos.add(deltaPos); ChunkFormatter w = begin(type); if (isInCurrentChunk(basePtr)) { if (w.ofsDelta(inflatedSize, w.position() - offsetOf(basePtr))) { currDataPos = w.position(); return; } endChunk(type); w = begin(type); } if (!longOfsDelta(w, inflatedSize, basePtr)) { endChunk(type); w = begin(type); if (!longOfsDelta(w, inflatedSize, basePtr)) throw panicCannotInsert(); } currDataPos = w.position(); }
@Override protected void onBeginWholeObject(long streamPosition, int type, long inflatedSize) throws IOException { ChunkFormatter w = begin(type); if (!w.whole(type, inflatedSize)) { endChunk(type); w = begin(type); if (!w.whole(type, inflatedSize)) throw panicCannotInsert(); } currType = type; currDataPos = w.position(); currPackedSize = 0; currInflatedSize = inflatedSize; objStreamPos.add(streamPosition); }
@Override protected void onBeginWholeObject(long streamPosition, int type, long inflatedSize) throws IOException { ChunkFormatter w = begin(type); if (!w.whole(type, inflatedSize)) { endChunk(type); w = begin(type); if (!w.whole(type, inflatedSize)) throw panicCannotInsert(); } currType = type; currDataPos = w.position(); currPackedSize = 0; currInflatedSize = inflatedSize; objStreamPos.add(streamPosition); }
@Override protected void onBeginRefDelta(long deltaPos, AnyObjectId baseId, long inflatedSize) throws IOException { // Try to get the base type, but only if it was seen before in this // pack stream. If not assume worst-case of BLOB type. // int typeCode; DhtInfo baseInfo = objectMap.get(baseId); if (baseInfo != null && baseInfo.isInPack()) { typeCode = baseInfo.getType(); currType = typeCode; } else { typeCode = OBJ_BLOB; currType = -1; } ChunkFormatter w = begin(typeCode); if (!w.refDelta(inflatedSize, baseId)) { endChunk(typeCode); w = begin(typeCode); if (!w.refDelta(inflatedSize, baseId)) throw panicCannotInsert(); } currDataPos = w.position(); currPackedSize = 0; currInflatedSize = inflatedSize; objStreamPos.add(deltaPos); }
@Override protected void onBeginRefDelta(long deltaPos, AnyObjectId baseId, long inflatedSize) throws IOException { // Try to get the base type, but only if it was seen before in this // pack stream. If not assume worst-case of BLOB type. // int typeCode; DhtInfo baseInfo = objectMap.get(baseId); if (baseInfo != null && baseInfo.isInPack()) { typeCode = baseInfo.getType(); currType = typeCode; } else { typeCode = OBJ_BLOB; currType = -1; } ChunkFormatter w = begin(typeCode); if (!w.refDelta(inflatedSize, baseId)) { endChunk(typeCode); w = begin(typeCode); if (!w.refDelta(inflatedSize, baseId)) throw panicCannotInsert(); } currDataPos = w.position(); currPackedSize = 0; currInflatedSize = inflatedSize; objStreamPos.add(deltaPos); }
int position = chunk.position(); if (!chunk.whole(type, inflatedSize)) throw new DhtException(DhtText.get().cannotInsertObject);
int position = chunk.position(); if (!chunk.whole(type, inflatedSize)) throw new DhtException(DhtText.get().cannotInsertObject);