@Test public void testAvg() throws InterruptedException, ExecutionException { assertEquals((COUNT - 1) / 2.0, AsyncAggregationClient .avg(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().doubleValue(), DELTA); }
@Test public void testRowCount() throws InterruptedException, ExecutionException { assertEquals(COUNT, AsyncAggregationClient .rowCount(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get() .longValue()); }
@Test public void testSum() throws InterruptedException, ExecutionException { assertEquals(COUNT * (COUNT - 1) / 2, AsyncAggregationClient .sum(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue()); }
@Test public void testMax() throws InterruptedException, ExecutionException { assertEquals(COUNT - 1, AsyncAggregationClient .max(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue()); }
@Test public void testMin() throws InterruptedException, ExecutionException { assertEquals(0, AsyncAggregationClient .min(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue()); }
@Test public void testStd() throws InterruptedException, ExecutionException { double avgSq = LongStream.range(0, COUNT).map(l -> l * l).reduce((l1, l2) -> l1 + l2).getAsLong() / (double) COUNT; double avg = (COUNT - 1) / 2.0; double std = Math.sqrt(avgSq - avg * avg); assertEquals(std, AsyncAggregationClient .std(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().doubleValue(), DELTA); }
@Test public void testMedian() throws InterruptedException, ExecutionException { long halfSum = COUNT * (COUNT - 1) / 4; long median = 0L; long sum = 0L; for (int i = 0; i < COUNT; i++) { sum += i; if (sum > halfSum) { median = i - 1; break; } } assertEquals(median, AsyncAggregationClient .median(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get() .longValue()); }
@Test public void testMedianWithWeight() throws InterruptedException, ExecutionException { long halfSum = LongStream.range(0, COUNT).map(l -> l * l).reduce((l1, l2) -> l1 + l2).getAsLong() / 2; long median = 0L; long sum = 0L; for (int i = 0; i < COUNT; i++) { sum += i * i; if (sum > halfSum) { median = i - 1; break; } } assertEquals(median, AsyncAggregationClient .median(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ).addColumn(CF, CQ2)) .get().longValue()); } }
@Test public void testMin() throws InterruptedException, ExecutionException { assertEquals(0, AsyncAggregationClient .min(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue()); }
@Test public void testRowCount() throws InterruptedException, ExecutionException { assertEquals(COUNT, AsyncAggregationClient .rowCount(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get() .longValue()); }
@Test public void testMax() throws InterruptedException, ExecutionException { assertEquals(COUNT - 1, AsyncAggregationClient .max(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue()); }
@Test public void testSum() throws InterruptedException, ExecutionException { assertEquals(COUNT * (COUNT - 1) / 2, AsyncAggregationClient .sum(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue()); }
@Test public void testSum() throws InterruptedException, ExecutionException { assertEquals(COUNT * (COUNT - 1) / 2, AsyncAggregationClient .sum(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue()); }
@Test public void testMin() throws InterruptedException, ExecutionException { assertEquals(0, AsyncAggregationClient .min(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue()); }
@Test public void testMax() throws InterruptedException, ExecutionException { assertEquals(COUNT - 1, AsyncAggregationClient .max(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue()); }
@Test public void testAvg() throws InterruptedException, ExecutionException { assertEquals((COUNT - 1) / 2.0, AsyncAggregationClient .avg(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().doubleValue(), DELTA); }
@Test public void testRowCount() throws InterruptedException, ExecutionException { assertEquals(COUNT, AsyncAggregationClient .rowCount(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get() .longValue()); }
@Test public void testAvg() throws InterruptedException, ExecutionException { assertEquals((COUNT - 1) / 2.0, AsyncAggregationClient .avg(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().doubleValue(), DELTA); }
@Test public void testStd() throws InterruptedException, ExecutionException { double avgSq = LongStream.range(0, COUNT).map(l -> l * l).reduce((l1, l2) -> l1 + l2).getAsLong() / (double) COUNT; double avg = (COUNT - 1) / 2.0; double std = Math.sqrt(avgSq - avg * avg); assertEquals(std, AsyncAggregationClient .std(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().doubleValue(), DELTA); }
@Test public void testStd() throws InterruptedException, ExecutionException { double avgSq = LongStream.range(0, COUNT).map(l -> l * l).reduce((l1, l2) -> l1 + l2).getAsLong() / (double) COUNT; double avg = (COUNT - 1) / 2.0; double std = Math.sqrt(avgSq - avg * avg); assertEquals(std, AsyncAggregationClient .std(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().doubleValue(), DELTA); }