@Test public void testAggregate() { LimitRowAggregator aggregator = new LimitRowAggregator(1); RowTraversal traversal = AllShowBitMap.of(5); IMocksControl control = EasyMock.createControl(); Column mockColumn = control.createMock(Column.class); DictionaryEncodedColumn dictionaryEncodedColumn = control.createMock(DictionaryEncodedColumn.class); EasyMock.expect(mockColumn.getDictionaryEncodedColumn()).andReturn(dictionaryEncodedColumn); EasyMock.expect(dictionaryEncodedColumn.getValueByRow(EasyMock.anyInt())).andReturn("aa"); control.replay(); LimitRowAggregatorValue limitRowAggregatorValue; limitRowAggregatorValue = aggregator.aggregate(traversal, mockColumn); List<Object> list = new ArrayList<>(); list.add("aa"); assertEquals(limitRowAggregatorValue.calculateValue(), list); }
@Override public LimitRowAggregatorValue aggregate(RowTraversal traversal, final Column column) { LimitRowAggregatorValue value = new LimitRowAggregatorValue(); final List<Object> list = new ArrayList<>(); traversal.breakableTraversal(new BreakTraversalAction() { @Override public boolean actionPerformed(int row) { list.add(column.getDictionaryEncodedColumn().getValueByRow(row)); return limitRow <= list.size(); } }); value.setValue(list); return value; }
LimitRowAggregator extends SingleColumnAggregator<LimitRowAggregatorValue> implements Serializable { @Override public LimitRowAggregatorValue aggregate(RowTraversal traversal, final Column column) { LimitRowAggregatorValue value = new LimitRowAggregatorValue(); final List<Object> list = new ArrayList<>(); traversal.breakableTraversal(new BreakTraversalAction() { @Override public boolean actionPerformed(int row) { list.add(column.getDictionaryEncodedColumn().getValueByRow(row)); return limitRow <= list.size(); } }); value.setValue(list); return value; } }
LimitRowAggregator extends SingleColumnAggregator<LimitRowAggregatorValue> implements Serializable { @Override public LimitRowAggregatorValue aggregate(RowTraversal traversal, final Column column) { LimitRowAggregatorValue value = new LimitRowAggregatorValue(); final List<Object> list = new ArrayList<>(); traversal.breakableTraversal(new BreakTraversalAction() { @Override public boolean actionPerformed(int row) { list.add(column.getDictionaryEncodedColumn().getValueByRow(row)); return limitRow <= list.size(); } }); value.setValue(list); return value; } LimitRowAggregator(int limitRow); }
LimitRowAggregator extends SingleColumnAggregator<LimitRowAggregatorValue> implements Serializable { @Override public LimitRowAggregatorValue aggregate(RowTraversal traversal, final Column column) { LimitRowAggregatorValue value = new LimitRowAggregatorValue(); final List<Object> list = new ArrayList<>(); traversal.breakableTraversal(new BreakTraversalAction() { @Override public boolean actionPerformed(int row) { list.add(column.getDictionaryEncodedColumn().getValueByRow(row)); return limitRow <= list.size(); } }); value.setValue(list); return value; } LimitRowAggregator(int limitRow); @Override LimitRowAggregatorValue aggregate(RowTraversal traversal, final Column column); @Override LimitRowAggregatorValue createAggregatorValue(AggregatorValue<?> value); @Override AggregatorType getAggregatorType(); @Override void combine(LimitRowAggregatorValue value, LimitRowAggregatorValue other); }
LimitRowAggregator extends SingleColumnAggregator<LimitRowAggregatorValue> implements Serializable { @Override public LimitRowAggregatorValue aggregate(RowTraversal traversal, final Column column) { LimitRowAggregatorValue value = new LimitRowAggregatorValue(); final List<Object> list = new ArrayList<>(); traversal.breakableTraversal(new BreakTraversalAction() { @Override public boolean actionPerformed(int row) { list.add(column.getDictionaryEncodedColumn().getValueByRow(row)); return limitRow <= list.size(); } }); value.setValue(list); return value; } LimitRowAggregator(int limitRow); @Override LimitRowAggregatorValue aggregate(RowTraversal traversal, final Column column); @Override LimitRowAggregatorValue createAggregatorValue(AggregatorValue<?> value); @Override AggregatorType getAggregatorType(); @Override void combine(LimitRowAggregatorValue value, LimitRowAggregatorValue other);  }