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

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

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

Either.isRight介绍

暂无

代码示例

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

public void flatMap(Either<Vertex<K, VV>, Tuple2<K, Message>> value,
      Collector<Tuple2<K, Either<NullValue, Message>>> out) {
    if (value.isRight()) {
      Tuple2<K, Message> message = value.right();
      outTuple.f0 = message.f0;
      outTuple.f1 = Either.Right(message.f1);
      out.collect(outTuple);
    }
  }
}

代码示例来源: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 rightSerializer for creating an instance of the right type
   * @param <L>
   *            the type of Left
   * @param <R>
   *            the type of Right
   * @return input if Right type else input's Right reference
   */
  @Internal
  public static <L, R> Right<L, R> obtainRight(Either<L, R> input, TypeSerializer<R> rightSerializer) {
    if (input.isRight()) {
      return (Right<L, R>) input;
    } else {
      Left<L, R> left = (Left<L, R>) input;
      if (left.right == null) {
        left.right = Right.of(rightSerializer.createInstance());
        left.right.left = left;
      }
      return left.right;
    }
  }
}

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

public void flatMap(Either<Vertex<K, VV>, Tuple2<K, Message>> value,
      Collector<Tuple2<K, Either<NullValue, Message>>> out) {
    if (value.isRight()) {
      Tuple2<K, Message> message = value.right();
      outTuple.f0 = message.f0;
      outTuple.f1 = Either.Right(message.f1);
      out.collect(outTuple);
    }
  }
}

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

public void flatMap(Either<Vertex<K, VV>, Tuple2<K, Message>> value,
      Collector<Tuple2<K, Either<NullValue, Message>>> out) {
    if (value.isRight()) {
      Tuple2<K, Message> message = value.right();
      outTuple.f0 = message.f0;
      outTuple.f1 = Either.Right(message.f1);
      out.collect(outTuple);
    }
  }
}

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

public void flatMap(Either<Vertex<K, VV>, Tuple2<K, Message>> value,
      Collector<Tuple2<K, Either<NullValue, Message>>> out) {
    if (value.isRight()) {
      Tuple2<K, Message> message = value.right();
      outTuple.f0 = message.f0;
      outTuple.f1 = Either.Right(message.f1);
      out.collect(outTuple);
    }
  }
}

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

/**
   * 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 rightSerializer for creating an instance of the right type
   * @param <L>
   *            the type of Left
   * @param <R>
   *            the type of Right
   * @return input if Right type else input's Right reference
   */
  @Internal
  public static <L, R> Right<L, R> obtainRight(Either<L, R> input, TypeSerializer<R> rightSerializer) {
    if (input.isRight()) {
      return (Right<L, R>) input;
    } else {
      Left<L, R> left = (Left<L, R>) input;
      if (left.right == null) {
        left.right = Right.of(rightSerializer.createInstance());
        left.right.left = left;
      }
      return left.right;
    }
  }
}

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

/**
   * 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 rightSerializer for creating an instance of the right type
   * @param <L>
   *            the type of Left
   * @param <R>
   *            the type of Right
   * @return input if Right type else input's Right reference
   */
  @Internal
  public static <L, R> Right<L, R> obtainRight(Either<L, R> input, TypeSerializer<R> rightSerializer) {
    if (input.isRight()) {
      return (Right<L, R>) input;
    } else {
      Left<L, R> left = (Left<L, R>) input;
      if (left.right == null) {
        left.right = Right.of(rightSerializer.createInstance());
        left.right.left = left;
      }
      return left.right;
    }
  }
}

相关文章

微信公众号

最新文章

更多