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


Java TypeHint类代码示例

本文整理汇总了Java中org.apache.flink.api.common.typeinfo.TypeHint的典型用法代码示例。如果您正苦于以下问题:Java TypeHint类的具体用法?Java TypeHint怎么用?Java TypeHint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TypeHint类属于org.apache.flink.api.common.typeinfo包,在下文中一共展示了TypeHint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: open

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
@Override
public void open(Configuration config) {
  ValueStateDescriptor<AbstractStatisticsWrapper<AisMessage>> descriptor =
      new ValueStateDescriptor<AbstractStatisticsWrapper<AisMessage>>("trajectoryStatistics",
          TypeInformation.of(new TypeHint<AbstractStatisticsWrapper<AisMessage>>() {}));

  statisticsOfTrajectory = getRuntimeContext().getState(descriptor);

}
 
开发者ID:ehabqadah,项目名称:in-situ-processing-datAcron,代码行数:10,代码来源:AisStreamEnricher.java

示例2: transformation

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
/**
 * Data transformation.
 * The method group by trackId, sum the number of occurrences, sort the output
 * and get the top elements defined by the user.
 * @param input
 * @return
 */
@Override
public DataSet<ChartsResult> transformation(DataSet<?> input) {
    log.info("Transformation Phase. Computing the tags");
    return input
            .groupBy(0) // Grouping by trackId
            .sum(1) // Sum the occurrences of each grouped item
            .sortPartition(1, Order.DESCENDING).setParallelism(1) // Sort by count
            .first(pipelineConf.args.getLimit())
            .map( t -> {
                    Tuple3<Long, Integer, TagEvent> tuple= (Tuple3<Long, Integer, TagEvent>) t;
                    return new ChartsResult(tuple.f0, tuple.f1, tuple.f2);
            })
            .returns(new TypeHint<ChartsResult>(){});
}
 
开发者ID:aaitor,项目名称:flink-charts,代码行数:22,代码来源:SimpleChartsPipeline.java

示例3: generate

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
@Override
public Graph<LongValue, NullValue, NullValue> generate() {
	Preconditions.checkState(vertexCount >= 0);

	// Vertices
	DataSet<Vertex<LongValue, NullValue>> vertices = GraphGeneratorUtils.vertexSequence(env, parallelism, vertexCount);

	// Edges
	DataSource<Edge<LongValue, NullValue>> edges = env
		.fromCollection(Collections.<Edge<LongValue, NullValue>>emptyList(), TypeInformation.of(new TypeHint<Edge<LongValue, NullValue>>(){}))
			.setParallelism(parallelism)
			.name("Empty edge set");

	// Graph
	return Graph.fromDataSet(vertices, edges, env);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:EmptyGraph.java

示例4: open

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
@Override
public void open(Configuration config) {

	// ===============================================================================
	//   4. When this operator is initialized, you should register and initialize
	//      modelState to be checkpointed by supplying a value state descriptor
	//      to the state backend (through the runtimeContext)
	// ===============================================================================

	// obtain key-value state for prediction model
	ValueStateDescriptor<TravelTimePredictionModel> descriptor =
			new ValueStateDescriptor<>(
					// state name
					"regressionModel",
					// type information of state
					TypeInformation.of(new TypeHint<TravelTimePredictionModel>() {}),
					// default value of state
					new TravelTimePredictionModel());
	modelState = getRuntimeContext().getState(descriptor);
}
 
开发者ID:flink-taiwan,项目名称:jcconf2016-workshop,代码行数:21,代码来源:TaxiRideTravelTimePredictionAnswer.java

示例5: testInputInferenceWithCustomTupleAndRichFunction

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
@Test
public void testInputInferenceWithCustomTupleAndRichFunction() {
	JoinFunction<CustomTuple2WithArray<Long>, CustomTuple2WithArray<Long>, CustomTuple2WithArray<Long>> function = new JoinWithCustomTuple2WithArray<>();

	TypeInformation<?> ti = TypeExtractor.getJoinReturnTypes(
		function,
		new TypeHint<CustomTuple2WithArray<Long>>(){}.getTypeInfo(),
		new TypeHint<CustomTuple2WithArray<Long>>(){}.getTypeInfo());

	Assert.assertTrue(ti.isTupleType());
	TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
	Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));

	Assert.assertTrue(tti.getTypeAt(0) instanceof ObjectArrayTypeInfo<?, ?>);
	ObjectArrayTypeInfo<?, ?> oati = (ObjectArrayTypeInfo<?, ?>) tti.getTypeAt(0);
	Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, oati.getComponentInfo());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:TypeExtractorTest.java

示例6: testWithSimpleGraph

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
@Test
public void testWithSimpleGraph() throws Exception {
	Graph<IntValue, Long, Double> result = undirectedSimpleGraph
		.mapVertices(v -> (long) v.getId().getValue(),
			new TypeHint<Vertex<IntValue, Long>>(){}.getTypeInfo())
		.mapEdges(e -> (double) e.getTarget().getValue() + e.getSource().getValue(),
			new TypeHint<Edge<IntValue, Double>>(){}.getTypeInfo())
		.run(new CommunityDetection<>(10, 0.5));

	String expectedResult =
		"(0,3)\n" +
		"(1,5)\n" +
		"(2,5)\n" +
		"(3,3)\n" +
		"(4,5)\n" +
		"(5,5)\n";

	TestBaseUtils.compareResultAsText(result.getVertices().collect(), expectedResult);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:20,代码来源:CommunityDetectionTest.java

示例7: testWithSingletonEdgeGraph

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
@Test
public void testWithSingletonEdgeGraph() throws Exception {
	Graph<LongValue, Long, Double> result = new SingletonEdgeGraph(env, 1)
		.generate()
		.mapVertices(v -> v.getId().getValue(),
			new TypeHint<Vertex<LongValue, Long>>(){}.getTypeInfo())
		.mapEdges(e -> 1.0,
			new TypeHint<Edge<LongValue, Double>>(){}.getTypeInfo())
		.run(new CommunityDetection<>(10, 0.5));

	String expectedResult =
		"(0,0)\n" +
		"(1,1)\n";

	TestBaseUtils.compareResultAsText(result.getVertices().collect(), expectedResult);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:CommunityDetectionTest.java

示例8: testWithRMatGraph

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
@Test
public void testWithRMatGraph() throws Exception {
	Graph<LongValue, Long, Double> result = undirectedRMatGraph(8, 4)
		.mapVertices(v -> v.getId().getValue(),
			new TypeHint<Vertex<LongValue, Long>>(){}.getTypeInfo())
		.mapEdges(e -> (double) e.getTarget().getValue() - e.getSource().getValue(),
			new TypeHint<Edge<LongValue, Double>>(){}.getTypeInfo())
		.run(new CommunityDetection<>(10, 0.5));

	Checksum checksum = new ChecksumHashCode<Vertex<LongValue, Long>>()
		.run(result.getVertices())
		.execute();

	assertEquals(184, checksum.getCount());
	assertEquals(0x00000000000cdc96L, checksum.getChecksum());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:CommunityDetectionTest.java

示例9: testCassandraBatchFormats

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的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

示例10: cleansing

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
/**
 * Filtering invalid input data.
 * Initially removing TagEvents without trackId
 * The cleansing logic can be encapsulated here
 * @param input
 * @return
 */
@Override
public DataSet<Tuple3<Long, Integer, TagEvent>> cleansing(DataSet<?> input) {
    log.info("Cleansing Phase. Removing invalid TagEvent's");

    return ((DataSet<TagEvent>) input)
            .filter(t -> t.trackId > 0) // Removing all the events with invalid trackids
            .map( t -> new Tuple3<>(t.trackId, 1, t)) // getting tuples
            .returns(new TypeHint<Tuple3<Long, Integer, TagEvent>>(){});
}
 
开发者ID:aaitor,项目名称:flink-charts,代码行数:17,代码来源:SimpleChartsPipeline.java

示例11: cleansing

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
/**
 * Filtering invalid input data.
 * Removing documents without trackId and with a country distinct of the selected
 * in the pipeline configuration.
 * The cleansing logic can be encapsulated here
 * @param input
 * @return
 */
@Override
public DataSet<Tuple4<Long, Integer, String, TagEvent>> cleansing(DataSet<?> input) {
    log.info("Cleansing Phase. Removing invalid TagEvent's");
    String country= pipelineConf.getConfig().getString("ingestion.stateChart.country");
    return ((DataSet<TagEvent>) input)
            .filter( t ->
                    t.geoRegionCountry.equals(country)
                            && t.trackId > 0
            )
            .map( t -> new Tuple4<>(t.trackId, 1, t.geoZone, t))
            .returns(new TypeHint<Tuple4<Long, Integer, String, TagEvent>>(){});
}
 
开发者ID:aaitor,项目名称:flink-charts,代码行数:21,代码来源:StateChartsPipeline.java

示例12: before

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
@Before
public void before() throws Exception {
    operator = new EventTimeOrderingOperator<>();
    operator.setInputType(TypeInformation.of(new TypeHint<Tuple2<String, Long>>() {
    }), new ExecutionConfig());
    testHarness = new KeyedOneInputStreamOperatorTestHarness<>(
            operator, in -> in.f0, TypeInformation.of(String.class));
    testHarness.setTimeCharacteristic(TimeCharacteristic.EventTime);
    testHarness.open();
}
 
开发者ID:pravega,项目名称:flink-connectors,代码行数:11,代码来源:EventTimeOrderingOperatorTest.java

示例13: open

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
@Override
public void open(Configuration config) {
  ValueStateDescriptor<PriorityQueue<Tuple3<String, Long, String>>> descriptor =
      new ValueStateDescriptor<>(
      // state name
          "sorted-raw-messages",
          // type information of state
          TypeInformation.of(new TypeHint<PriorityQueue<Tuple3<String, Long, String>>>() {}));
  queueState = getRuntimeContext().getState(descriptor);
}
 
开发者ID:ehabqadah,项目名称:in-situ-processing-datAcron,代码行数:11,代码来源:RawMessagesSorter.java

示例14: open

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
@Override
public void open(Configuration config) {
  ValueStateDescriptor<Long> descriptor =
      new ValueStateDescriptor<Long>("lastTimestamp", TypeInformation.of(new TypeHint<Long>() {}));
  lastTimestamp = getRuntimeContext().getState(descriptor);

}
 
开发者ID:ehabqadah,项目名称:in-situ-processing-datAcron,代码行数:8,代码来源:StreamPlayer.java

示例15: open

import org.apache.flink.api.common.typeinfo.TypeHint; //导入依赖的package包/类
@Override
public void open(Configuration config) {
  ValueStateDescriptor<PriorityQueue<AisMessage>> descriptor = new ValueStateDescriptor<>(
  // state name
      "sorted-ais-messages",
      // type information of state
      TypeInformation.of(new TypeHint<PriorityQueue<AisMessage>>() {}));
  queueState = getRuntimeContext().getState(descriptor);
}
 
开发者ID:ehabqadah,项目名称:in-situ-processing-datAcron,代码行数:10,代码来源:AisMessagesStreamSorter.java


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