コード例 #1
0
  private <P> PartitionOperator(
      DataSet<T> input,
      PartitionMethod pMethod,
      Keys<T> pKeys,
      Partitioner<P> customPartitioner,
      TypeInformation<P> partitionerTypeInfo,
      String partitionLocationName) {
    super(input, input.getType());

    Preconditions.checkNotNull(pMethod);
    Preconditions.checkArgument(
        pKeys != null || pMethod == PartitionMethod.REBALANCE, "Partitioning requires keys");
    Preconditions.checkArgument(
        pMethod != PartitionMethod.CUSTOM || customPartitioner != null,
        "Custom partioning requires a partitioner.");
    Preconditions.checkArgument(
        pMethod != PartitionMethod.RANGE, "Range partitioning is not yet supported");

    if (pKeys instanceof Keys.ExpressionKeys<?> && !(input.getType() instanceof CompositeType)) {
      throw new IllegalArgumentException(
          "Hash Partitioning with key fields only possible on Tuple or POJO DataSets");
    }

    if (customPartitioner != null) {
      pKeys.validateCustomPartitioner(customPartitioner, partitionerTypeInfo);
    }

    this.pMethod = pMethod;
    this.pKeys = pKeys;
    this.partitionLocationName = partitionLocationName;
    this.customPartitioner = customPartitioner;
  }