Java Code Examples for org.apache.flink.api.common.operators.util.FieldSet#size()

The following examples show how to use org.apache.flink.api.common.operators.util.FieldSet#size() . 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: Ordering.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
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 2
Source File: FieldSetTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
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 3
Source File: Ordering.java    From flink with Apache License 2.0 5 votes vote down vote up
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 4
Source File: FieldSetTest.java    From flink with Apache License 2.0 5 votes vote down vote up
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: Ordering.java    From flink with Apache License 2.0 5 votes vote down vote up
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 6
Source File: FieldSetTest.java    From flink with Apache License 2.0 5 votes vote down vote up
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));
	}
}