本文整理汇总了Java中org.apache.flink.api.java.DataSet.partitionCustom方法的典型用法代码示例。如果您正苦于以下问题:Java DataSet.partitionCustom方法的具体用法?Java DataSet.partitionCustom怎么用?Java DataSet.partitionCustom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.api.java.DataSet
的用法示例。
在下文中一共展示了DataSet.partitionCustom方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRangePartitionCustomPartitionerByKeySelector
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testRangePartitionCustomPartitionerByKeySelector() throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
final DataSet<CustomPojo> ds = getPojoDataSet(env);
ds.partitionCustom(new Partitioner<Integer>() {
@Override
public int partition(Integer key, int numPartitions) {
return 1;
}
}, new KeySelector<CustomPojo, Integer>() {
@Override
public Integer getKey(CustomPojo value) throws Exception {
return value.getNumber();
}
});
}
示例2: testRangePartitionCustomPartitionerByFieldId
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testRangePartitionCustomPartitionerByFieldId() throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
final DataSet<Tuple2<Integer, String>> ds = getTupleDataSet(env);
ds.partitionCustom(new Partitioner<Integer>() {
@Override
public int partition(Integer key, int numPartitions) {
return 1;
}
}, 0);
}
示例3: testRangePartitionInvalidCustomPartitionerByFieldId
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test(expected = InvalidProgramException.class)
public void testRangePartitionInvalidCustomPartitionerByFieldId() throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
final DataSet<Tuple2<Integer, String>> ds = getTupleDataSet(env);
ds.partitionCustom(new Partitioner<Integer>() {
@Override
public int partition(Integer key, int numPartitions) {
return 1;
}
}, 1);
}
示例4: testRangePartitionCustomPartitionerByFieldName
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testRangePartitionCustomPartitionerByFieldName() throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
final DataSet<CustomPojo> ds = getPojoDataSet(env);
ds.partitionCustom(new Partitioner<Integer>() {
@Override
public int partition(Integer key, int numPartitions) {
return 1;
}
}, "number");
}
示例5: testRangePartitionInvalidCustomPartitionerByFieldName
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test(expected = InvalidProgramException.class)
public void testRangePartitionInvalidCustomPartitionerByFieldName() throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
final DataSet<CustomPojo> ds = getPojoDataSet(env);
ds.partitionCustom(new Partitioner<Integer>() {
@Override
public int partition(Integer key, int numPartitions) {
return 1;
}
}, "name");
}