use of io.crate.metadata.doc.DocSchemaInfo in project crate by crate.
the class SelectStatementAnalyzerTest method init.
@Before
public void init() throws Exception {
DocTableInfo fooUserTableInfo = TestingTableInfo.builder(new TableIdent("foo", "users"), SHARD_ROUTING).add("id", DataTypes.LONG, null).add("name", DataTypes.STRING, null).addPrimaryKey("id").build();
DocTableInfoFactory fooTableFactory = new TestingDocTableInfoFactory(ImmutableMap.of(fooUserTableInfo.ident(), fooUserTableInfo));
ClusterService clusterService = new NoopClusterService();
sqlExecutor = SQLExecutor.builder(clusterService).enableDefaultTables().addSchema(new DocSchemaInfo("foo", clusterService, fooTableFactory)).build();
}
use of io.crate.metadata.doc.DocSchemaInfo in project crate by crate.
the class TransportAnalyzeAction method fetchSamplesThenGenerateAndPublishStats.
@SuppressWarnings("unchecked")
public CompletableFuture<AcknowledgedResponse> fetchSamplesThenGenerateAndPublishStats() {
ArrayList<CompletableFuture<Map.Entry<RelationName, Stats>>> futures = new ArrayList<>();
for (SchemaInfo schema : schemas) {
if (!(schema instanceof DocSchemaInfo)) {
continue;
}
for (TableInfo table : schema.getTables()) {
List<Reference> primitiveColumns = StreamSupport.stream(table.spliterator(), false).filter(x -> !x.column().isSystemColumn()).filter(x -> DataTypes.isPrimitive(x.valueType())).map(x -> table.getReadReference(x.column())).collect(Collectors.toList());
futures.add(fetchSamples(table.ident(), primitiveColumns).thenApply(samples -> Map.entry(table.ident(), createTableStats(samples, primitiveColumns))));
}
}
return CompletableFutures.allAsList(futures).thenCompose(entries -> publishTableStats(Map.ofEntries(entries.toArray(new Map.Entry[0]))));
}
use of io.crate.metadata.doc.DocSchemaInfo 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();
}
Aggregations