use of cyclops.data.tuple.Tuple2 in project cyclops by aol.
the class LazySeqObjectPoolingTest method testZipWithFuturesCoreStream.
@Test
public void testZipWithFuturesCoreStream() {
Stream stream = Stream.of("a", "b");
FutureStream<Tuple2<Integer, String>> seq = of(1, 2).actOnFutures().zip(stream);
// .map(tuple -> Tuple.tuple(tuple.v1.join(),tuple.v2)).collect(CyclopsCollectors.toList());
List<Tuple2<Integer, String>> result = seq.block();
assertThat(result.size(), is(asList(tuple(1, "a"), tuple(2, "b")).size()));
}
use of cyclops.data.tuple.Tuple2 in project cyclops by aol.
the class LazySeqObjectPoolingTest method testZipWithFuturesStream.
@Test
public void testZipWithFuturesStream() {
Stream stream = of("a", "b");
FutureStream<Tuple2<Integer, String>> seq = of(1, 2).actOnFutures().zip(stream);
// .map(tuple -> Tuple.tuple(tuple.v1.join(),tuple.v2)).collect(CyclopsCollectors.toList());
List<Tuple2<Integer, String>> result = seq.block();
assertThat(result.size(), is(asList(tuple(1, "a"), tuple(2, "b")).size()));
}
use of cyclops.data.tuple.Tuple2 in project cyclops by aol.
the class LazySequentialSeqAgronaTest method testZipWithFutures.
@Test
public void testZipWithFutures() {
Stream stream = of("a", "b");
List<Tuple2<Integer, String>> result = of(1, 2).actOnFutures().zip(stream).block();
assertThat(result, is(asList(tuple(1, "a"), tuple(2, "b"))));
}
use of cyclops.data.tuple.Tuple2 in project cyclops by aol.
the class SpoutsZipTest method pairWise.
@Test
public void pairWise() {
AtomicBoolean data = new AtomicBoolean(false);
AtomicReference<Vector<Tuple2<Integer, String>>> values = new AtomicReference<>(Vector.empty());
AtomicBoolean complete = new AtomicBoolean(false);
AtomicReference<Throwable> error = new AtomicReference<Throwable>(null);
Spouts.of(1).zip(Spouts.of("test")).zip(Spouts.of("test2")).map(t -> Tuple.tuple(t._1()._1(), t._1()._2() + t._2())).forEach(n -> {
data.set(true);
values.updateAndGet(v -> v.plus(n));
}, e -> {
error.set(e);
}, () -> {
complete.set(true);
});
assertTrue(data.get());
assertTrue(complete.get());
assertNull(error.get());
assertThat(values.get(), equalTo(Vector.of(Tuple.tuple(1, "testtest2"))));
}
use of cyclops.data.tuple.Tuple2 in project cyclops by aol.
the class BaseSequentialTest method testUnzip.
@Test
public void testUnzip() {
Supplier<ReactiveSeq<Tuple2<Integer, String>>> s = () -> of(new Tuple2(1, "a"), new Tuple2(2, "b"), new Tuple2(3, "c"));
Tuple2<ReactiveSeq<Integer>, ReactiveSeq<String>> u1 = ReactiveSeq.unzip(s.get());
assertThat(u1._1().toList(), equalTo(asList(1, 2, 3)));
assertThat(u1._2().toList(), equalTo(asList("a", "b", "c")));
}
Aggregations