use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class AggregatorTest method testAggregationFromIterToFinal.
@Test
public void testAggregationFromIterToFinal() {
Aggregation aggregation = Aggregation.finalAggregation(countImpl.info(), Collections.<Symbol>singletonList(new InputColumn(0)), Aggregation.Step.ITER);
Input dummyInput = new Input() {
@Override
public Object value() {
return 300L;
}
};
Aggregator collector = new Aggregator(RAM_ACCOUNTING_CONTEXT, aggregation, countImpl, dummyInput);
Object state = collector.prepareState();
for (int i = 0; i < 5; i++) {
state = collector.processRow(state);
}
long result = (Long) collector.finishCollect(state);
assertThat(result, is(5L));
}
use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class RowShardResolverTest method testNoPrimaryKeyButRouting.
@Test
public void testNoPrimaryKeyButRouting() {
RowShardResolver rowShardResolver = new RowShardResolver(functions, ImmutableList.<ColumnIdent>of(), ImmutableList.<Symbol>of(), ID_IDENT, new InputColumn(1));
rowShardResolver.setNextRow(row(1, "hoschi"));
// auto-generated id, special routing
assertNotNull(rowShardResolver.id());
assertThat(rowShardResolver.routing(), is("hoschi"));
}
use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class RowShardResolverTest method testPrimaryKeyAndRouting.
@Test
public void testPrimaryKeyAndRouting() {
List<Symbol> primaryKeySymbols = ImmutableList.<Symbol>of(new InputColumn(0), new InputColumn(1));
RowShardResolver rowShardResolver = new RowShardResolver(functions, ImmutableList.of(ci("id"), ci("foo")), primaryKeySymbols, ci("foo"), new InputColumn(1));
rowShardResolver.setNextRow(row(1, "hoschi"));
// compound encoded id, special routing
assertThat(rowShardResolver.id(), is("AgZob3NjaGkBMQ=="));
assertThat(rowShardResolver.routing(), is("hoschi"));
}
use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class RowShardResolverTest method testPrimaryKeyNullException.
@Test
public void testPrimaryKeyNullException() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("A primary key value must not be NULL");
List<Symbol> primaryKeySymbols = ImmutableList.<Symbol>of(new InputColumn(0));
RowShardResolver rowShardResolver = new RowShardResolver(functions, ImmutableList.of(ci("id")), primaryKeySymbols, null, null);
rowShardResolver.setNextRow(row(new Object[] { null }));
}
Aggregations