Search in sources :

Example 1 with IndexEnv

use of io.crate.testing.IndexEnv in project crate by crate.

the class DocLevelExpressionsTest method prepare.

@Before
public void prepare() throws Exception {
    SQLExecutor e = SQLExecutor.builder(clusterService).addTable(createTableStatement).build();
    indexEnv = new IndexEnv(THREAD_POOL, (DocTableInfo) StreamSupport.stream(e.schemas().spliterator(), false).filter(x -> x instanceof DocSchemaInfo).map(x -> (DocSchemaInfo) x).findFirst().orElseThrow(() -> new IllegalStateException("No doc schema found")).getTables().iterator().next(), clusterService.state(), Version.CURRENT, createTempDir());
    IndexWriter writer = indexEnv.writer();
    insertValues(writer);
    DirectoryReader directoryReader = DirectoryReader.open(writer, true, true);
    readerContext = directoryReader.leaves().get(0);
    ctx = new CollectorContext();
}
Also used : DocTableInfo(io.crate.metadata.doc.DocTableInfo) CollectorContext(io.crate.expression.reference.doc.lucene.CollectorContext) IndexEnv(io.crate.testing.IndexEnv) DirectoryReader(org.apache.lucene.index.DirectoryReader) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) IndexWriter(org.apache.lucene.index.IndexWriter) Version(org.elasticsearch.Version) DocSchemaInfo(io.crate.metadata.doc.DocSchemaInfo) After(org.junit.After) StreamSupport(java.util.stream.StreamSupport) LeafReaderContext(org.apache.lucene.index.LeafReaderContext) SQLExecutor(io.crate.testing.SQLExecutor) Before(org.junit.Before) DocTableInfo(io.crate.metadata.doc.DocTableInfo) DocSchemaInfo(io.crate.metadata.doc.DocSchemaInfo) SQLExecutor(io.crate.testing.SQLExecutor) IndexEnv(io.crate.testing.IndexEnv) IndexWriter(org.apache.lucene.index.IndexWriter) DirectoryReader(org.apache.lucene.index.DirectoryReader) CollectorContext(io.crate.expression.reference.doc.lucene.CollectorContext) Before(org.junit.Before)

Aggregations

CollectorContext (io.crate.expression.reference.doc.lucene.CollectorContext)1 DocSchemaInfo (io.crate.metadata.doc.DocSchemaInfo)1 DocTableInfo (io.crate.metadata.doc.DocTableInfo)1 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)1 IndexEnv (io.crate.testing.IndexEnv)1 SQLExecutor (io.crate.testing.SQLExecutor)1 StreamSupport (java.util.stream.StreamSupport)1 DirectoryReader (org.apache.lucene.index.DirectoryReader)1 IndexWriter (org.apache.lucene.index.IndexWriter)1 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1 Version (org.elasticsearch.Version)1 After (org.junit.After)1 Before (org.junit.Before)1