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


Java StreamRecord.getValue方法代码示例

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


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

示例1: compare

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Override
public int compare(Object o1, Object o2) {
	if (o1 instanceof Watermark || o2 instanceof Watermark) {
		return 0;
	} else {
		StreamRecord<Tuple3<String, Long, Long>> sr0 = (StreamRecord<Tuple3<String, Long, Long>>) o1;
		StreamRecord<Tuple3<String, Long, Long>> sr1 = (StreamRecord<Tuple3<String, Long, Long>>) o2;
		if (sr0.getTimestamp() != sr1.getTimestamp()) {
			return (int) (sr0.getTimestamp() - sr1.getTimestamp());
		}
		int comparison = sr0.getValue().f0.compareTo(sr1.getValue().f0);
		if (comparison != 0) {
			return comparison;
		} else {
			comparison = (int) (sr0.getValue().f1 - sr1.getValue().f1);
			if (comparison != 0) {
				return comparison;
			}
			return (int) (sr0.getValue().f1 - sr1.getValue().f1);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:WindowOperatorFrom12MigrationTest.java

示例2: processElement

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Override
public void processElement(final StreamRecord<IN> element) throws Exception {
	this.flinkCollector.setTimestamp(element);

	IN value = element.getValue();

	if (this.stormTopology != null) {
		Tuple tuple = (Tuple) value;
		Integer producerTaskId = tuple.getField(tuple.getArity() - 1);

		this.bolt.execute(new StormTuple<>(value, this.inputSchemas.get(producerTaskId),
				producerTaskId, this.inputStreamIds.get(producerTaskId), this.inputComponentIds
				.get(producerTaskId), MessageId.makeUnanchored()));

	} else {
		this.bolt.execute(new StormTuple<>(value, this.inputSchemas.get(null), -1, null, null,
				MessageId.makeUnanchored()));
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:20,代码来源:BoltWrapper.java

示例3: compare

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Override
public int compare(Object o1, Object o2) {
	if (o1 instanceof Watermark || o2 instanceof Watermark) {
		return 0;
	} else {
		StreamRecord<Tuple3<String, Long, Long>> sr0 = (StreamRecord<Tuple3<String, Long, Long>>) o1;
		StreamRecord<Tuple3<String, Long, Long>> sr1 = (StreamRecord<Tuple3<String, Long, Long>>) o2;
		if (sr0.getTimestamp() != sr1.getTimestamp()) {
			return (int) (sr0.getTimestamp() - sr1.getTimestamp());
		}
		int comparison = sr0.getValue().f0.compareTo(sr1.getValue().f0);
		if (comparison != 0) {
			return comparison;
		} else {
			comparison = (int) (sr0.getValue().f1 - sr1.getValue().f1);
			if (comparison != 0) {
				return comparison;
			}
			return (int) (sr0.getValue().f2 - sr1.getValue().f2);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:WindowOperatorFrom11MigrationTest.java

示例4: compare

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Override
public int compare(Object o1, Object o2) {
	if (o1 instanceof Watermark || o2 instanceof Watermark) {
		return 0;
	} else {
		StreamRecord<Integer> sr0 = (StreamRecord<Integer>) o1;
		StreamRecord<Integer> sr1 = (StreamRecord<Integer>) o2;

		if (sr0.getTimestamp() != sr1.getTimestamp()) {
			return (int) (sr0.getTimestamp() - sr1.getTimestamp());
		}

		int comparison = sr0.getValue().compareTo(sr1.getValue());
		if (comparison != 0) {
			return comparison;
		} else {
			return sr0.getValue() - sr1.getValue();
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:21,代码来源:AsyncWaitOperatorTest.java

示例5: compare

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Override
public int compare(Object o1, Object o2) {
	if (o1 instanceof Watermark || o2 instanceof Watermark) {
		return 0;
	} else {
		StreamRecord<Tuple2<String, Integer>> sr0 = (StreamRecord<Tuple2<String, Integer>>) o1;
		StreamRecord<Tuple2<String, Integer>> sr1 = (StreamRecord<Tuple2<String, Integer>>) o2;
		if (sr0.getTimestamp() != sr1.getTimestamp()) {
			return (int) (sr0.getTimestamp() - sr1.getTimestamp());
		}
		int comparison = sr0.getValue().f0.compareTo(sr1.getValue().f0);
		if (comparison != 0) {
			return comparison;
		} else {
			return sr0.getValue().f1 - sr1.getValue().f1;
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:WindowingTestHarness.java

示例6: snapshotQueueState

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Override
protected void snapshotQueueState(PriorityQueue<StreamRecord<Tuple2<String, IN>>> queue, DataOutputView dataOutputView) throws IOException {
	dataOutputView.writeInt(queue.size());
	for (StreamRecord<Tuple2<String, IN>> record : queue) {
		String streamId = record.getValue().f0;
		dataOutputView.writeUTF(streamId);
		this.getStreamRecordSerializer(streamId).serialize(record, dataOutputView);
	}
}
 
开发者ID:haoch,项目名称:flink-siddhi,代码行数:10,代码来源:SiddhiStreamOperator.java

示例7: snapshotQueueState

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Override
protected void snapshotQueueState(PriorityQueue<StreamRecord<Tuple2<String, IN>>> queue, DataOutputView dataOutputView) throws IOException {
    dataOutputView.writeInt(queue.size());
    for (StreamRecord<Tuple2<String, IN>> record : queue) {
        String streamId = record.getValue().f0;
        dataOutputView.writeUTF(streamId);
        this.getStreamRecordSerializer(streamId).serialize(record, dataOutputView);
    }
}
 
开发者ID:apache,项目名称:bahir-flink,代码行数:10,代码来源:SiddhiStreamOperator.java

示例8: processElement

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Override
public void processElement(
    StreamRecord<WindowedValue<ValueWithRecordId<T>>> streamRecord) throws Exception {
  ByteBuffer currentKey = keyedStateBackend.getCurrentKey();
  int groupIndex = keyedStateBackend.getCurrentKeyGroupIndex();
  if (shouldOutput(groupIndex, currentKey)) {
    WindowedValue<ValueWithRecordId<T>> value = streamRecord.getValue();
    output.collect(streamRecord.replace(value.withValue(value.getValue().getValue())));
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:DedupingOperator.java

示例9: processElement

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Override
public void processElement(StreamRecord<Long> element) throws Exception {
	elCount++;
	if (element.getValue() * 2 != element.getTimestamp()) {
		throw new RuntimeException("Invalid timestamp: " + element);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:Kafka011ITCase.java

示例10: processElement

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Override
public void processElement(StreamRecord<Integer> element) throws Exception {
	if (element.getTimestamp() != element.getValue()) {
		Assert.fail("Timestamps are not properly handled.");
	}
	output.collect(element);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:TimestampITCase.java

示例11: verifyPattern

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
private void verifyPattern(Object outputObject, Event start, SubEvent middle, Event end) {
	assertTrue(outputObject instanceof StreamRecord);

	StreamRecord<?> resultRecord = (StreamRecord<?>) outputObject;
	assertTrue(resultRecord.getValue() instanceof Map);

	@SuppressWarnings("unchecked")
	Map<String, List<Event>> patternMap = (Map<String, List<Event>>) resultRecord.getValue();
	assertEquals(start, patternMap.get("start").get(0));
	assertEquals(middle, patternMap.get("middle").get(0));
	assertEquals(end, patternMap.get("end").get(0));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:CEPRescalingTest.java

示例12: processElement

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Override
public void processElement(StreamRecord<T> element) throws Exception {
	final T value = element.getValue();
	final long newTimestamp = userFunction.extractTimestamp(value,
			element.hasTimestamp() ? element.getTimestamp() : Long.MIN_VALUE);

	output.collect(element.replace(element.getValue(), newTimestamp));

	final Watermark nextWatermark = userFunction.checkAndGetNextWatermark(value, newTimestamp);
	if (nextWatermark != null && nextWatermark.getTimestamp() > currentWatermark) {
		currentWatermark = nextWatermark.getTimestamp();
		output.emitWatermark(nextWatermark);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:15,代码来源:TimestampsAndPunctuatedWatermarksOperator.java

示例13: processElement

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Override
public void processElement(StreamRecord<Integer> element) throws Exception {
	if (verifyRestore) {
		// check restored managed keyed state
		long exp = element.getValue() + 1;
		long act = keyedState.value();
		Assert.assertEquals(exp, act);
	} else {
		// write managed keyed state that goes into snapshot
		keyedState.update(element.getValue() + 1);
		// write managed operator state that goes into snapshot
		opState.add(element.getValue());
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:15,代码来源:StreamOperatorSnapshotRestoreTest.java

示例14: testSinglePatternAfterMigration

import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; //导入方法依赖的package包/类
@Test
public void testSinglePatternAfterMigration() throws Exception {

	KeySelector<Event, Integer> keySelector = new KeySelector<Event, Integer>() {
		private static final long serialVersionUID = -4873366487571254798L;

		@Override
		public Integer getKey(Event value) throws Exception {
			return value.getId();
		}
	};

	final Event startEvent1 = new Event(42, "start", 1.0);

	OneInputStreamOperatorTestHarness<Event, Map<String, List<Event>>> harness =
			new KeyedOneInputStreamOperatorTestHarness<>(
					new KeyedCEPPatternOperator<>(
							Event.createTypeSerializer(),
							false,
							IntSerializer.INSTANCE,
							new SinglePatternNFAFactory(),
							true),
					keySelector,
					BasicTypeInfo.INT_TYPE_INFO);

	try {
		harness.setup();
		harness.initializeState(
			OperatorSnapshotUtil.readStateHandle(
				OperatorSnapshotUtil.getResourceFilename(
					"cep-migration-single-pattern-afterwards-flink1.2-snapshot")));
		harness.open();

		harness.processElement(new StreamRecord<>(startEvent1, 5));

		harness.processWatermark(new Watermark(20));

		ConcurrentLinkedQueue<Object> result = harness.getOutput();

		// watermark and the result
		assertEquals(2, result.size());

		Object resultObject = result.poll();
		assertTrue(resultObject instanceof StreamRecord);
		StreamRecord<?> resultRecord = (StreamRecord<?>) resultObject;
		assertTrue(resultRecord.getValue() instanceof Map);

		@SuppressWarnings("unchecked")
		Map<String, List<Event>> patternMap =
			(Map<String, List<Event>>) resultRecord.getValue();

		assertEquals(startEvent1, patternMap.get("start").get(0));
	} finally {
		harness.close();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:57,代码来源:CEPFrom12MigrationTest.java


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