本文整理汇总了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);
}
}
}
示例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()));
}
}
示例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);
}
}
}
示例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();
}
}
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
}
示例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())));
}
}
示例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);
}
}
示例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);
}
示例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));
}
示例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);
}
}
示例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());
}
}
示例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();
}
}