本文整理匯總了Java中org.apache.flink.streaming.api.datastream.DataStream.keyBy方法的典型用法代碼示例。如果您正苦於以下問題:Java DataStream.keyBy方法的具體用法?Java DataStream.keyBy怎麽用?Java DataStream.keyBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.flink.streaming.api.datastream.DataStream
的用法示例。
在下文中一共展示了DataStream.keyBy方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple3<K, AnomalyResult, RV>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector , KeySelector<V,Double> valueSelector, PayloadFold<V, RV> valueFold, Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Object> foldResultType = TypeExtractor.getUnaryOperatorReturnType(valueFold,
PayloadFold.class,
false,
false,
ds.getType(),
"PayloadFold",
false);
TypeInformation<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple3.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO), foldResultType});
Tuple3<K,Tuple4<Double,Double,Long,Long>, RV> init= new Tuple3<>(null,new Tuple4<>(0d,0d,0l,0l), valueFold.getInit());
KeyedStream<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new ExtCountWindFold<>(keySelector,valueFold, window, resultType),new ExtWindowTimeExtractor(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例2: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple3<K, AnomalyResult, RV>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector , KeySelector<V,Double> valueSelector, PayloadFold<V, RV> valueFold, Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Object> foldResultType = TypeExtractor.getUnaryOperatorReturnType(valueFold,
PayloadFold.class,
false,
false,
ds.getType(),
"PayloadFold",
false);
TypeInformation<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple3.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO), foldResultType});
Tuple3<K,Tuple4<Double,Double,Long,Long>, RV> init= new Tuple3<>(null,new Tuple4<>(0d,0d,0l,0l), valueFold.getInit());
KeyedStream<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new ExtCountSumFold<>(keySelector, valueSelector, valueFold, resultType), new ExtWindowTimeExtractor(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例3: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple2<K, AnomalyResult>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector , Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Tuple2<K,Tuple4<Double,Double,Long,Long>>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple2.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO)});
Tuple2<K,Tuple4<Double,Double,Long,Long>> init= new Tuple2<>(null,new Tuple4<>(0d,0d,0l,0l));
KeyedStream<Tuple2<K,Tuple4<Double,Double,Long,Long>>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new CountWindFold<>(keySelector, window, resultType),new WindowTimeExtractor(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例4: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple2<K, AnomalyResult>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector , KeySelector<V,Double> valueSelector, Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Tuple2<K,Tuple4<Double,Double,Long,Long>>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple2.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO)});
Tuple2<K,Tuple4<Double,Double,Long,Long>> init= new Tuple2<>(null,new Tuple4<>(0d,0d,0l,0l));
KeyedStream<Tuple2<K,Tuple4<Double,Double,Long,Long>>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new CountSumFold<>(keySelector, valueSelector, resultType), new WindowTimeExtractor(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例5: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple2<K, AnomalyResult>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector, KeySelector<V,Double> valueSelector, Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Tuple2<K,Tuple4<Double,Double,Long,Long>>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple2.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO)});
Tuple2<K,Tuple4<Double,Double,Long,Long>> init= new Tuple2<>(null,new Tuple4<>(0d,0d,0l,0l));
KeyedStream<Tuple2<K,Tuple4<Double,Double,Long,Long>>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new CountSumFold<>(keySelector,valueSelector, resultType),new WindowTimeExtractor(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例6: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple3<K, AnomalyResult, RV>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector, KeySelector<V,Double> valueSelector, PayloadFold<V, RV> valueFold, Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Object> foldResultType = TypeExtractor.getUnaryOperatorReturnType(valueFold,
PayloadFold.class,
false,
false,
ds.getType(),
"PayloadFold",
false);
TypeInformation<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple3.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO), foldResultType});
Tuple3<K,Tuple4<Double,Double,Long,Long>, RV> init= new Tuple3<>(null,new Tuple4<>(0d,0d,0l,0l), valueFold.getInit());
KeyedStream<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new ExtCountSumFold<>(keySelector,valueSelector,valueFold, resultType),new ExtWindowTimeExtractor(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例7: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple2<K, AnomalyResult>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector , Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Tuple2<K,Tuple4<Double,Double,Long,Long>>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple2.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO)});
Tuple2<K,Tuple4<Double,Double,Long,Long>> init= new Tuple2<>(null,new Tuple4<>(0d,0d,0l,0l));
KeyedStream<Tuple2<K,Tuple4<Double,Double,Long,Long>>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new CountWindFold<>(keySelector, window, resultType),new WindowTimeExtractor(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例8: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple3<K, AnomalyResult, RV>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector , PayloadFold<V, RV> valueFold, Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Object> foldResultType = TypeExtractor.getUnaryOperatorReturnType(valueFold,
PayloadFold.class,
false,
false,
ds.getType(),
"PayloadFold",
false);
TypeInformation<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple3.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO), foldResultType});
Tuple3<K,Tuple4<Double,Double,Long,Long>, RV> init= new Tuple3<>(null,new Tuple4<>(0d,0d,0l,0l), valueFold.getInit());
KeyedStream<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new ExtCountWindFold<>(keySelector,valueFold, window, resultType),new ExtWindowTimeExtractor(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例9: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple3<K, AnomalyResult, RV>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector, KeySelector<V,Double> valueSelector, PayloadFold<V, RV> valueFold, Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Object> foldResultType = TypeExtractor.getUnaryOperatorReturnType(valueFold,
PayloadFold.class,
false,
false,
ds.getType(),
"PayloadFold",
false);
TypeInformation<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple3.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO), foldResultType});
Tuple3<K,Tuple4<Double,Double,Long,Long>, RV> init= new Tuple3<>(null,new Tuple4<>(0d,0d,0l,0l), valueFold.getInit());
KeyedStream<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new ExtLogCountSumFold<>(keySelector,valueSelector,valueFold, resultType),new ExtWindowTimeExtractor(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例10: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple3<K, AnomalyResult, RV>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector, KeySelector<V,Double> valueSelector, PayloadFold<V, RV> valueFold, Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Object> foldResultType = TypeExtractor.getUnaryOperatorReturnType(valueFold,
PayloadFold.class,
false,
false,
ds.getType(),
"PayloadFold",
false);
TypeInformation<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple2.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO), foldResultType});
Tuple3<K,Tuple4<Double,Double,Long,Long>, RV> init= new Tuple3<>(null,new Tuple4<>(0d,0d,0l,0l), valueFold.getInit());
KeyedStream<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new ExtLogCountSumFold<>(keySelector,valueSelector,valueFold, resultType),new ExtWindowTimeExtractor(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例11: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple3<K, AnomalyResult, RV>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector, PayloadFold<V, RV> valueFold, Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Object> foldResultType = TypeExtractor.getUnaryOperatorReturnType(valueFold,
PayloadFold.class,
false,
false,
ds.getType(),
"PayloadFold",
false);
TypeInformation<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple3.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO), foldResultType});
Tuple3<K,Tuple4<Double,Double,Long,Long>, RV> init= new Tuple3<>(null,new Tuple4<>(0d,0d,0l,0l), valueFold.getInit());
KeyedStream<Tuple3<K,Tuple4<Double,Double,Long,Long>,RV>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new ExtCountWindFold<>(keySelector,valueFold, window, resultType),new ExtWindowTimeExtractor(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例12: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple2<K, AnomalyResult>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector, Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Tuple2<K,Tuple4<Double,Double,Long,Long>>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple2.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO)});
Tuple2<K,Tuple4<Double,Double,Long,Long>> init= new Tuple2<>(null,new Tuple4<>(0d,0d,0l,0l));
KeyedStream<Tuple2<K,Tuple4<Double,Double,Long,Long>>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new CountWindFold<>(keySelector, window, resultType),new WindowTimeExtractor(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例13: testTupleNestedArrayKeyRejection
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
@Test
public void testTupleNestedArrayKeyRejection() {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream<Tuple2<Integer[], String>> input = env.fromElements(
new Tuple2<>(new Integer[] {1, 2}, "test-test"));
TypeInformation<?> expectedTypeInfo = new TupleTypeInfo<Tuple2<Integer[], String>>(
BasicArrayTypeInfo.INT_ARRAY_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);
// adjust the rule
expectedException.expect(InvalidProgramException.class);
expectedException.expectMessage(new StringStartsWith("Type " + expectedTypeInfo + " cannot be used as key."));
input.keyBy(new KeySelector<Tuple2<Integer[], String>, Tuple2<Integer[], String>>() {
@Override
public Tuple2<Integer[], String> getKey(Tuple2<Integer[], String> value) throws Exception {
return value;
}
});
}
示例14: getAnomalySteam
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
public DataStream<Tuple2<K, AnomalyResult>> getAnomalySteam(DataStream<V> ds, KeySelector<V, K> keySelector, KeySelector<V,Double> valueSelector, Time window) {
KeyedStream<V, K> keyedInput = ds
.keyBy(keySelector);
TypeInformation<Tuple2<K,Tuple4<Double,Double,Long,Long>>> resultType = (TypeInformation) new TupleTypeInfo<>(Tuple2.class,
new TypeInformation[] {keyedInput.getKeyType(), new TupleTypeInfo(Tuple4.class,
BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO)});
Tuple2<K,Tuple4<Double,Double,Long,Long>> init= new Tuple2<>(null,new Tuple4<>(0d,0d,0l,0l));
KeyedStream<Tuple2<K,Tuple4<Double,Double,Long,Long>>, Tuple> kPreStream = keyedInput
.timeWindow(window)
.apply(init, new CountSumFold<>(keySelector,valueSelector, resultType),new WindowTimeExtractor<>(resultType))
.keyBy(0);
return kPreStream.flatMap(afm);
}
示例15: testPOJOWithNestedArrayNoHashCodeKeyRejection
import org.apache.flink.streaming.api.datastream.DataStream; //導入方法依賴的package包/類
@Test
public void testPOJOWithNestedArrayNoHashCodeKeyRejection() {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream<POJOWithHashCode> input = env.fromElements(
new POJOWithHashCode(new int[] {1, 2}));
TypeInformation<?> expectedTypeInfo = new TupleTypeInfo<Tuple1<int[]>>(
PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO);
// adjust the rule
expectedException.expect(InvalidProgramException.class);
expectedException.expectMessage(new StringStartsWith("Type " + expectedTypeInfo + " cannot be used as key."));
input.keyBy("id");
}