@Test
public void testPI() throws Exception {

	DataSet<Row> result = new IterativeComQueue()
		.add(new ComputeFunction() {
			@Override
			public void calc(ComContext context) {
				if (1 == context.getStepNo()) {
					context.putObj("cnt", new int[]{0});
				}
				int[] cnt = context.getObj("cnt");
				double x = Math.random();
				double y = Math.random();
				cnt[0] += ((x * x + y * y < 1) ? 1 : 0);
			}
		})
		.closeWith(new CompleteResultFunction() {
			@Override
			public List<Row> calc(ComContext context) {
				int[] cnt = context.getObj("cnt");
				return Collections.singletonList(Row.of(4.0 * cnt[0] / 1000));
			}
		})
		.setMaxIter(1000)
		.exec();
	Assert.assertEquals(3.0, (double) result.collect().get(0).getField(0), 0.5);
}