use of cyclops.data.tuple.Tuple2 in project cyclops by aol.
the class AutoclosingTest method autoClosingZipLots.
@Test
public void autoClosingZipLots() throws InterruptedException {
for (int i = 0; i < 1500; i++) {
close = new AtomicInteger();
added = new AtomicInteger();
// subscription fills from outside in (lazyRight to lazyLeft), need to store open / closed for each queue
List<Tuple2<List<List<String>>, Integer>> results = new LazyReact().generate(() -> nextValues()).withQueueFactory(() -> eventQueue()).zip(new LazyReact().of(1, 2, 3)).collect(Collectors.toList());
System.out.println("finished");
int localAdded = added.get();
assertThat(close.get(), greaterThan(0));
assertThat(results.size(), is(3));
assertThat(localAdded, is(added.get()));
}
}
use of cyclops.data.tuple.Tuple2 in project cyclops by aol.
the class AutoclosingTest method autoClosingZip.
@Test
public void autoClosingZip() throws InterruptedException {
System.out.println("Started!");
close = new AtomicInteger();
added = new AtomicInteger();
// subscription fills from outside in (lazyRight to lazyLeft), need to store open / closed for each queue
List<Tuple2<List<List<String>>, Integer>> results = new LazyReact().generateAsync(() -> nextValues()).withQueueFactory(() -> eventQueue()).zip(new LazyReact().of(1, 2, 3)).collect(Collectors.toList());
System.out.println("finished");
int localAdded = added.get();
assertThat(close.get(), greaterThan(0));
assertThat(results.size(), is(3));
assertThat(localAdded, is(added.get()));
}
use of cyclops.data.tuple.Tuple2 in project cyclops by aol.
the class LazySeqAgronaTest 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 AsyncRSZippingTest method testUnzipWithLimits.
@Test
public void testUnzipWithLimits() {
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());
assertTrue(u1._1().limit(2).toList().containsAll(Arrays.asList(1, 2)));
assertTrue(u1._2().toList().containsAll(asList("a", "b", "c")));
}
use of cyclops.data.tuple.Tuple2 in project cyclops by aol.
the class AsyncRSZippingTest 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());
assertTrue(u1._1().toList().containsAll(Arrays.asList(1, 2, 3)));
assertTrue(u1._2().toList().containsAll(asList("a", "b", "c")));
}
Aggregations