private List<ChunkKey> toChunkList(Set<DhtInfo> objects) throws DhtException { if (objects == null || objects.isEmpty()) return null; Map<ChunkKey, ChunkOrderingEntry> map = new HashMap<ChunkKey, ChunkOrderingEntry>(); for (DhtInfo obj : objects) { if (!obj.isInPack()) continue; long chunkPtr = obj.chunkPtr; ChunkKey key = chunkOf(chunkPtr); ChunkOrderingEntry e = map.get(key); if (e == null) { e = new ChunkOrderingEntry(); e.key = key; e.order = chunkIdx(chunkPtr); map.put(key, e); } else { e.order = Math.min(e.order, chunkIdx(chunkPtr)); } } ChunkOrderingEntry[] tmp = map.values().toArray( new ChunkOrderingEntry[map.size()]); Arrays.sort(tmp); ChunkKey[] out = new ChunkKey[tmp.length]; for (int i = 0; i < tmp.length; i++) out[i] = tmp[i].key; return Arrays.asList(out); }
private List<ChunkKey> toChunkList(Set<DhtInfo> objects) throws DhtException { if (objects == null || objects.isEmpty()) return null; Map<ChunkKey, ChunkOrderingEntry> map = new HashMap<ChunkKey, ChunkOrderingEntry>(); for (DhtInfo obj : objects) { if (!obj.isInPack()) continue; long chunkPtr = obj.chunkPtr; ChunkKey key = chunkOf(chunkPtr); ChunkOrderingEntry e = map.get(key); if (e == null) { e = new ChunkOrderingEntry(); e.key = key; e.order = chunkIdx(chunkPtr); map.put(key, e); } else { e.order = Math.min(e.order, chunkIdx(chunkPtr)); } } ChunkOrderingEntry[] tmp = map.values().toArray( new ChunkOrderingEntry[map.size()]); Arrays.sort(tmp); ChunkKey[] out = new ChunkKey[tmp.length]; for (int i = 0; i < tmp.length; i++) out[i] = tmp[i].key; return Arrays.asList(out); }
if (!obj.isInPack()) return;
if (!obj.isInPack()) return;
@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); }