Search in sources :

Example 1 with CreateBlobTable

use of io.crate.sql.tree.CreateBlobTable in project crate by crate.

the class CreateBlobTablePlan method buildSettings.

@VisibleForTesting
public static Settings buildSettings(CreateBlobTable<Symbol> createBlobTable, CoordinatorTxnCtx txnCtx, NodeContext nodeCtx, Row params, SubQueryResults subQueryResults, NumberOfShards numberOfShards) {
    Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate(txnCtx, nodeCtx, x, params, subQueryResults);
    CreateBlobTable<Object> blobTable = createBlobTable.map(eval);
    GenericProperties<Object> properties = blobTable.genericProperties();
    // apply default in case it is not specified in the properties,
    // if it is it will get overwritten afterwards.
    TableParameter tableParameter = new TableParameter();
    TablePropertiesAnalyzer.analyzeWithBoundValues(tableParameter, TableParameters.CREATE_BLOB_TABLE_PARAMETERS, properties, true);
    Settings.Builder builder = Settings.builder();
    builder.put(tableParameter.settings());
    builder.put(SETTING_INDEX_BLOBS_ENABLED.getKey(), true);
    int numShards;
    ClusteredBy<Object> clusteredBy = blobTable.clusteredBy();
    if (clusteredBy != null) {
        numShards = numberOfShards.fromClusteredByClause(clusteredBy);
    } else {
        numShards = numberOfShards.defaultNumberOfShards();
    }
    builder.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards);
    return builder.build();
}
Also used : SETTING_INDEX_BLOBS_ENABLED(io.crate.blob.v2.BlobIndicesService.SETTING_INDEX_BLOBS_ENABLED) RelationName(io.crate.metadata.RelationName) IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) GenericProperties(io.crate.sql.tree.GenericProperties) Function(java.util.function.Function) DependencyCarrier(io.crate.planner.DependencyCarrier) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) Settings(org.elasticsearch.common.settings.Settings) CreateIndexRequest(org.elasticsearch.action.admin.indices.create.CreateIndexRequest) OneRowActionListener(io.crate.execution.support.OneRowActionListener) BlobIndex.fullIndexName(io.crate.blob.v2.BlobIndex.fullIndexName) CreateBlobTable(io.crate.sql.tree.CreateBlobTable) TableParameter(io.crate.analyze.TableParameter) NodeContext(io.crate.metadata.NodeContext) TablePropertiesAnalyzer(io.crate.analyze.TablePropertiesAnalyzer) TableParameters(io.crate.analyze.TableParameters) CreateIndexResponse(org.elasticsearch.action.admin.indices.create.CreateIndexResponse) RowConsumer(io.crate.data.RowConsumer) NumberOfShards(io.crate.analyze.NumberOfShards) ClusteredBy(io.crate.sql.tree.ClusteredBy) AnalyzedCreateBlobTable(io.crate.analyze.AnalyzedCreateBlobTable) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) Row1(io.crate.data.Row1) CoordinatorTxnCtx(io.crate.metadata.CoordinatorTxnCtx) TableParameter(io.crate.analyze.TableParameter) Settings(org.elasticsearch.common.settings.Settings) VisibleForTesting(io.crate.common.annotations.VisibleForTesting)

Aggregations

AnalyzedCreateBlobTable (io.crate.analyze.AnalyzedCreateBlobTable)1 NumberOfShards (io.crate.analyze.NumberOfShards)1 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)1 TableParameter (io.crate.analyze.TableParameter)1 TableParameters (io.crate.analyze.TableParameters)1 TablePropertiesAnalyzer (io.crate.analyze.TablePropertiesAnalyzer)1 BlobIndex.fullIndexName (io.crate.blob.v2.BlobIndex.fullIndexName)1 SETTING_INDEX_BLOBS_ENABLED (io.crate.blob.v2.BlobIndicesService.SETTING_INDEX_BLOBS_ENABLED)1 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)1 Row (io.crate.data.Row)1 Row1 (io.crate.data.Row1)1 RowConsumer (io.crate.data.RowConsumer)1 OneRowActionListener (io.crate.execution.support.OneRowActionListener)1 Symbol (io.crate.expression.symbol.Symbol)1 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)1 NodeContext (io.crate.metadata.NodeContext)1 RelationName (io.crate.metadata.RelationName)1 DependencyCarrier (io.crate.planner.DependencyCarrier)1 Plan (io.crate.planner.Plan)1 PlannerContext (io.crate.planner.PlannerContext)1