use of org.apache.flink.api.java.tuple.Tuple in project flink by apache.
the class StormTupleTest method testBooleanTuple.
@Test
public void testBooleanTuple() {
final Boolean data = this.r.nextBoolean();
final int index = this.r.nextInt(5);
final Tuple flinkTuple = new Tuple5<Object, Object, Object, Object, Object>();
flinkTuple.setField(data, index);
final StormTuple<Tuple> tuple = new StormTuple<Tuple>(flinkTuple, null, -1, null, null, null);
Assert.assertEquals(flinkTuple.getField(index), tuple.getBoolean(index));
}
use of org.apache.flink.api.java.tuple.Tuple in project flink by apache.
the class StormTupleTest method testSelect.
@Test
public void testSelect() throws Exception {
Tuple tuple = Tuple.getTupleClass(arity).newInstance();
Values values = new Values();
ArrayList<String> attributeNames = new ArrayList<String>(arity);
ArrayList<String> filterNames = new ArrayList<String>(arity);
for (int i = 0; i < arity; ++i) {
tuple.setField(i, i);
attributeNames.add("a" + i);
if (r.nextBoolean()) {
filterNames.add("a" + i);
values.add(i);
}
}
Fields schema = new Fields(attributeNames);
Fields selector = new Fields(filterNames);
Assert.assertEquals(values, new StormTuple<>(tuple, schema, -1, null, null, null).select(selector));
}
use of org.apache.flink.api.java.tuple.Tuple in project flink by apache.
the class StormTupleTest method testIntegerTuple.
@Test
public void testIntegerTuple() {
final Integer data = this.r.nextInt();
final int index = this.r.nextInt(5);
final Tuple flinkTuple = new Tuple5<Object, Object, Object, Object, Object>();
flinkTuple.setField(data, index);
final StormTuple<Tuple> tuple = new StormTuple<Tuple>(flinkTuple, null, -1, null, null, null);
Assert.assertEquals(flinkTuple.getField(index), tuple.getInteger(index));
}
use of org.apache.flink.api.java.tuple.Tuple in project flink by apache.
the class StormTupleTest method tupleTestWithTaskId.
@Test
public void tupleTestWithTaskId() throws InstantiationException, IllegalAccessException {
for (int numberOfAttributes = 1; numberOfAttributes < 26; ++numberOfAttributes) {
final Object[] data = new Object[numberOfAttributes];
final Tuple flinkTuple = Tuple.getTupleClass(numberOfAttributes).newInstance();
for (int i = 0; i < numberOfAttributes - 1; ++i) {
data[i] = this.r.nextInt();
flinkTuple.setField(data[i], i);
}
final StormTuple<Tuple> tuple = new StormTuple<Tuple>(flinkTuple, null, 0, null, null, null);
final List<Object> values = tuple.getValues();
Assert.assertEquals(numberOfAttributes - 1, values.size());
for (int i = 0; i < numberOfAttributes - 1; ++i) {
Assert.assertEquals(flinkTuple.getField(i), values.get(i));
}
Assert.assertEquals(numberOfAttributes - 1, tuple.size());
}
}
use of org.apache.flink.api.java.tuple.Tuple in project flink by apache.
the class ReplicatingDataSourceITCase method testReplicatedSourceToJoin.
@Test
public void testReplicatedSourceToJoin() throws Exception {
/*
* Test replicated source going into join
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple1<Long>> source1 = env.createInput(new ReplicatingInputFormat<Long, GenericInputSplit>(new ParallelIteratorInputFormat<Long>(new NumberSequenceIterator(0l, 1000l))), BasicTypeInfo.LONG_TYPE_INFO).map(new ToTuple());
DataSet<Tuple1<Long>> source2 = env.generateSequence(0l, 1000l).map(new ToTuple());
DataSet<Tuple> pairs = source1.join(source2).where(0).equalTo(0).projectFirst(0).sum(0);
List<Tuple> result = pairs.collect();
String expectedResult = "(500500)";
compareResultAsText(result, expectedResult);
}
Aggregations