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); }
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 get(Context options, Set<ObjectIndexKey> objects, AsyncCallback<Map<ObjectIndexKey, Collection<ObjectInfo>>> callback) { Map<ObjectIndexKey, Collection<ObjectInfo>> out = new HashMap<ObjectIndexKey, Collection<ObjectInfo>>(); for (ObjectIndexKey objId : objects) { for (MemTable.Cell cell : table.scanFamily(objId.asBytes(), colInfo)) { Collection<ObjectInfo> chunks = out.get(objId); ChunkKey chunkKey; if (chunks == null) { chunks = new ArrayList<ObjectInfo>(4); out.put(objId, chunks); } chunkKey = ChunkKey.fromBytes(colInfo.suffix(cell.getName())); try { chunks.add(new ObjectInfo( chunkKey, cell.getTimestamp(), GitStore.ObjectInfo.parseFrom(cell.getValue()))); } catch (InvalidProtocolBufferException badCell) { callback.onFailure(new DhtException(MessageFormat.format( DhtText.get().invalidObjectInfo, objId, chunkKey), badCell)); return; } } } callback.onSuccess(out); }
public void get(Context options, Set<ObjectIndexKey> objects, AsyncCallback<Map<ObjectIndexKey, Collection<ObjectInfo>>> callback) { Map<ObjectIndexKey, Collection<ObjectInfo>> out = new HashMap<ObjectIndexKey, Collection<ObjectInfo>>(); for (ObjectIndexKey objId : objects) { for (MemTable.Cell cell : table.scanFamily(objId.asBytes(), colInfo)) { Collection<ObjectInfo> chunks = out.get(objId); ChunkKey chunkKey; if (chunks == null) { chunks = new ArrayList<ObjectInfo>(4); out.put(objId, chunks); } chunkKey = ChunkKey.fromBytes(colInfo.suffix(cell.getName())); try { chunks.add(new ObjectInfo( chunkKey, cell.getTimestamp(), GitStore.ObjectInfo.parseFrom(cell.getValue()))); } catch (InvalidProtocolBufferException badCell) { callback.onFailure(new DhtException(MessageFormat.format( DhtText.get().invalidObjectInfo, objId, chunkKey), badCell)); return; } } } callback.onSuccess(out); }
ObjectInfo link(ChunkKey key) { GitStore.ObjectInfo.Builder b = GitStore.ObjectInfo.newBuilder(); b.setObjectType(ObjectType.valueOf(type)); b.setOffset((int) getOffset()); b.setPackedSize(packed); b.setInflatedSize(inflated); return new ObjectInfo(key, b.build()); } }
ObjectInfo link(ChunkKey key) { GitStore.ObjectInfo.Builder b = GitStore.ObjectInfo.newBuilder(); b.setObjectType(ObjectType.valueOf(type)); b.setOffset((int) getOffset()); b.setPackedSize(packed); b.setInflatedSize(inflated); return new ObjectInfo(key, b.build()); } }
ObjectInfo info(ChunkKey chunkKey) { GitStore.ObjectInfo.Builder b = GitStore.ObjectInfo.newBuilder(); b.setObjectType(GitStore.ObjectInfo.ObjectType.valueOf(getType())); b.setOffset(offsetOf(chunkPtr)); b.setPackedSize(packedSize); b.setInflatedSize(inflatedSize); if (base != null) { byte[] t = new byte[Constants.OBJECT_ID_LENGTH]; base.copyRawTo(t, 0); b.setDeltaBase(ByteString.copyFrom(t)); } if (isFragmented()) b.setIsFragmented(true); return new ObjectInfo(chunkKey, b.build()); } }
ObjectInfo info(ChunkKey chunkKey) { GitStore.ObjectInfo.Builder b = GitStore.ObjectInfo.newBuilder(); b.setObjectType(GitStore.ObjectInfo.ObjectType.valueOf(getType())); b.setOffset(offsetOf(chunkPtr)); b.setPackedSize(packedSize); b.setInflatedSize(inflatedSize); if (base != null) { byte[] t = new byte[Constants.OBJECT_ID_LENGTH]; base.copyRawTo(t, 0); b.setDeltaBase(ByteString.copyFrom(t)); } if (isFragmented()) b.setIsFragmented(true); return new ObjectInfo(chunkKey, b.build()); } }
b.setPackedSize(packedSize); b.setInflatedSize(inflatedSize); ObjectInfo info = new ObjectInfo(key, b.build()); ObjectIndexKey objKey = ObjectIndexKey.create(repo, objId); db.objectIndex().add(objKey, info, dbBuffer()); b.setPackedSize(packedSize); b.setInflatedSize(inflatedSize); ObjectInfo info = new ObjectInfo(firstChunkKey, b.build()); ObjectIndexKey objKey = ObjectIndexKey.create(repo, objId); db.objectIndex().add(objKey, info, dbBuffer());
b.setPackedSize(packedSize); b.setInflatedSize(inflatedSize); ObjectInfo info = new ObjectInfo(key, b.build()); ObjectIndexKey objKey = ObjectIndexKey.create(repo, objId); db.objectIndex().add(objKey, info, dbBuffer()); b.setPackedSize(packedSize); b.setInflatedSize(inflatedSize); ObjectInfo info = new ObjectInfo(firstChunkKey, b.build()); ObjectIndexKey objKey = ObjectIndexKey.create(repo, objId); db.objectIndex().add(objKey, info, dbBuffer());