Java Code Examples for org.apache.flink.api.common.typeinfo.TypeInformation#isSortKeyType()
The following examples show how to use
org.apache.flink.api.common.typeinfo.TypeInformation#isSortKeyType() .
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: SortedGrouping.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public <K> SortedGrouping(DataSet<T> set, Keys<T> keys, Keys.SelectorFunctionKeys<T, K> keySelector, Order order) { super(set, keys); if (!(this.keys instanceof Keys.SelectorFunctionKeys)) { throw new InvalidProgramException("Sorting on KeySelector keys only works with KeySelector grouping."); } TypeInformation<?> sortKeyType = keySelector.getKeyType(); if (!sortKeyType.isSortKeyType()) { throw new InvalidProgramException("Key type " + sortKeyType + " is not sortable."); } this.groupSortKeyPositions = keySelector.computeLogicalKeyPositions(); for (int i = 0; i < groupSortKeyPositions.length; i++) { groupSortKeyPositions[i] += this.keys.getNumberOfKeyFields(); } this.groupSortSelectorFunctionKey = keySelector; this.groupSortOrders = new Order[groupSortKeyPositions.length]; Arrays.fill(this.groupSortOrders, order); }
Example 2
Source File: Keys.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public static boolean isSortKey(int fieldPos, TypeInformation<?> type) { if (!type.isTupleType() || !(type instanceof CompositeType)) { throw new InvalidProgramException("Specifying keys via field positions is only valid " + "for tuple data types. Type: " + type); } if (type.getArity() == 0) { throw new InvalidProgramException("Tuple size must be greater than 0. Size: " + type.getArity()); } if(fieldPos < 0 || fieldPos >= type.getArity()) { throw new IndexOutOfBoundsException("Tuple position is out of range: " + fieldPos); } TypeInformation<?> sortKeyType = ((CompositeType<?>)type).getTypeAt(fieldPos); return sortKeyType.isSortKeyType(); }
Example 3
Source File: Keys.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public static boolean isSortKey(String fieldExpr, TypeInformation<?> type) { TypeInformation<?> sortKeyType; fieldExpr = fieldExpr.trim(); if (SELECT_ALL_CHAR.equals(fieldExpr) || SELECT_ALL_CHAR_SCALA.equals(fieldExpr)) { sortKeyType = type; } else { if (type instanceof CompositeType) { sortKeyType = ((CompositeType<?>) type).getTypeAt(fieldExpr); } else { throw new InvalidProgramException( "Field expression must be equal to '" + SELECT_ALL_CHAR + "' or '" + SELECT_ALL_CHAR_SCALA + "' for atomic types."); } } return sortKeyType.isSortKeyType(); }
Example 4
Source File: SortedGrouping.java From flink with Apache License 2.0 | 6 votes |
public <K> SortedGrouping(DataSet<T> set, Keys<T> keys, Keys.SelectorFunctionKeys<T, K> keySelector, Order order) { super(set, keys); if (!(this.keys instanceof Keys.SelectorFunctionKeys)) { throw new InvalidProgramException("Sorting on KeySelector keys only works with KeySelector grouping."); } TypeInformation<?> sortKeyType = keySelector.getKeyType(); if (!sortKeyType.isSortKeyType()) { throw new InvalidProgramException("Key type " + sortKeyType + " is not sortable."); } this.groupSortKeyPositions = keySelector.computeLogicalKeyPositions(); for (int i = 0; i < groupSortKeyPositions.length; i++) { groupSortKeyPositions[i] += this.keys.getNumberOfKeyFields(); } this.groupSortSelectorFunctionKey = keySelector; this.groupSortOrders = new Order[groupSortKeyPositions.length]; Arrays.fill(this.groupSortOrders, order); }
Example 5
Source File: Keys.java From flink with Apache License 2.0 | 6 votes |
public static boolean isSortKey(int fieldPos, TypeInformation<?> type) { if (!type.isTupleType() || !(type instanceof CompositeType)) { throw new InvalidProgramException("Specifying keys via field positions is only valid " + "for tuple data types. Type: " + type); } if (type.getArity() == 0) { throw new InvalidProgramException("Tuple size must be greater than 0. Size: " + type.getArity()); } if(fieldPos < 0 || fieldPos >= type.getArity()) { throw new IndexOutOfBoundsException("Tuple position is out of range: " + fieldPos); } TypeInformation<?> sortKeyType = ((CompositeType<?>)type).getTypeAt(fieldPos); return sortKeyType.isSortKeyType(); }
Example 6
Source File: Keys.java From flink with Apache License 2.0 | 6 votes |
public static boolean isSortKey(String fieldExpr, TypeInformation<?> type) { TypeInformation<?> sortKeyType; fieldExpr = fieldExpr.trim(); if (SELECT_ALL_CHAR.equals(fieldExpr) || SELECT_ALL_CHAR_SCALA.equals(fieldExpr)) { sortKeyType = type; } else { if (type instanceof CompositeType) { sortKeyType = ((CompositeType<?>) type).getTypeAt(fieldExpr); } else { throw new InvalidProgramException( "Field expression must be equal to '" + SELECT_ALL_CHAR + "' or '" + SELECT_ALL_CHAR_SCALA + "' for atomic types."); } } return sortKeyType.isSortKeyType(); }
Example 7
Source File: SortedGrouping.java From flink with Apache License 2.0 | 6 votes |
public <K> SortedGrouping(DataSet<T> set, Keys<T> keys, Keys.SelectorFunctionKeys<T, K> keySelector, Order order) { super(set, keys); if (!(this.keys instanceof Keys.SelectorFunctionKeys)) { throw new InvalidProgramException("Sorting on KeySelector keys only works with KeySelector grouping."); } TypeInformation<?> sortKeyType = keySelector.getKeyType(); if (!sortKeyType.isSortKeyType()) { throw new InvalidProgramException("Key type " + sortKeyType + " is not sortable."); } this.groupSortKeyPositions = keySelector.computeLogicalKeyPositions(); for (int i = 0; i < groupSortKeyPositions.length; i++) { groupSortKeyPositions[i] += this.keys.getNumberOfKeyFields(); } this.groupSortSelectorFunctionKey = keySelector; this.groupSortOrders = new Order[groupSortKeyPositions.length]; Arrays.fill(this.groupSortOrders, order); }
Example 8
Source File: Keys.java From flink with Apache License 2.0 | 6 votes |
public static boolean isSortKey(int fieldPos, TypeInformation<?> type) { if (!type.isTupleType() || !(type instanceof CompositeType)) { throw new InvalidProgramException("Specifying keys via field positions is only valid " + "for tuple data types. Type: " + type); } if (type.getArity() == 0) { throw new InvalidProgramException("Tuple size must be greater than 0. Size: " + type.getArity()); } if(fieldPos < 0 || fieldPos >= type.getArity()) { throw new IndexOutOfBoundsException("Tuple position is out of range: " + fieldPos); } TypeInformation<?> sortKeyType = ((CompositeType<?>)type).getTypeAt(fieldPos); return sortKeyType.isSortKeyType(); }
Example 9
Source File: Keys.java From flink with Apache License 2.0 | 6 votes |
public static boolean isSortKey(String fieldExpr, TypeInformation<?> type) { TypeInformation<?> sortKeyType; fieldExpr = fieldExpr.trim(); if (SELECT_ALL_CHAR.equals(fieldExpr) || SELECT_ALL_CHAR_SCALA.equals(fieldExpr)) { sortKeyType = type; } else { if (type instanceof CompositeType) { sortKeyType = ((CompositeType<?>) type).getTypeAt(fieldExpr); } else { throw new InvalidProgramException( "Field expression must be equal to '" + SELECT_ALL_CHAR + "' or '" + SELECT_ALL_CHAR_SCALA + "' for atomic types."); } } return sortKeyType.isSortKeyType(); }