private static ChunkKey chunk(Collection<ObjectInfo> info) { if (info == null || info.isEmpty()) return null; List<ObjectInfo> infoList = new ArrayList<ObjectInfo>(info); ObjectInfo.sort(infoList); return infoList.get(0).getChunkKey(); }
@Override public ObjectId getDeltaBase() { return info.getDeltaBase(); }
int getOffset() { return info.getOffset(); }
private byte[] encode(List<ObjectInfo> items) { CachedObjectIndex.Builder b; b = CachedObjectIndex.newBuilder(); for (ObjectInfo info : items) { CachedObjectIndex.Item.Builder i = b.addItemBuilder(); i.setChunkKey(info.getChunkKey().asString()); i.setObjectInfo(info.getData()); if (0 < info.getTime()) i.setTime(info.getTime()); } return b.build().toByteArray(); } });
private Collection<ObjectInfo> decode(byte[] value) throws InvalidProtocolBufferException { CachedObjectIndex cacheEntry = CachedObjectIndex.parseFrom(value); int sz = cacheEntry.getItemCount(); ObjectInfo[] r = new ObjectInfo[sz]; for (int i = 0; i < sz; i++) { CachedObjectIndex.Item item = cacheEntry.getItem(i); r[i] = new ObjectInfo( ChunkKey.fromString(item.getChunkKey()), item.getTime(), item.getObjectInfo()); } return Arrays.asList(r); }
public void add(ObjectIndexKey objId, ObjectInfo info, WriteBuffer buffer) throws DhtException { ChunkKey chunk = info.getChunkKey(); table.put(objId.asBytes(), colInfo.append(chunk.asBytes()), info.getData().toByteArray()); }
public ObjectLoader open() throws IOException { ChunkKey chunkKey = current.chunkKey; // Objects returned by the queue are clustered by chunk. This object // is either in the current chunk, or are the next chunk ready on the // prefetcher. Anything else is a programming error. // PackChunk chunk; if (currChunk != null && chunkKey.equals(currChunk.getChunkKey())) chunk = currChunk; else { chunk = prefetcher.get(chunkKey); if (chunk == null) throw new DhtMissingChunkException(chunkKey); currChunk = chunk; reader.recentChunk(chunk); } if (current.info != null) { int ptr = current.info.getOffset(); int type = current.info.getType(); return PackChunk.read(chunk, ptr, reader, type); } else { int ptr = chunk.findOffset(repo, current.object); if (ptr < 0) throw DhtReader.missing(current.object, ObjectReader.OBJ_ANY); return PackChunk.read(chunk, ptr, reader, ObjectReader.OBJ_ANY); } }
chunk = prefetcher.get(link.getChunkKey()); if (chunk == null) { chunk = load(link.getChunkKey()); if (chunk == null) continue; chunk = load(link.getChunkKey()); if (chunk == null) continue; return new ChunkAndOffset(chunk, link.getOffset());
ObjectWithInfo(T object, ObjectInfo info, ObjectWithInfo<T> next) { this.object = object; this.info = info; this.chunkKey = info.getChunkKey(); this.next = next; }
long getPackedSize() { return info.getPackedSize(); }
public long getSize() { return currResult.info.getSize(); }
@Override public int getFormat() { if (info.isDelta()) return PACK_DELTA; return PACK_WHOLE; }
private byte[] encode(List<ObjectInfo> items) { CachedObjectIndex.Builder b; b = CachedObjectIndex.newBuilder(); for (ObjectInfo info : items) { CachedObjectIndex.Item.Builder i = b.addItemBuilder(); i.setChunkKey(info.getChunkKey().asString()); i.setObjectInfo(info.getData()); if (0 < info.getTime()) i.setTime(info.getTime()); } return b.build().toByteArray(); } });
private Collection<ObjectInfo> decode(byte[] value) throws InvalidProtocolBufferException { CachedObjectIndex cacheEntry = CachedObjectIndex.parseFrom(value); int sz = cacheEntry.getItemCount(); ObjectInfo[] r = new ObjectInfo[sz]; for (int i = 0; i < sz; i++) { CachedObjectIndex.Item item = cacheEntry.getItem(i); r[i] = new ObjectInfo( ChunkKey.fromString(item.getChunkKey()), item.getTime(), item.getObjectInfo()); } return Arrays.asList(r); }
public void add(ObjectIndexKey objId, ObjectInfo info, WriteBuffer buffer) throws DhtException { ChunkKey chunk = info.getChunkKey(); table.put(objId.asBytes(), colInfo.append(chunk.asBytes()), info.getData().toByteArray()); }
public ObjectLoader open() throws IOException { ChunkKey chunkKey = current.chunkKey; // Objects returned by the queue are clustered by chunk. This object // is either in the current chunk, or are the next chunk ready on the // prefetcher. Anything else is a programming error. // PackChunk chunk; if (currChunk != null && chunkKey.equals(currChunk.getChunkKey())) chunk = currChunk; else { chunk = prefetcher.get(chunkKey); if (chunk == null) throw new DhtMissingChunkException(chunkKey); currChunk = chunk; reader.recentChunk(chunk); } if (current.info != null) { int ptr = current.info.getOffset(); int type = current.info.getType(); return PackChunk.read(chunk, ptr, reader, type); } else { int ptr = chunk.findOffset(repo, current.object); if (ptr < 0) throw DhtReader.missing(current.object, ObjectReader.OBJ_ANY); return PackChunk.read(chunk, ptr, reader, ObjectReader.OBJ_ANY); } }
chunk = prefetcher.get(link.getChunkKey()); if (chunk == null) { chunk = load(link.getChunkKey()); if (chunk == null) continue; chunk = load(link.getChunkKey()); if (chunk == null) continue; return new ChunkAndOffset(chunk, link.getOffset());
ObjectWithInfo(T object, ObjectInfo info, ObjectWithInfo<T> next) { this.object = object; this.info = info; this.chunkKey = info.getChunkKey(); this.next = next; }
long getPackedSize() { return info.getPackedSize(); }