Java Code Examples for org.apache.flink.api.java.tuple.Tuple2#equals()

The following examples show how to use org.apache.flink.api.java.tuple.Tuple2#equals() . 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: TestData.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public T next(T reuse) {
	Tuple2 r = null;
	while (r == null) {
		try {
			r = queue.take();
		} catch (InterruptedException iex) {
			throw new RuntimeException("Reader was interrupted.");
		}
	}

	if (r.equals(SENTINEL)) {
		// put the sentinel back, to ensure that repeated calls do not block
		try {
			queue.put(r);
		} catch (InterruptedException e) {
			throw new RuntimeException("Reader was interrupted.");
		}
		return null;
	} else {
		reuse.setField(r.getField(0), 0);
		reuse.setField(r.getField(1), 1);
		return reuse;
	}
}
 
Example 2
Source File: TestData.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public T next() {
	Tuple2 r = null;
	while (r == null) {
		try {
			r = queue.take();
		} catch (InterruptedException iex) {
			throw new RuntimeException("Reader was interrupted.");
		}
	}

	if (r.equals(SENTINEL)) {
		// put the sentinel back, to ensure that repeated calls do not block
		try {
			queue.put(r);
		} catch (InterruptedException e) {
			throw new RuntimeException("Reader was interrupted.");
		}
		return null;
	} else {
		Tuple2 result = new Tuple2(r.f0, r.f1);
		return (T) result;
	}
}
 
Example 3
Source File: TestData.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public T next(T reuse) {
	Tuple2 r = null;
	while (r == null) {
		try {
			r = queue.take();
		} catch (InterruptedException iex) {
			throw new RuntimeException("Reader was interrupted.");
		}
	}

	if (r.equals(SENTINEL)) {
		// put the sentinel back, to ensure that repeated calls do not block
		try {
			queue.put(r);
		} catch (InterruptedException e) {
			throw new RuntimeException("Reader was interrupted.");
		}
		return null;
	} else {
		reuse.setField(r.getField(0), 0);
		reuse.setField(r.getField(1), 1);
		return reuse;
	}
}
 
Example 4
Source File: TestData.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public T next() {
	Tuple2 r = null;
	while (r == null) {
		try {
			r = queue.take();
		} catch (InterruptedException iex) {
			throw new RuntimeException("Reader was interrupted.");
		}
	}

	if (r.equals(SENTINEL)) {
		// put the sentinel back, to ensure that repeated calls do not block
		try {
			queue.put(r);
		} catch (InterruptedException e) {
			throw new RuntimeException("Reader was interrupted.");
		}
		return null;
	} else {
		Tuple2 result = new Tuple2(r.f0, r.f1);
		return (T) result;
	}
}
 
Example 5
Source File: TestData.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public T next(T reuse) {
	Tuple2 r = null;
	while (r == null) {
		try {
			r = queue.take();
		} catch (InterruptedException iex) {
			throw new RuntimeException("Reader was interrupted.");
		}
	}

	if (r.equals(SENTINEL)) {
		// put the sentinel back, to ensure that repeated calls do not block
		try {
			queue.put(r);
		} catch (InterruptedException e) {
			throw new RuntimeException("Reader was interrupted.");
		}
		return null;
	} else {
		reuse.setField(r.getField(0), 0);
		reuse.setField(r.getField(1), 1);
		return reuse;
	}
}
 
Example 6
Source File: TestData.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public T next() {
	Tuple2 r = null;
	while (r == null) {
		try {
			r = queue.take();
		} catch (InterruptedException iex) {
			throw new RuntimeException("Reader was interrupted.");
		}
	}

	if (r.equals(SENTINEL)) {
		// put the sentinel back, to ensure that repeated calls do not block
		try {
			queue.put(r);
		} catch (InterruptedException e) {
			throw new RuntimeException("Reader was interrupted.");
		}
		return null;
	} else {
		Tuple2 result = new Tuple2(r.f0, r.f1);
		return (T) result;
	}
}
 
Example 7
Source File: UdfAnalyzerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public Tuple2<Integer, Integer> map(Integer value) throws Exception {
	Tuple2<Integer, Integer> tuple = new Tuple2<Integer, Integer>();
	// non-input content
	if (tuple.equals(new Tuple2<Integer, Integer>())) {
		tuple.f0 = 123456;
	}
	if (tuple.equals(new Tuple2<Integer, Integer>())) {
		tuple.f0 = value;
	}
	// forwarding
	tuple.f1 = value;
	return tuple;
}