/** * Partitions the operator state of a {@link DataStream} by the given key positions. * * @param fields * The position of the fields on which the {@link DataStream} * will be grouped. * @return The {@link DataStream} with partitioned state (i.e. KeyedStream) */ public KeyedStream<T, Tuple> keyBy(int... fields) { if (getType() instanceof BasicArrayTypeInfo || getType() instanceof PrimitiveArrayTypeInfo) { return keyBy(KeySelectorUtil.getSelectorForArray(fields, getType())); } else { return keyBy(new Keys.ExpressionKeys<>(fields, getType())); } }
private KeyedStream<T, Tuple> keyBy(Keys<T> keys) { return new KeyedStream<>(this, clean(KeySelectorUtil.getSelectorForKeys(keys, getType(), getExecutionConfig()))); }
private <K> DataStream<T> partitionCustom(Partitioner<K> partitioner, Keys<T> keys) { KeySelector<T, K> keySelector = KeySelectorUtil.getSelectorForOneKey(keys, partitioner, getType(), getExecutionConfig()); return setConnectionType( new CustomPartitionerWrapper<>( clean(partitioner), clean(keySelector))); }
KeySelector<MyPojo, Tuple> keySelector = KeySelectorUtil.getSelectorForKeys( new Keys.ExpressionKeys<>(new String[]{"f0"}, typeInfo), typeInfo, config);
@Test public void testObjectArrays() { try { String[] array1 = { "a", "b", "c", "d", "e" }; String[] array2 = { "v", "w", "x", "y", "z" }; KeySelectorUtil.ArrayKeySelector<String[]> singleFieldSelector = KeySelectorUtil.getSelectorForArray(new int[] {1}, BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO); assertEquals(new Tuple1<>("b"), singleFieldSelector.getKey(array1)); assertEquals(new Tuple1<>("w"), singleFieldSelector.getKey(array2)); KeySelectorUtil.ArrayKeySelector<String[]> twoFieldsSelector = KeySelectorUtil.getSelectorForArray(new int[] {3, 0}, BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO); assertEquals(new Tuple2<>("d", "a"), twoFieldsSelector.getKey(array1)); assertEquals(new Tuple2<>("y", "v"), twoFieldsSelector.getKey(array2)); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
private <K> DataStream<T> partitionCustom(Partitioner<K> partitioner, Keys<T> keys) { KeySelector<T, K> keySelector = KeySelectorUtil.getSelectorForOneKey(keys, partitioner, getType(), getExecutionConfig()); return setConnectionType( new CustomPartitionerWrapper<>( clean(partitioner), clean(keySelector))); }
KeySelector<Tuple2<Integer, Integer>, Tuple> keySelector = KeySelectorUtil.getSelectorForKeys( new Keys.ExpressionKeys<>(new int[]{0}, typeInfo), typeInfo, config);
@Test public void testPrimitiveArrays() { try { int[] array1 = { 1, 2, 3, 4, 5 }; int[] array2 = { -5, -4, -3, -2, -1, 0 }; KeySelectorUtil.ArrayKeySelector<int[]> singleFieldSelector = KeySelectorUtil.getSelectorForArray(new int[] {1}, PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO); assertEquals(new Tuple1<>(2), singleFieldSelector.getKey(array1)); assertEquals(new Tuple1<>(-4), singleFieldSelector.getKey(array2)); KeySelectorUtil.ArrayKeySelector<int[]> twoFieldsSelector = KeySelectorUtil.getSelectorForArray(new int[] {3, 0}, PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO); assertEquals(new Tuple2<>(4, 1), twoFieldsSelector.getKey(array1)); assertEquals(new Tuple2<>(-2, -5), twoFieldsSelector.getKey(array2)); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } } }
private <K> DataStream<T> partitionCustom(Partitioner<K> partitioner, Keys<T> keys) { KeySelector<T, K> keySelector = KeySelectorUtil.getSelectorForOneKey(keys, partitioner, getType(), getExecutionConfig()); return setConnectionType( new CustomPartitionerWrapper<>( clean(partitioner), clean(keySelector))); }
KeySelector<MyPojo3, Tuple> keySelector = KeySelectorUtil.getSelectorForKeys( new Keys.ExpressionKeys<>(new String[]{"f0"}, typeInfo), typeInfo, config);
/** * Partitions the operator state of a {@link DataStream} by the given key positions. * * @param fields * The position of the fields on which the {@link DataStream} * will be grouped. * @return The {@link DataStream} with partitioned state (i.e. KeyedStream) */ public KeyedStream<T, Tuple> keyBy(int... fields) { if (getType() instanceof BasicArrayTypeInfo || getType() instanceof PrimitiveArrayTypeInfo) { return keyBy(KeySelectorUtil.getSelectorForArray(fields, getType())); } else { return keyBy(new Keys.ExpressionKeys<>(fields, getType())); } }
private <K> DataStream<T> partitionCustom(Partitioner<K> partitioner, Keys<T> keys) { KeySelector<T, K> keySelector = KeySelectorUtil.getSelectorForOneKey(keys, partitioner, getType(), getExecutionConfig()); return setConnectionType( new CustomPartitionerWrapper<>( clean(partitioner), clean(keySelector))); }
KeySelector<Tuple3<Integer, Integer, Integer>, Tuple> keySelector = KeySelectorUtil.getSelectorForKeys( new Keys.ExpressionKeys<>(new int[]{0}, typeInfo), typeInfo, config);
/** * Partitions the operator state of a {@link DataStream} by the given key positions. * * @param fields * The position of the fields on which the {@link DataStream} * will be grouped. * @return The {@link DataStream} with partitioned state (i.e. KeyedStream) */ public KeyedStream<T, Tuple> keyBy(int... fields) { if (getType() instanceof BasicArrayTypeInfo || getType() instanceof PrimitiveArrayTypeInfo) { return keyBy(KeySelectorUtil.getSelectorForArray(fields, getType())); } else { return keyBy(new Keys.ExpressionKeys<>(fields, getType())); } }
private KeyedStream<T, Tuple> keyBy(Keys<T> keys) { return new KeyedStream<>(this, clean(KeySelectorUtil.getSelectorForKeys(keys, getType(), getExecutionConfig()))); }
/** * Partitions the operator state of a {@link DataStream} by the given key positions. * * @param fields * The position of the fields on which the {@link DataStream} * will be grouped. * @return The {@link DataStream} with partitioned state (i.e. KeyedStream) */ public KeyedStream<T, Tuple> keyBy(int... fields) { if (getType() instanceof BasicArrayTypeInfo || getType() instanceof PrimitiveArrayTypeInfo) { return keyBy(KeySelectorUtil.getSelectorForArray(fields, getType())); } else { return keyBy(new Keys.ExpressionKeys<>(fields, getType())); } }
private KeyedStream<T, Tuple> keyBy(Keys<T> keys) { return new KeyedStream<>(this, clean(KeySelectorUtil.getSelectorForKeys(keys, getType(), getExecutionConfig()))); }
private KeyedStream<T, Tuple> keyBy(Keys<T> keys) { return new KeyedStream<>(this, clean(KeySelectorUtil.getSelectorForKeys(keys, getType(), getExecutionConfig()))); }