Java Code Examples for org.apache.flink.api.common.operators.util.FieldSet#contains()
The following examples show how to use
org.apache.flink.api.common.operators.util.FieldSet#contains() .
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: SingleInputSemanticProperties.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private boolean isTargetFieldPresent(int targetField) { for(FieldSet targetFields : fieldMapping.values()) { if(targetFields.contains(targetField)) { return true; } } return false; }
Example 2
Source File: Ordering.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public boolean groupsFields(FieldSet fields) { if (fields.size() > this.indexes.size()) { return false; } for (int i = 0; i < fields.size(); i++) { if (!fields.contains(this.indexes.get(i))) { return false; } } return true; }
Example 3
Source File: DualInputSemanticProperties.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private boolean isTargetFieldPresent(int targetField, Map<Integer, FieldSet> fieldMapping) { for(FieldSet targetFields : fieldMapping.values()) { if(targetFields.contains(targetField)) { return true; } } return false; }
Example 4
Source File: FieldSetTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static void check(FieldSet set, int... elements) { if (elements == null) { assertEquals(0, set.size()); return; } assertEquals(elements.length, set.size()); // test contains for (int i : elements) { set.contains(i); } Arrays.sort(elements); // test to array { int[] arr = set.toArray(); Arrays.sort(arr); assertTrue(Arrays.equals(arr, elements)); } { int[] fromIter = new int[set.size()]; Iterator<Integer> iter = set.iterator(); for (int i = 0; i < fromIter.length; i++) { fromIter[i] = iter.next(); } assertFalse(iter.hasNext()); Arrays.sort(fromIter); assertTrue(Arrays.equals(fromIter, elements)); } }
Example 5
Source File: SingleInputSemanticProperties.java From flink with Apache License 2.0 | 5 votes |
private boolean isTargetFieldPresent(int targetField) { for(FieldSet targetFields : fieldMapping.values()) { if(targetFields.contains(targetField)) { return true; } } return false; }
Example 6
Source File: Ordering.java From flink with Apache License 2.0 | 5 votes |
public boolean groupsFields(FieldSet fields) { if (fields.size() > this.indexes.size()) { return false; } for (int i = 0; i < fields.size(); i++) { if (!fields.contains(this.indexes.get(i))) { return false; } } return true; }
Example 7
Source File: DualInputSemanticProperties.java From flink with Apache License 2.0 | 5 votes |
private boolean isTargetFieldPresent(int targetField, Map<Integer, FieldSet> fieldMapping) { for(FieldSet targetFields : fieldMapping.values()) { if(targetFields.contains(targetField)) { return true; } } return false; }
Example 8
Source File: FieldSetTest.java From flink with Apache License 2.0 | 5 votes |
private static void check(FieldSet set, int... elements) { if (elements == null) { assertEquals(0, set.size()); return; } assertEquals(elements.length, set.size()); // test contains for (int i : elements) { set.contains(i); } Arrays.sort(elements); // test to array { int[] arr = set.toArray(); Arrays.sort(arr); assertTrue(Arrays.equals(arr, elements)); } { int[] fromIter = new int[set.size()]; Iterator<Integer> iter = set.iterator(); for (int i = 0; i < fromIter.length; i++) { fromIter[i] = iter.next(); } assertFalse(iter.hasNext()); Arrays.sort(fromIter); assertTrue(Arrays.equals(fromIter, elements)); } }
Example 9
Source File: SingleInputSemanticProperties.java From flink with Apache License 2.0 | 5 votes |
private boolean isTargetFieldPresent(int targetField) { for(FieldSet targetFields : fieldMapping.values()) { if(targetFields.contains(targetField)) { return true; } } return false; }
Example 10
Source File: Ordering.java From flink with Apache License 2.0 | 5 votes |
public boolean groupsFields(FieldSet fields) { if (fields.size() > this.indexes.size()) { return false; } for (int i = 0; i < fields.size(); i++) { if (!fields.contains(this.indexes.get(i))) { return false; } } return true; }
Example 11
Source File: DualInputSemanticProperties.java From flink with Apache License 2.0 | 5 votes |
private boolean isTargetFieldPresent(int targetField, Map<Integer, FieldSet> fieldMapping) { for(FieldSet targetFields : fieldMapping.values()) { if(targetFields.contains(targetField)) { return true; } } return false; }
Example 12
Source File: FieldSetTest.java From flink with Apache License 2.0 | 5 votes |
private static void check(FieldSet set, int... elements) { if (elements == null) { assertEquals(0, set.size()); return; } assertEquals(elements.length, set.size()); // test contains for (int i : elements) { set.contains(i); } Arrays.sort(elements); // test to array { int[] arr = set.toArray(); Arrays.sort(arr); assertTrue(Arrays.equals(arr, elements)); } { int[] fromIter = new int[set.size()]; Iterator<Integer> iter = set.iterator(); for (int i = 0; i < fromIter.length; i++) { fromIter[i] = iter.next(); } assertFalse(iter.hasNext()); Arrays.sort(fromIter); assertTrue(Arrays.equals(fromIter, elements)); } }
Example 13
Source File: SemanticPropUtil.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
private static void parseNonForwardedFields(SemanticProperties sp, String[] nonForwardedStr, TypeInformation<?> inType, TypeInformation<?> outType, int input, boolean skipIncompatibleTypes) { if (nonForwardedStr == null) { return; } FieldSet excludedFields = new FieldSet(); for (String s : nonForwardedStr) { // remove white characters s = s.replaceAll("\\s", ""); if (s.equals("")) { continue; } if (!inType.equals(outType)) { if (skipIncompatibleTypes) { continue; } else { throw new InvalidSemanticAnnotationException("Non-forwarded fields annotation only allowed for identical input and output types."); } } Matcher matcher = PATTERN_LIST.matcher(s); if (!matcher.matches()) { throw new InvalidSemanticAnnotationException("Invalid format of non-forwarded fields annotation \"" + s + "\"."); } // process individual fields matcher = PATTERN_FIELD.matcher(s); while (matcher.find()) { String fieldStr = matcher.group(); try { // get and add all flat field positions List<FlatFieldDescriptor> inFFDs = getFlatFields(fieldStr, inType); for (FlatFieldDescriptor ffd : inFFDs) { excludedFields = excludedFields.addField(ffd.getPosition()); } } catch (InvalidFieldReferenceException ifre) { throw new InvalidSemanticAnnotationException("Invalid field reference in non-forwarded fields annotation \"" + fieldStr + "\".", ifre); } } } for (int i = 0; i < inType.getTotalFields(); i++) { if (!excludedFields.contains(i)) { if (sp instanceof SingleInputSemanticProperties) { ((SingleInputSemanticProperties) sp).addForwardedField(i, i); } else if (sp instanceof DualInputSemanticProperties) { ((DualInputSemanticProperties) sp).addForwardedField(input, i, i); } } } }
Example 14
Source File: SemanticPropUtil.java From flink with Apache License 2.0 | 4 votes |
private static void parseNonForwardedFields(SemanticProperties sp, String[] nonForwardedStr, TypeInformation<?> inType, TypeInformation<?> outType, int input, boolean skipIncompatibleTypes) { if (nonForwardedStr == null) { return; } FieldSet excludedFields = new FieldSet(); for (String s : nonForwardedStr) { // remove white characters s = s.replaceAll("\\s", ""); if (s.equals("")) { continue; } if (!inType.equals(outType)) { if (skipIncompatibleTypes) { continue; } else { throw new InvalidSemanticAnnotationException("Non-forwarded fields annotation only allowed for identical input and output types."); } } Matcher matcher = PATTERN_LIST.matcher(s); if (!matcher.matches()) { throw new InvalidSemanticAnnotationException("Invalid format of non-forwarded fields annotation \"" + s + "\"."); } // process individual fields matcher = PATTERN_FIELD.matcher(s); while (matcher.find()) { String fieldStr = matcher.group(); try { // get and add all flat field positions List<FlatFieldDescriptor> inFFDs = getFlatFields(fieldStr, inType); for (FlatFieldDescriptor ffd : inFFDs) { excludedFields = excludedFields.addField(ffd.getPosition()); } } catch (InvalidFieldReferenceException ifre) { throw new InvalidSemanticAnnotationException("Invalid field reference in non-forwarded fields annotation \"" + fieldStr + "\".", ifre); } } } for (int i = 0; i < inType.getTotalFields(); i++) { if (!excludedFields.contains(i)) { if (sp instanceof SingleInputSemanticProperties) { ((SingleInputSemanticProperties) sp).addForwardedField(i, i); } else if (sp instanceof DualInputSemanticProperties) { ((DualInputSemanticProperties) sp).addForwardedField(input, i, i); } } } }
Example 15
Source File: SemanticPropUtil.java From flink with Apache License 2.0 | 4 votes |
private static void parseNonForwardedFields(SemanticProperties sp, String[] nonForwardedStr, TypeInformation<?> inType, TypeInformation<?> outType, int input, boolean skipIncompatibleTypes) { if (nonForwardedStr == null) { return; } FieldSet excludedFields = new FieldSet(); for (String s : nonForwardedStr) { // remove white characters s = s.replaceAll("\\s", ""); if (s.equals("")) { continue; } if (!inType.equals(outType)) { if (skipIncompatibleTypes) { continue; } else { throw new InvalidSemanticAnnotationException("Non-forwarded fields annotation only allowed for identical input and output types."); } } Matcher matcher = PATTERN_LIST.matcher(s); if (!matcher.matches()) { throw new InvalidSemanticAnnotationException("Invalid format of non-forwarded fields annotation \"" + s + "\"."); } // process individual fields matcher = PATTERN_FIELD.matcher(s); while (matcher.find()) { String fieldStr = matcher.group(); try { // get and add all flat field positions List<FlatFieldDescriptor> inFFDs = getFlatFields(fieldStr, inType); for (FlatFieldDescriptor ffd : inFFDs) { excludedFields = excludedFields.addField(ffd.getPosition()); } } catch (InvalidFieldReferenceException ifre) { throw new InvalidSemanticAnnotationException("Invalid field reference in non-forwarded fields annotation \"" + fieldStr + "\".", ifre); } } } for (int i = 0; i < inType.getTotalFields(); i++) { if (!excludedFields.contains(i)) { if (sp instanceof SingleInputSemanticProperties) { ((SingleInputSemanticProperties) sp).addForwardedField(i, i); } else if (sp instanceof DualInputSemanticProperties) { ((DualInputSemanticProperties) sp).addForwardedField(input, i, i); } } } }