public VGV getVertexGroupValue() { return f2.isLeft() ? f2.left() : null; }
public void flatMap(Either<Vertex<K, VV>, Tuple2<K, Message>> value, Collector<Vertex<K, VV>> out) { if (value.isLeft()) { out.collect(value.left()); } } }
/** * Utility function for {@link EitherSerializer} to support object reuse. * * To support object reuse both subclasses of Either contain a reference to * an instance of the other type. This method provides access to and * initializes the cross-reference. * * @param input container for Left or Right value * @param leftSerializer for creating an instance of the left type * @param <L> * the type of Left * @param <R> * the type of Right * @return input if Left type else input's Left reference */ @Internal public static <L, R> Left<L, R> obtainLeft(Either<L, R> input, TypeSerializer<L> leftSerializer) { if (input.isLeft()) { return (Left<L, R>) input; } else { Right<L, R> right = (Right<L, R>) input; if (right.left == null) { right.left = Left.of(leftSerializer.createInstance()); right.left.right = right; } return right.left; } }
@Override public void serialize(Either<L, R> record, DataOutputView target) throws IOException { if (record.isLeft()) { target.writeBoolean(true); leftSerializer.serialize(record.left(), target); } else { target.writeBoolean(false); rightSerializer.serialize(record.right(), target); } }
@Override public Either<L, R> copy(Either<L, R> from) { if (from.isLeft()) { L left = from.left(); L copyLeft = leftSerializer.copy(left); return Left(copyLeft); } else { R right = from.right(); R copyRight = rightSerializer.copy(right); return Right(copyRight); } }
@Override public Either<L, R> copy(Either<L, R> from, Either<L, R> reuse) { if (from.isLeft()) { Left<L, R> to = Either.obtainLeft(reuse, leftSerializer); L left = leftSerializer.copy(from.left(), to.left()); to.setValue(left); return to; } else { Right<L, R> to = Either.obtainRight(reuse, rightSerializer); R right = rightSerializer.copy(from.right(), to.right()); to.setValue(right); return to; } }
public VGV getVertexGroupValue() { return f2.isLeft() ? f2.left() : null; }
public VGV getVertexGroupValue() { return f2.isLeft() ? f2.left() : null; }
public void flatMap(Either<Vertex<K, VV>, Tuple2<K, Message>> value, Collector<Vertex<K, VV>> out) { if (value.isLeft()) { out.collect(value.left()); } } }
public void flatMap(Either<Vertex<K, VV>, Tuple2<K, Message>> value, Collector<Vertex<K, VV>> out) { if (value.isLeft()) { out.collect(value.left()); } } }
public void flatMap(Either<Vertex<K, VV>, Tuple2<K, Message>> value, Collector<Vertex<K, VV>> out) { if (value.isLeft()) { out.collect(value.left()); } } }
public static void thirdParty(Their their, Either either) { if (either.isLeft()) their.thirdPartyExpectsString(either.getLeft()); else their.thirdPartyExpectsDouble(either.getRight()); }
@Override public void processElement( Either<DepositEvent, TransactionEvent> depositOrTransaction, Context context, Collector<DepositEvent> out) { if (depositOrTransaction.isLeft()) { out.collect(depositOrTransaction.left()); } else { context.output(transactionsSideOutput, depositOrTransaction.right()); } } });
@Override public void serialize(Either<L, R> record, DataOutputView target) throws IOException { if (record.isLeft()) { target.writeBoolean(true); leftSerializer.serialize(record.left(), target); } else { target.writeBoolean(false); rightSerializer.serialize(record.right(), target); } }
@Override public void flatMap(Either<Tuple2<Map<String, List<T>>, Long>, Map<String, List<T>>> value, Collector<Either<L, R>> out) throws Exception { if (value.isLeft()) { Tuple2<Map<String, List<T>>, Long> timeout = value.left(); patternFlatTimeoutFunction.timeout(timeout.f0, timeout.f1, new LeftCollector<>(out)); } else { patternFlatSelectFunction.flatSelect(value.right(), new RightCollector(out)); } }
@Override public void serialize(Either<L, R> record, DataOutputView target) throws IOException { if (record.isLeft()) { target.writeBoolean(true); leftSerializer.serialize(record.left(), target); } else { target.writeBoolean(false); rightSerializer.serialize(record.right(), target); } }
@Override public Either<L, R> map(Either<Tuple2<Map<String, List<T>>, Long>, Map<String, List<T>>> value) throws Exception { if (value.isLeft()) { Tuple2<Map<String, List<T>>, Long> timeout = value.left(); return Either.Left(patternTimeoutFunction.timeout(timeout.f0, timeout.f1)); } else { return Either.Right(patternSelectFunction.select(value.right())); } } }
@Override public Either<L, R> copy(Either<L, R> from) { if (from.isLeft()) { L left = from.left(); L copyLeft = leftSerializer.copy(left); return Left(copyLeft); } else { R right = from.right(); R copyRight = rightSerializer.copy(right); return Right(copyRight); } }
@Override public Either<L, R> copy(Either<L, R> from) { if (from.isLeft()) { L left = from.left(); L copyLeft = leftSerializer.copy(left); return Left(copyLeft); } else { R right = from.right(); R copyRight = rightSerializer.copy(right); return Right(copyRight); } }
@Override public Either<L, R> copy(Either<L, R> from, Either<L, R> reuse) { if (from.isLeft()) { Left<L, R> to = Either.obtainLeft(reuse, leftSerializer); L left = leftSerializer.copy(from.left(), to.left()); to.setValue(left); return to; } else { Right<L, R> to = Either.obtainRight(reuse, rightSerializer); R right = rightSerializer.copy(from.right(), to.right()); to.setValue(right); return to; } }