use of io.crate.planner.fetch.IndexBaseVisitor in project crate by crate.
the class FetchContextTest method testSearcherIsAcquiredForShard.
@Test
public void testSearcherIsAcquiredForShard() throws Exception {
Routing routing = new Routing(TreeMapBuilder.<String, Map<String, List<Integer>>>newMapBuilder().put("dummy", TreeMapBuilder.<String, List<Integer>>newMapBuilder().put("i1", ImmutableList.of(1, 2)).map()).map());
IndexBaseVisitor ibv = new IndexBaseVisitor();
routing.walkLocations(ibv);
HashMultimap<TableIdent, String> tableIndices = HashMultimap.create();
tableIndices.put(new TableIdent(null, "i1"), "i1");
final FetchContext context = new FetchContext(new FetchPhase(1, null, ibv.build(), tableIndices, ImmutableList.of(createReference("i1", new ColumnIdent("x"), DataTypes.STRING))), "dummy", new SharedShardContexts(mock(IndicesService.class, RETURNS_MOCKS)), ImmutableList.of(routing));
context.prepare();
assertThat(context.searcher(1), Matchers.notNullValue());
assertThat(context.searcher(2), Matchers.notNullValue());
}
use of io.crate.planner.fetch.IndexBaseVisitor in project crate by crate.
the class IndexBaseVisitorTest method testMaxShard.
@Test
public void testMaxShard() throws Exception {
IndexBaseVisitor visitor = new IndexBaseVisitor();
visitor.visitIndex("n1", "i1", ImmutableList.of(1, 4));
visitor.visitIndex("n2", "i2", ImmutableList.of(1, 5));
TreeMap<String, Integer> bases = visitor.build();
assertThat(bases.size(), is(2));
assertThat(bases.get("i1"), is(0));
assertThat(bases.get("i2"), is(5));
}
use of io.crate.planner.fetch.IndexBaseVisitor in project crate by crate.
the class IndexBaseVisitorTest method testDoubleIndex.
@Test
public void testDoubleIndex() throws Exception {
IndexBaseVisitor visitor = new IndexBaseVisitor();
visitor.visitIndex("n1", "i1", ImmutableList.of(1, 4));
visitor.visitIndex("n1", "i2", ImmutableList.of(1, 2));
visitor.visitIndex("n2", "i1", ImmutableList.of(1, 5));
visitor.visitIndex("n3", "i1", ImmutableList.of(1, 3));
visitor.visitIndex("n3", "i3", ImmutableList.of(1, 3));
TreeMap<String, Integer> bases = visitor.build();
assertThat(bases.size(), is(3));
assertThat(bases.get("i1"), is(0));
assertThat(bases.get("i2"), is(6));
assertThat(bases.get("i3"), is(9));
}
Aggregations