Package io.crate.analyze

Examples of io.crate.analyze.CreateTableStatementAnalyzer


    }

    private DocIndexMetaData getDocIndexMetaDataFromStatement(String stmt) throws IOException {
        Statement statement = SqlParser.createStatement(stmt);
        ClusterService clusterService = mock(ClusterService.class);
        CreateTableStatementAnalyzer analyzer = new CreateTableStatementAnalyzer(
            new ReferenceInfos(
                ImmutableMap.<String, SchemaInfo>of("doc",
                    new DocSchemaInfo(clusterService,
                        mock(TransportPutIndexTemplateAction.class)))),
            new FulltextAnalyzerResolver(clusterService, mock(IndicesAnalysisService.class))
        );

        CreateTableAnalysis analysis = (CreateTableAnalysis) analyzer.newAnalysis(
                new Analyzer.ParameterContext(new Object[0], new Object[0][]));
        analysis.analyzedTableElements(new AnalyzedTableElements());

        ImmutableSettings.Builder settingsBuilder = ImmutableSettings.builder()
                .put("index.number_of_shards", 1)
                .put("index.number_of_replicas", 0)
                .put(analysis.tableParameter().settings());

        analyzer.process(statement, analysis);
        IndexMetaData indexMetaData = IndexMetaData.builder(analysis.tableIdent().name())
                .settings(settingsBuilder)
                .putMapping(new MappingMetaData(Constants.DEFAULT_MAPPING_TYPE, analysis.mapping()))
                .build();
View Full Code Here

TOP

Related Classes of io.crate.analyze.CreateTableStatementAnalyzer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.