Java Code Examples for org.apache.flink.api.java.tuple.Tuple3#setField()

The following examples show how to use org.apache.flink.api.java.tuple.Tuple3#setField() . 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: MapITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public Tuple3<Integer, Long, String> map(Tuple3<Integer, Long, String> value)
		throws Exception {
	Integer incr = Integer.valueOf(value.f0.intValue() + 1);
	value.setField(incr, 0);
	return value;
}
 
Example 2
Source File: FlatMapITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void flatMap(Tuple3<Integer, Long, String> value,
		Collector<Tuple3<Integer, Long, String>> out) throws Exception {
	final int numTuples = value.f0 % 4;
	for (int i = 0; i < numTuples; i++) {
		value.setField(i, 0);
		out.collect(value);
	}
}
 
Example 3
Source File: UdfAnalyzerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public Tuple3<String, String, String> map(Tuple3<String, String, String> value) throws Exception {
	String tmp = value.f0;
	for (int i = 0; i < 2; i++) {
		value.setField("Test", i);
	}
	Tuple3<String, String, String> tuple;
	if (value.f0.equals("x")) {
		tuple = new Tuple3<String, String, String>(tmp, value.f0, null);
	} else {
		tuple = new Tuple3<String, String, String>(tmp, value.f0, "");
	}
	return tuple;
}
 
Example 4
Source File: UdfAnalyzerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public Tuple3<String, String, String> map(Tuple3<String, String, String> value) throws Exception {
	int i = 0;
	do {
		value.setField("", i);
		i++;
	} while (i >= 2);
	return value;
}
 
Example 5
Source File: MapITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Tuple3<Integer, Long, String> map(Tuple3<Integer, Long, String> value)
		throws Exception {
	Integer incr = Integer.valueOf(value.f0.intValue() + 1);
	value.setField(incr, 0);
	return value;
}
 
Example 6
Source File: FlatMapITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void flatMap(Tuple3<Integer, Long, String> value,
		Collector<Tuple3<Integer, Long, String>> out) throws Exception {
	final int numTuples = value.f0 % 4;
	for (int i = 0; i < numTuples; i++) {
		value.setField(i, 0);
		out.collect(value);
	}
}
 
Example 7
Source File: WindowTriangles.java    From gelly-streaming with Apache License 2.0 5 votes vote down vote up
@Override
public void applyOnEdges(Long vertexID,
		Iterable<Tuple2<Long, NullValue>> neighbors,
		Collector<Tuple3<Long, Long, Boolean>> out) throws Exception {

	Tuple3<Long, Long, Boolean> outT = new Tuple3<>();
	outT.setField(vertexID, 0);
	outT.setField(false, 2); //isCandidate=false

	Set<Long> neighborIdsSet = new HashSet<Long>();
	for (Tuple2<Long, NullValue> t: neighbors) {
		outT.setField(t.f0, 1);
		out.collect(outT);
		neighborIdsSet.add(t.f0);
	}
	Object[] neighborIds = neighborIdsSet.toArray();
	neighborIdsSet.clear();
	outT.setField(true, 2); //isCandidate=true
	for (int i=0; i<neighborIds.length-1; i++) {
		for (int j=i; j<neighborIds.length; j++) {
			// only emit the candidates
			// with IDs larger than the vertex ID
			if (((long)neighborIds[i] > vertexID) && ((long)neighborIds[j] > vertexID)) {
				outT.setField((long)neighborIds[i], 0);
				outT.setField((long)neighborIds[j], 1);
				out.collect(outT);
			}
		}
	}
}
 
Example 8
Source File: ExactTriangleCount.java    From gelly-streaming with Apache License 2.0 5 votes vote down vote up
@Override
public Tuple3<Integer, Integer, TreeSet<Integer>> map(Tuple3<Integer, Integer, TreeSet<Integer>> t) {
	int source = Math.min(t.f0, t.f1);
	int trg = Math.max(t.f0, t.f1);
	t.setField(source, 0);
	t.setField(trg, 1);
	return t;
}
 
Example 9
Source File: MapITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Tuple3<Integer, Long, String> map(Tuple3<Integer, Long, String> value)
		throws Exception {
	Integer incr = Integer.valueOf(value.f0.intValue() + 1);
	value.setField(incr, 0);
	return value;
}
 
Example 10
Source File: FlatMapITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void flatMap(Tuple3<Integer, Long, String> value,
		Collector<Tuple3<Integer, Long, String>> out) throws Exception {
	final int numTuples = value.f0 % 4;
	for (int i = 0; i < numTuples; i++) {
		value.setField(i, 0);
		out.collect(value);
	}
}