当前位置: 首页>>代码示例>>Java>>正文


Java DataSet.count方法代码示例

本文整理汇总了Java中org.apache.flink.api.java.DataSet.count方法的典型用法代码示例。如果您正苦于以下问题:Java DataSet.count方法的具体用法?Java DataSet.count怎么用?Java DataSet.count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.api.java.DataSet的用法示例。


在下文中一共展示了DataSet.count方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        if (!parseParameters(args))
            return;

        // set up execution environment
        final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

        Configuration config =
            GlobalConfiguration.loadConfiguration();
        int parallelism =
            config.getInteger("parallelism.default", 0);
        System.out.println("Paral: " + parallelism);

        // get input data
        DataSet<Long> input =
            env.generateSequence(0, parallelism - 1);
        DataSet<Long> slept = input.map(new Sleeper());
        slept.count();
    }
 
开发者ID:thrill,项目名称:fst-bench,代码行数:21,代码来源:JavaSleep.java

示例2: testSimple

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testSimple() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Integer[] input = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

	DataSet<Integer> data = env.fromElements(input);

	// count
	long numEntries = data.count();
	assertEquals(10, numEntries);

	// collect
	ArrayList<Integer> list = (ArrayList<Integer>) data.collect();
	assertArrayEquals(input, list.toArray());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:CountCollectITCase.java

示例3: testAdvanced

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testAdvanced() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.getConfig().disableObjectReuse();

	DataSet<Integer> data = env.fromElements(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
	DataSet<Integer> data2 = env.fromElements(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

	DataSet<Tuple2<Integer, Integer>> data3 = data.cross(data2);

	// count
	long numEntries = data3.count();
	assertEquals(100, numEntries);

	// collect
	ArrayList<Tuple2<Integer, Integer>> list = (ArrayList<Tuple2<Integer, Integer>>) data3.collect();

	// set expected entries in a hash map to true
	HashMap<Tuple2<Integer, Integer>, Boolean> expected = new HashMap<Tuple2<Integer, Integer>, Boolean>();
	for (int i = 1; i <= 10; i++) {
		for (int j = 1; j <= 10; j++) {
			expected.put(new Tuple2<Integer, Integer>(i, j), true);
		}
	}

	// check if all entries are contained in the hash map
	for (int i = 0; i < 100; i++) {
		Tuple2<Integer, Integer> element = list.get(i);
		assertEquals(expected.get(element), true);
		expected.remove(element);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:33,代码来源:CountCollectITCase.java

示例4: testCassandraBatchFormats

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testCassandraBatchFormats() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(1);

	DataSet<Tuple3<String, Integer, Integer>> dataSet = env.fromCollection(collection);
	dataSet.output(new CassandraOutputFormat<Tuple3<String, Integer, Integer>>(INSERT_DATA_QUERY, builder));

	env.execute("Write data");

	DataSet<Tuple3<String, Integer, Integer>> inputDS = env.createInput(
		new CassandraInputFormat<Tuple3<String, Integer, Integer>>(SELECT_DATA_QUERY, builder),
		TypeInformation.of(new TypeHint<Tuple3<String, Integer, Integer>>(){}));


	long count = inputDS.count();
	Assert.assertEquals(count, 20L);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:CassandraConnectorITCase.java

示例5: shouldExecuteAnnotatedCallback

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void shouldExecuteAnnotatedCallback() {
    DataSetCallback dataSetCallback = new AnnotatedDataSetCallback(new Object() {
        @org.apache.camel.component.flink.annotations.DataSetCallback
        Long countLines(DataSet<String> textFile) {
            try {
                return textFile.count();
            } catch (Exception e) {
                return null;
            }
        }
    });

    long pomLinesCount = template.requestBodyAndHeader(flinkDataSetUri, null, FlinkConstants.FLINK_DATASET_CALLBACK_HEADER, dataSetCallback, Long.class);

    Truth.assertThat(pomLinesCount).isEqualTo(19);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:FlinkProducerTest.java

示例6: shouldExecuteAnnotatedCallbackWithParameters

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void shouldExecuteAnnotatedCallbackWithParameters() {
    DataSetCallback dataSetCallback = new AnnotatedDataSetCallback(new Object() {
        @org.apache.camel.component.flink.annotations.DataSetCallback
        Long countLines(DataSet<String> textFile, int first, int second) {
            try {
                return textFile.count() * first * second;
            } catch (Exception e) {
                return null;
            }
        }
    });

    long pomLinesCount = template.requestBodyAndHeader(flinkDataSetUri, Arrays.<Integer>asList(10, 10), FlinkConstants.FLINK_DATASET_CALLBACK_HEADER, dataSetCallback, Long.class);
    Truth.assertThat(pomLinesCount).isEqualTo(numberOfLinesInTestFile * 10 * 10);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:FlinkProducerTest.java


注:本文中的org.apache.flink.api.java.DataSet.count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。