Search in sources :

Example 1 with IndexBaseVisitor

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());
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) SharedShardContexts(io.crate.action.job.SharedShardContexts) FetchPhase(io.crate.planner.node.fetch.FetchPhase) IndexBaseVisitor(io.crate.planner.fetch.IndexBaseVisitor) Routing(io.crate.metadata.Routing) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) TableIdent(io.crate.metadata.TableIdent) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 2 with IndexBaseVisitor

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));
}
Also used : IndexBaseVisitor(io.crate.planner.fetch.IndexBaseVisitor) Test(org.junit.Test)

Example 3 with IndexBaseVisitor

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));
}
Also used : IndexBaseVisitor(io.crate.planner.fetch.IndexBaseVisitor) Test(org.junit.Test)

Aggregations

IndexBaseVisitor (io.crate.planner.fetch.IndexBaseVisitor)3 Test (org.junit.Test)3 ImmutableList (com.google.common.collect.ImmutableList)1 SharedShardContexts (io.crate.action.job.SharedShardContexts)1 ColumnIdent (io.crate.metadata.ColumnIdent)1 Routing (io.crate.metadata.Routing)1 TableIdent (io.crate.metadata.TableIdent)1 FetchPhase (io.crate.planner.node.fetch.FetchPhase)1 CrateUnitTest (io.crate.test.integration.CrateUnitTest)1 List (java.util.List)1