org.apache.flink.types.Either.isLeft()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中org.apache.flink.types.Either.isLeft()方法的一些代码示例,展示了Either.isLeft()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Either.isLeft()方法的具体详情如下:
包路径:org.apache.flink.types.Either
类名称:Either
方法名:isLeft

Either.isLeft介绍

暂无

代码示例

代码示例来源:origin: apache/flink

public VGV getVertexGroupValue() {
  return f2.isLeft() ? f2.left() : null;
}

代码示例来源:origin: apache/flink

public void flatMap(Either<Vertex<K, VV>, Tuple2<K, Message>> value,
      Collector<Vertex<K, VV>> out) {
    if (value.isLeft()) {
      out.collect(value.left());
    }
  }
}

代码示例来源:origin: apache/flink

/**
 * 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;
  }
}

代码示例来源:origin: apache/flink

@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);
  }
}

代码示例来源:origin: apache/flink

@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);
  }
}

代码示例来源:origin: apache/flink

@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;
  }
}

代码示例来源:origin: com.alibaba.blink/flink-gelly

public VGV getVertexGroupValue() {
  return f2.isLeft() ? f2.left() : null;
}

代码示例来源:origin: org.apache.flink/flink-gelly_2.11

public VGV getVertexGroupValue() {
  return f2.isLeft() ? f2.left() : null;
}

代码示例来源:origin: org.apache.flink/flink-gelly_2.10

public void flatMap(Either<Vertex<K, VV>, Tuple2<K, Message>> value,
      Collector<Vertex<K, VV>> out) {
    if (value.isLeft()) {
      out.collect(value.left());
    }
  }
}

代码示例来源:origin: org.apache.flink/flink-gelly_2.11

public void flatMap(Either<Vertex<K, VV>, Tuple2<K, Message>> value,
      Collector<Vertex<K, VV>> out) {
    if (value.isLeft()) {
      out.collect(value.left());
    }
  }
}

代码示例来源:origin: com.alibaba.blink/flink-gelly

public void flatMap(Either<Vertex<K, VV>, Tuple2<K, Message>> value,
      Collector<Vertex<K, VV>> out) {
    if (value.isLeft()) {
      out.collect(value.left());
    }
  }
}

代码示例来源:origin: stackoverflow.com

public static void thirdParty(Their their, Either either) {
  if (either.isLeft())
    their.thirdPartyExpectsString(either.getLeft());
  else
    their.thirdPartyExpectsDouble(either.getRight());
}

代码示例来源:origin: dataArtisans/da-streamingledger

@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());
    }
  }
});

代码示例来源:origin: com.alibaba.blink/flink-core

@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);
  }
}

代码示例来源:origin: org.apache.flink/flink-cep_2.10

@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));
  }
}

代码示例来源:origin: org.apache.flink/flink-core

@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);
  }
}

代码示例来源:origin: org.apache.flink/flink-cep_2.10

@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()));
    }
  }
}

代码示例来源:origin: org.apache.flink/flink-core

@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);
  }
}

代码示例来源:origin: com.alibaba.blink/flink-core

@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);
  }
}

代码示例来源:origin: org.apache.flink/flink-core

@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;
  }
}

相关文章

微信公众号

最新文章

更多