Search in sources :

Example 1 with FetchPhase

use of io.crate.planner.node.fetch.FetchPhase 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 FetchPhase

use of io.crate.planner.node.fetch.FetchPhase in project crate by crate.

the class FetchContextTest method testGetIndexServiceForInvalidReaderId.

@Test
public void testGetIndexServiceForInvalidReaderId() throws Exception {
    final FetchContext context = new FetchContext(new FetchPhase(1, null, new TreeMap<String, Integer>(), HashMultimap.<TableIdent, String>create(), ImmutableList.<Reference>of()), "dummy", new SharedShardContexts(mock(IndicesService.class)), Collections.<Routing>emptyList());
    expectedException.expect(IllegalArgumentException.class);
    context.indexService(10);
}
Also used : SharedShardContexts(io.crate.action.job.SharedShardContexts) TestingHelpers.createReference(io.crate.testing.TestingHelpers.createReference) Reference(io.crate.metadata.Reference) FetchPhase(io.crate.planner.node.fetch.FetchPhase) TableIdent(io.crate.metadata.TableIdent) TreeMap(java.util.TreeMap) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

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