@Override public void reduce(Processor.UnaryProcess request, StreamObserver<Kv.Operand> responseObserver) { LOGGER.info("egg reduce request received"); long now = System.currentTimeMillis(); Kv.Operand.Builder operandBuilder = Kv.Operand.newBuilder(); Kv.Operand operand1 = operandBuilder.setKey(ByteString.copyFromUtf8("k1_" + reduceCount.getAndIncrement())).setValue(ByteString.copyFromUtf8("v1")).build(); Kv.Operand operand2 = operandBuilder.setKey(ByteString.copyFromUtf8("k2_" + reduceCount.getAndIncrement())).setValue(ByteString.copyFromUtf8("v2")).build(); responseObserver.onNext(operand1); responseObserver.onNext(operand2); responseObserver.onCompleted(); }
@Override public void delete(Kv.Operand request, StreamObserver<Kv.Operand> responseObserver) { KeyValueStore<Bytes, byte[]> store = getStore(); byte[] oldValue = store.delete(Bytes.wrap(request.getKey().toByteArray())); Kv.Operand.Builder builder = Kv.Operand.newBuilder().setKey(request.getKey()); if (oldValue != null) { builder.setValue(ByteString.copyFrom(oldValue)); } responseObserver.onNext(builder.buildPartial()); responseObserver.onCompleted(); }
/** * */ public void putIfAbsent(Kv.Operand request, StreamObserver<Kv.Operand> responseObserver) { KeyValueStore<Bytes, byte[]> store = getStore(); byte[] oldValue = store.putIfAbsent(Bytes.wrap(request.getKey().toByteArray()), request.getValue().toByteArray()); Kv.Operand.Builder builder = Kv.Operand.newBuilder().setKey(request.getKey()); if (oldValue != null) { builder.setValue(ByteString.copyFrom(oldValue)); } responseObserver.onNext(builder.buildPartial()); responseObserver.onCompleted(); }
while (keyValueIterator.hasNext()) { KeyValue<Bytes, byte[]> keyValue = keyValueIterator.next(); Kv.Operand operand = Kv.Operand.newBuilder().setKey(ByteString.copyFrom(keyValue.key.get())) .setValue(ByteString.copyFrom(keyValue.value)).build(); responseObserver.onNext(operand);
.setKey(transferMeta.getDataDesc().getTaggedVariableName()) .build();
.setKey(finalTransferMeta.getDataDesc().getTaggedVariableName()) .setValue(serializedObjectResult) .build();
public static Kv.Operand buildOperand(Bytes key, byte[] value) { return Kv.Operand.newBuilder().setKey(ByteString.copyFrom(key.get())) .setValue(ByteString.copyFrom(value)).build(); }
public static Kv.Operand buildOperand(KeyValue<Bytes, byte[]> keyValue) { return Kv.Operand.newBuilder().setKey(ByteString.copyFrom(keyValue.key.get())) .setValue(ByteString.copyFrom(keyValue.value)).build(); }
public Builder mergeFrom(com.webank.ai.fate.api.eggroll.storage.Kv.Operand other) { if (other == com.webank.ai.fate.api.eggroll.storage.Kv.Operand.getDefaultInstance()) return this; if (other.getKey() != com.google.protobuf.ByteString.EMPTY) { setKey(other.getKey()); } if (other.getValue() != com.google.protobuf.ByteString.EMPTY) { setValue(other.getValue()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
public Builder mergeFrom(com.webank.ai.fate.api.eggroll.storage.Kv.Operand other) { if (other == com.webank.ai.fate.api.eggroll.storage.Kv.Operand.getDefaultInstance()) return this; if (other.getKey() != com.google.protobuf.ByteString.EMPTY) { setKey(other.getKey()); } if (other.getValue() != com.google.protobuf.ByteString.EMPTY) { setValue(other.getValue()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@Override public void get(Kv.Operand request, StreamObserver<Kv.Operand> responseObserver) { KeyValueStore<Bytes, byte[]> store = getStore(); byte[] value = store.get(Bytes.wrap(request.getKey().toByteArray())); Kv.Operand.Builder builder = Kv.Operand.newBuilder().setKey(request.getKey()); if (value != null) builder.setValue(ByteString.copyFrom(value)); responseObserver.onNext(builder.buildPartial()); responseObserver.onCompleted(); }
public Kv.Operand toOperand(DataStructure.RawEntry rawEntry) { Kv.Operand result = null; synchronized (operandBuilderLock) { result = operandBuilder.clear() .setKey(rawEntry.getKey()) .setValue(rawEntry.getValue()) .build(); } return result; } }
@Override public void get(Kv.Operand request, StreamObserver<Kv.Operand> responseObserver) { LMDBStore store = getStore(); byte[] valueBuffer = store.get(Bytes.wrap(request.getKey())); Kv.Operand.Builder builder = Kv.Operand.newBuilder().setKey(request.getKey()); if (valueBuffer != null) builder.setValue(ByteString.copyFrom(valueBuffer)); responseObserver.onNext(builder.buildPartial()); responseObserver.onCompleted(); }
@Override public void putIfAbsent(Kv.Operand request, StreamObserver<Kv.Operand> responseObserver) { LMDBStore store = getStore(); byte[] oldValue = store.putIfAbsent(Bytes.wrap(request.getKey()), request.getValue().toByteArray()); Kv.Operand.Builder builder = Kv.Operand.newBuilder().setKey(request.getKey()); if (oldValue != null) { builder.setValue(ByteString.copyFrom(oldValue)); } responseObserver.onNext(builder.buildPartial()); responseObserver.onCompleted(); }
@Override public void delete(Kv.Operand request, StreamObserver<Kv.Operand> responseObserver) { LMDBStore store = getStore(); byte[] valueBuffer = store.delete(Bytes.wrap(request.getKey())); Kv.Operand.Builder builder = Kv.Operand.newBuilder().setKey(request.getKey()); if (valueBuffer != null) { builder.setValue(ByteString.copyFrom(valueBuffer)); } responseObserver.onNext(builder.buildPartial()); responseObserver.onCompleted(); }