org.apache.flink.api.common.operators.Keys.ExpressionKeys Java Examples
The following examples show how to use
org.apache.flink.api.common.operators.Keys.ExpressionKeys.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExpressionKeysTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testAreCompatible9() throws Keys.IncompatibleKeysException { TypeInformation<Tuple3<String, Long, Integer>> t1 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO ); TypeInformation<PojoWithMultiplePojos> t2 = TypeExtractor.getForClass(PojoWithMultiplePojos.class); ExpressionKeys<Tuple3<String, Long, Integer>> ek1 = new ExpressionKeys<>(new int[]{2,0}, t1); Keys<PojoWithMultiplePojos> ek2 = new Keys.SelectorFunctionKeys<>( new KeySelector3(), t2, new TupleTypeInfo<Tuple2<Integer, String>>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO) ); Assert.assertTrue(ek1.areCompatible(ek2)); }
Example #2
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testStandardTupleKeys() { TupleTypeInfo<Tuple7<String, String, String, String, String, String, String>> typeInfo = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO); ExpressionKeys<Tuple7<String, String, String, String, String, String, String>> ek; for( int i = 1; i < 8; i++) { int[] ints = new int[i]; for( int j = 0; j < i; j++) { ints[j] = j; } int[] inInts = Arrays.copyOf(ints, ints.length); // copy, just to make sure that the code is not cheating by changing the ints. ek = new ExpressionKeys<>(inInts, typeInfo); Assert.assertArrayEquals(ints, ek.computeLogicalKeyPositions()); Assert.assertEquals(ints.length, ek.computeLogicalKeyPositions().length); ArrayUtils.reverse(ints); inInts = Arrays.copyOf(ints, ints.length); ek = new ExpressionKeys<>(inInts, typeInfo); Assert.assertArrayEquals(ints, ek.computeLogicalKeyPositions()); Assert.assertEquals(ints.length, ek.computeLogicalKeyPositions().length); } }
Example #3
Source File: ExpressionKeysTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testInvalidTuple() throws Throwable { TupleTypeInfo<Tuple3<String, Tuple3<String, String, String>, String>> typeInfo = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, new TupleTypeInfo<Tuple3<String, String, String>>(BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO), BasicTypeInfo.STRING_TYPE_INFO); String[][] tests = new String[][] { new String[] {"f0.f1"}, // nesting into unnested new String[] {"f11"}, new String[] {"f-35"}, new String[] {"f0.f33"}, new String[] {"f1.f33"} }; for (String[] test : tests) { Throwable e = null; try { new ExpressionKeys<>(test, typeInfo); } catch (Throwable t) { e = t; } Assert.assertNotNull(e); } }
Example #4
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testInvalidPojo() throws Throwable { TypeInformation<ComplexNestedClass> ti = TypeExtractor.getForClass(ComplexNestedClass.class); String[][] tests = new String[][] { new String[] {"nonexistent"}, new String[] {"date.abc"} // nesting into unnested }; for (String[] test : tests) { Throwable e = null; try { new ExpressionKeys<>(test, ti); } catch (Throwable t) { e = t; } Assert.assertNotNull(e); } }
Example #5
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testPojoKeys() { TypeInformation<PojoWithMultiplePojos> ti = TypeExtractor.getForClass(PojoWithMultiplePojos.class); ExpressionKeys<PojoWithMultiplePojos> ek; ek = new ExpressionKeys<>("*", ti); Assert.assertArrayEquals(new int[] {0,1,2,3,4}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>("p1.*", ti); Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>("p2.*", ti); Assert.assertArrayEquals(new int[] {3,4}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>("p1", ti); Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>("p2", ti); Assert.assertArrayEquals(new int[] {3,4}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>("i0", ti); Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions()); }
Example #6
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testAreCompatible9() throws Keys.IncompatibleKeysException { TypeInformation<Tuple3<String, Long, Integer>> t1 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO ); TypeInformation<PojoWithMultiplePojos> t2 = TypeExtractor.getForClass(PojoWithMultiplePojos.class); ExpressionKeys<Tuple3<String, Long, Integer>> ek1 = new ExpressionKeys<>(new int[]{2,0}, t1); Keys<PojoWithMultiplePojos> ek2 = new Keys.SelectorFunctionKeys<>( new KeySelector3(), t2, new TupleTypeInfo<Tuple2<Integer, String>>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO) ); Assert.assertTrue(ek1.areCompatible(ek2)); }
Example #7
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testStandardTupleKeys() { TupleTypeInfo<Tuple7<String, String, String, String, String, String, String>> typeInfo = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO); ExpressionKeys<Tuple7<String, String, String, String, String, String, String>> ek; for( int i = 1; i < 8; i++) { int[] ints = new int[i]; for( int j = 0; j < i; j++) { ints[j] = j; } int[] inInts = Arrays.copyOf(ints, ints.length); // copy, just to make sure that the code is not cheating by changing the ints. ek = new ExpressionKeys<>(inInts, typeInfo); Assert.assertArrayEquals(ints, ek.computeLogicalKeyPositions()); Assert.assertEquals(ints.length, ek.computeLogicalKeyPositions().length); ArrayUtils.reverse(ints); inInts = Arrays.copyOf(ints, ints.length); ek = new ExpressionKeys<>(inInts, typeInfo); Assert.assertArrayEquals(ints, ek.computeLogicalKeyPositions()); Assert.assertEquals(ints.length, ek.computeLogicalKeyPositions().length); } }
Example #8
Source File: ExpressionKeysTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testAreCompatible3() throws Keys.IncompatibleKeysException { TypeInformation<String> t1 = BasicTypeInfo.STRING_TYPE_INFO; TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); ExpressionKeys<String> ek1 = new ExpressionKeys<>("*", t1); ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
Example #9
Source File: ExpressionKeysTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test(expected = Keys.IncompatibleKeysException.class) public void testAreCompatible7() throws Keys.IncompatibleKeysException { TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class); TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>(new String[]{"a", "b"}, t1); ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2); ek1.areCompatible(ek2); }
Example #10
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testAreCompatible1() throws Keys.IncompatibleKeysException { TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class); ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1); ExpressionKeys<Pojo1> ek2 = new ExpressionKeys<>("b", t1); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
Example #11
Source File: ExpressionKeysTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testAreCompatible5() throws Keys.IncompatibleKeysException { TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class); TypeInformation<Tuple2<String, String>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO ); ExpressionKeys<PojoWithMultiplePojos> ek1 = new ExpressionKeys<>(new String[]{"p1.b", "p2.a2"}, t1); ExpressionKeys<Tuple2<String, String>> ek2 = new ExpressionKeys<>("*", t2); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
Example #12
Source File: ExpressionKeysTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testAreCompatible4() throws Keys.IncompatibleKeysException { TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class); TypeInformation<Tuple3<String, Long, Integer>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO ); ExpressionKeys<PojoWithMultiplePojos> ek1 = new ExpressionKeys<>(new String[]{"p1", "i0"}, t1); ExpressionKeys<Tuple3<String, Long, Integer>> ek2 = new ExpressionKeys<>(new int[]{0, 0, 2}, t2); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
Example #13
Source File: PojoComparatorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override protected TypeComparator<PojoContainingTuple> createComparator(boolean ascending) { Assert.assertTrue(type instanceof CompositeType); CompositeType<PojoContainingTuple> cType = (CompositeType<PojoContainingTuple>) type; ExpressionKeys<PojoContainingTuple> keys = new ExpressionKeys<PojoContainingTuple>(new String[] {"theTuple.*"}, cType); boolean[] orders = new boolean[keys.getNumberOfKeyFields()]; Arrays.fill(orders, ascending); return cType.createComparator(keys.computeLogicalKeyPositions(), orders, 0, new ExecutionConfig()); }
Example #14
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testTupleWithNestedPojo() { TypeInformation<Tuple3<Integer, Pojo1, PojoWithMultiplePojos>> ti = new TupleTypeInfo<>( BasicTypeInfo.INT_TYPE_INFO, TypeExtractor.getForClass(Pojo1.class), TypeExtractor.getForClass(PojoWithMultiplePojos.class) ); ExpressionKeys<Tuple3<Integer, Pojo1, PojoWithMultiplePojos>> ek; ek = new ExpressionKeys<>(0, ti); Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>(1, ti); Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>(2, ti); Assert.assertArrayEquals(new int[] {3,4,5,6,7}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>(new int[]{}, ti, true); Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6,7}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>("*", ti); Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6,7}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>("f2.p1.*", ti); Assert.assertArrayEquals(new int[] {4,5}, ek.computeLogicalKeyPositions()); }
Example #15
Source File: ExpressionKeysTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testTupleWithNestedPojo() { TypeInformation<Tuple3<Integer, Pojo1, PojoWithMultiplePojos>> ti = new TupleTypeInfo<>( BasicTypeInfo.INT_TYPE_INFO, TypeExtractor.getForClass(Pojo1.class), TypeExtractor.getForClass(PojoWithMultiplePojos.class) ); ExpressionKeys<Tuple3<Integer, Pojo1, PojoWithMultiplePojos>> ek; ek = new ExpressionKeys<>(0, ti); Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>(1, ti); Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>(2, ti); Assert.assertArrayEquals(new int[] {3,4,5,6,7}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>(new int[]{}, ti, true); Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6,7}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>("*", ti); Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6,7}, ek.computeLogicalKeyPositions()); ek = new ExpressionKeys<>("f2.p1.*", ti); Assert.assertArrayEquals(new int[] {4,5}, ek.computeLogicalKeyPositions()); }
Example #16
Source File: SortedGrouping.java From flink with Apache License 2.0 | 5 votes |
public SortedGrouping(DataSet<T> set, Keys<T> keys, String field, Order order) { super(set, keys); if (!Keys.ExpressionKeys.isSortKey(field, inputDataSet.getType())) { throw new InvalidProgramException("Selected sort key is not a sortable type"); } // resolve String-field to int using the expression keys ExpressionKeys<T> ek = new ExpressionKeys<>(field, inputDataSet.getType()); this.groupSortKeyPositions = ek.computeLogicalKeyPositions(); this.groupSortOrders = new Order[groupSortKeyPositions.length]; Arrays.fill(this.groupSortOrders, order); // if field == "*" }
Example #17
Source File: ExpressionKeysTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testAreCompatible2() throws Keys.IncompatibleKeysException { TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class); TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1); ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
Example #18
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testAreCompatible2() throws Keys.IncompatibleKeysException { TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class); TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1); ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
Example #19
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testBasicType() { TypeInformation<Long> longType = BasicTypeInfo.LONG_TYPE_INFO; ExpressionKeys<Long> ek = new ExpressionKeys<>("*", longType); Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions()); }
Example #20
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 5 votes |
@Test(expected = Keys.IncompatibleKeysException.class) public void testAreCompatible6() throws Keys.IncompatibleKeysException { TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class); TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1); ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(1, t2); ek1.areCompatible(ek2); }
Example #21
Source File: SortedGrouping.java From flink with Apache License 2.0 | 5 votes |
public SortedGrouping(DataSet<T> set, Keys<T> keys, String field, Order order) { super(set, keys); if (!Keys.ExpressionKeys.isSortKey(field, inputDataSet.getType())) { throw new InvalidProgramException("Selected sort key is not a sortable type"); } // resolve String-field to int using the expression keys ExpressionKeys<T> ek = new ExpressionKeys<>(field, inputDataSet.getType()); this.groupSortKeyPositions = ek.computeLogicalKeyPositions(); this.groupSortOrders = new Order[groupSortKeyPositions.length]; Arrays.fill(this.groupSortOrders, order); // if field == "*" }
Example #22
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testAreCompatible3() throws Keys.IncompatibleKeysException { TypeInformation<String> t1 = BasicTypeInfo.STRING_TYPE_INFO; TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); ExpressionKeys<String> ek1 = new ExpressionKeys<>("*", t1); ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
Example #23
Source File: SortedGrouping.java From flink with Apache License 2.0 | 5 votes |
private void addSortGroupInternal(ExpressionKeys<T> ek, Order order) { Preconditions.checkArgument(order != null, "Order can not be null"); int[] additionalKeyPositions = ek.computeLogicalKeyPositions(); int newLength = this.groupSortKeyPositions.length + additionalKeyPositions.length; this.groupSortKeyPositions = Arrays.copyOf(this.groupSortKeyPositions, newLength); this.groupSortOrders = Arrays.copyOf(this.groupSortOrders, newLength); int pos = newLength - additionalKeyPositions.length; int off = newLength - additionalKeyPositions.length; for (; pos < newLength; pos++) { this.groupSortKeyPositions[pos] = additionalKeyPositions[pos - off]; this.groupSortOrders[pos] = order; // use the same order } }
Example #24
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testAreCompatible1() throws Keys.IncompatibleKeysException { TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class); ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1); ExpressionKeys<Pojo1> ek2 = new ExpressionKeys<>("b", t1); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
Example #25
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testAreCompatible4() throws Keys.IncompatibleKeysException { TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class); TypeInformation<Tuple3<String, Long, Integer>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO ); ExpressionKeys<PojoWithMultiplePojos> ek1 = new ExpressionKeys<>(new String[]{"p1", "i0"}, t1); ExpressionKeys<Tuple3<String, Long, Integer>> ek2 = new ExpressionKeys<>(new int[]{0, 0, 2}, t2); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
Example #26
Source File: PojoComparatorTest.java From flink with Apache License 2.0 | 5 votes |
@Override protected TypeComparator<PojoContainingTuple> createComparator(boolean ascending) { Assert.assertTrue(type instanceof CompositeType); CompositeType<PojoContainingTuple> cType = (CompositeType<PojoContainingTuple>) type; ExpressionKeys<PojoContainingTuple> keys = new ExpressionKeys<PojoContainingTuple>(new String[] {"theTuple.*"}, cType); boolean[] orders = new boolean[keys.getNumberOfKeyFields()]; Arrays.fill(orders, ascending); return cType.createComparator(keys.computeLogicalKeyPositions(), orders, 0, new ExecutionConfig()); }
Example #27
Source File: SortedGrouping.java From flink with Apache License 2.0 | 5 votes |
private void addSortGroupInternal(ExpressionKeys<T> ek, Order order) { Preconditions.checkArgument(order != null, "Order can not be null"); int[] additionalKeyPositions = ek.computeLogicalKeyPositions(); int newLength = this.groupSortKeyPositions.length + additionalKeyPositions.length; this.groupSortKeyPositions = Arrays.copyOf(this.groupSortKeyPositions, newLength); this.groupSortOrders = Arrays.copyOf(this.groupSortOrders, newLength); int pos = newLength - additionalKeyPositions.length; int off = newLength - additionalKeyPositions.length; for (; pos < newLength; pos++) { this.groupSortKeyPositions[pos] = additionalKeyPositions[pos - off]; this.groupSortOrders[pos] = order; // use the same order } }
Example #28
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testBasicType() { TypeInformation<Long> longType = BasicTypeInfo.LONG_TYPE_INFO; ExpressionKeys<Long> ek = new ExpressionKeys<>("*", longType); Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions()); }
Example #29
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testKeyGenericType() { TypeInformation<GenericKeyType> genericType = new GenericTypeInfo<>(GenericKeyType.class); ExpressionKeys<GenericKeyType> ek = new ExpressionKeys<>("*", genericType); Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions()); }
Example #30
Source File: ExpressionKeysTest.java From flink with Apache License 2.0 | 5 votes |
@Test(expected = InvalidProgramException.class) public void testTupleNonKeyField() { // selected field is not a key type TypeInformation<Tuple3<String, Long, GenericNonKeyType>> ti = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO, TypeExtractor.getForClass(GenericNonKeyType.class) ); new ExpressionKeys<>(2, ti); }