org.apache.flink.util.Preconditions.checkElementIndex()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(135)

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

Preconditions.checkElementIndex介绍

[英]Ensures that the given index is valid for an array, list or string of the given size.
[中]确保给定索引对给定大小的数组、列表或字符串有效。

代码示例

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

for (int i = 0; i < firstFieldIndexes.length; i++) {
  Preconditions.checkElementIndex(firstFieldIndexes[i], maxFieldIndex);

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

for (int i = 0; i < firstFieldIndexes.length; i++) {
  Preconditions.checkElementIndex(firstFieldIndexes[i], maxFieldIndex);

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

for (int i = 0; i < secondFieldIndexes.length; i++) {
  Preconditions.checkElementIndex(secondFieldIndexes[i], maxFieldIndex);

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

public Projection(DataSet<T> ds, int[] fieldIndexes) {
  if (!(ds.getType() instanceof TupleTypeInfo)) {
    throw new UnsupportedOperationException("project() can only be applied to DataSets of Tuples.");
  }
  if (fieldIndexes.length == 0) {
    throw new IllegalArgumentException("project() needs to select at least one (1) field.");
  } else if (fieldIndexes.length > Tuple.MAX_ARITY - 1) {
    throw new IllegalArgumentException(
      "project() may select only up to (" + (Tuple.MAX_ARITY - 1) + ") fields.");
  }
  int maxFieldIndex = ds.getType().getArity();
  for (int fieldIndexe : fieldIndexes) {
    Preconditions.checkElementIndex(fieldIndexe, maxFieldIndex);
  }
  this.ds = ds;
  this.fieldIndexes = fieldIndexes;
}

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

protected StreamProjection(DataStream<IN> dataStream, int[] fieldIndexes) {
  if (!dataStream.getType().isTupleType()) {
    throw new RuntimeException("Only Tuple DataStreams can be projected");
  }
  if (fieldIndexes.length == 0) {
    throw new IllegalArgumentException("project() needs to select at least one (1) field.");
  } else if (fieldIndexes.length > Tuple.MAX_ARITY - 1) {
    throw new IllegalArgumentException(
        "project() may select only up to (" + (Tuple.MAX_ARITY - 1) + ") fields.");
  }
  int maxFieldIndex = (dataStream.getType()).getArity();
  for (int i = 0; i < fieldIndexes.length; i++) {
    Preconditions.checkElementIndex(fieldIndexes[i], maxFieldIndex);
  }
  this.dataStream = dataStream;
  this.fieldIndexes = fieldIndexes;
}

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

for (int i = 0; i < secondFieldIndexes.length; i++) {
  Preconditions.checkElementIndex(secondFieldIndexes[i], maxFieldIndex);

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

Preconditions.checkElementIndex(this.fieldIndexes[i], maxFieldIndex);

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

Preconditions.checkElementIndex(this.fieldIndexes[i], maxFieldIndex);

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

/**
 * Returns the requested subpartition.
 */
public ResultSubpartitionView createSubpartitionView(int index, BufferAvailabilityListener availabilityListener) throws IOException {
  int refCnt = pendingReferences.get();
  checkState(refCnt != -1, "Partition released.");
  checkState(refCnt > 0, "Partition not pinned.");
  checkElementIndex(index, subpartitions.length, "Subpartition not found.");
  ResultSubpartitionView readView = subpartitions[index].createReadView(availabilityListener);
  LOG.debug("Created {}", readView);
  return readView;
}

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

/**
 * Returns the requested subpartition.
 */
public ResultSubpartitionView createSubpartitionView(int index, BufferAvailabilityListener availabilityListener) throws IOException {
  int refCnt = pendingReferences.get();
  checkState(refCnt != -1, "Partition released.");
  checkState(refCnt > 0, "Partition not pinned.");
  checkElementIndex(index, subpartitions.length, "Subpartition not found.");
  ResultSubpartitionView readView = subpartitions[index].createReadView(availabilityListener);
  LOG.debug("Created {}", readView);
  return readView;
}

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

/**
 * Returns the requested subpartition.
 */
public ResultSubpartitionView createSubpartitionView(int index, BufferAvailabilityListener availabilityListener) throws IOException {
  int refCnt = pendingReferences.get();
  checkState(refCnt != -1, "Partition released.");
  checkState(refCnt > 0, "Partition not pinned.");
  checkElementIndex(index, subpartitions.length, "Subpartition not found.");
  ResultSubpartitionView readView = subpartitions[index].createReadView(availabilityListener);
  LOG.debug("Created {}", readView);
  return readView;
}

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

/**
 * Returns the requested subpartition.
 */
public ResultSubpartitionView createSubpartitionView(int index, BufferAvailabilityListener availabilityListener) throws IOException {
  int refCnt = pendingReferences.get();
  checkState(refCnt != -1, "Partition released.");
  checkState(refCnt > 0, "Partition not pinned.");
  checkElementIndex(index, subpartitions.length, "Subpartition not found.");
  ResultSubpartitionView readView = subpartitions[index].createReadView(availabilityListener);
  LOG.debug("Created {}", readView);
  return readView;
}

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

for (int i = 0; i < secondFieldIndexes.length; i++) {
  Preconditions.checkElementIndex(secondFieldIndexes[i], maxFieldIndex);

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

public Projection(DataSet<T> ds, int[] fieldIndexes) {
  if (!(ds.getType() instanceof TupleTypeInfo)) {
    throw new UnsupportedOperationException("project() can only be applied to DataSets of Tuples.");
  }
  if (fieldIndexes.length == 0) {
    throw new IllegalArgumentException("project() needs to select at least one (1) field.");
  } else if (fieldIndexes.length > Tuple.MAX_ARITY - 1) {
    throw new IllegalArgumentException(
      "project() may select only up to (" + (Tuple.MAX_ARITY - 1) + ") fields.");
  }
  int maxFieldIndex = ds.getType().getArity();
  for (int fieldIndexe : fieldIndexes) {
    Preconditions.checkElementIndex(fieldIndexe, maxFieldIndex);
  }
  this.ds = ds;
  this.fieldIndexes = fieldIndexes;
}

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

for (int i = 0; i < secondFieldIndexes.length; i++) {
  Preconditions.checkElementIndex(secondFieldIndexes[i], maxFieldIndex);

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

for (int i = 0; i < secondFieldIndexes.length; i++) {
  Preconditions.checkElementIndex(secondFieldIndexes[i], maxFieldIndex);

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

public Projection(DataSet<T> ds, int[] fieldIndexes) {
  if (!(ds.getType() instanceof TupleTypeInfo)) {
    throw new UnsupportedOperationException("project() can only be applied to DataSets of Tuples.");
  }
  if (fieldIndexes.length == 0) {
    throw new IllegalArgumentException("project() needs to select at least one (1) field.");
  } else if (fieldIndexes.length > Tuple.MAX_ARITY - 1) {
    throw new IllegalArgumentException(
      "project() may select only up to (" + (Tuple.MAX_ARITY - 1) + ") fields.");
  }
  int maxFieldIndex = ds.getType().getArity();
  for (int fieldIndexe : fieldIndexes) {
    Preconditions.checkElementIndex(fieldIndexe, maxFieldIndex);
  }
  this.ds = ds;
  this.fieldIndexes = fieldIndexes;
}

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

protected StreamProjection(DataStream<IN> dataStream, int[] fieldIndexes) {
  if (!dataStream.getType().isTupleType()) {
    throw new RuntimeException("Only Tuple DataStreams can be projected");
  }
  if (fieldIndexes.length == 0) {
    throw new IllegalArgumentException("project() needs to select at least one (1) field.");
  } else if (fieldIndexes.length > Tuple.MAX_ARITY - 1) {
    throw new IllegalArgumentException(
        "project() may select only up to (" + (Tuple.MAX_ARITY - 1) + ") fields.");
  }
  int maxFieldIndex = (dataStream.getType()).getArity();
  for (int i = 0; i < fieldIndexes.length; i++) {
    Preconditions.checkElementIndex(fieldIndexes[i], maxFieldIndex);
  }
  this.dataStream = dataStream;
  this.fieldIndexes = fieldIndexes;
}

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

protected StreamProjection(DataStream<IN> dataStream, int[] fieldIndexes) {
  if (!dataStream.getType().isTupleType()) {
    throw new RuntimeException("Only Tuple DataStreams can be projected");
  }
  if (fieldIndexes.length == 0) {
    throw new IllegalArgumentException("project() needs to select at least one (1) field.");
  } else if (fieldIndexes.length > Tuple.MAX_ARITY - 1) {
    throw new IllegalArgumentException(
        "project() may select only up to (" + (Tuple.MAX_ARITY - 1) + ") fields.");
  }
  int maxFieldIndex = (dataStream.getType()).getArity();
  for (int i = 0; i < fieldIndexes.length; i++) {
    Preconditions.checkElementIndex(fieldIndexes[i], maxFieldIndex);
  }
  this.dataStream = dataStream;
  this.fieldIndexes = fieldIndexes;
}

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

protected StreamProjection(DataStream<IN> dataStream, int[] fieldIndexes) {
  if (!dataStream.getType().isTupleType()) {
    throw new RuntimeException("Only Tuple DataStreams can be projected");
  }
  if (fieldIndexes.length == 0) {
    throw new IllegalArgumentException("project() needs to select at least one (1) field.");
  } else if (fieldIndexes.length > Tuple.MAX_ARITY - 1) {
    throw new IllegalArgumentException(
        "project() may select only up to (" + (Tuple.MAX_ARITY - 1) + ") fields.");
  }
  int maxFieldIndex = (dataStream.getType()).getArity();
  for (int i = 0; i < fieldIndexes.length; i++) {
    Preconditions.checkElementIndex(fieldIndexes[i], maxFieldIndex);
  }
  this.dataStream = dataStream;
  this.fieldIndexes = fieldIndexes;
}

相关文章