Search in sources :

Example 11 with NodeContext

use of io.crate.metadata.NodeContext in project crate by crate.

the class FetchProjector method create.

public static Projector create(FetchProjection projection, RamAccounting ramAccounting, LongSupplier getBucketsBytesThreshold, TransactionContext txnCtx, NodeContext nodeCtx, FetchOperation fetchOperation) {
    final FetchRows fetchRows = FetchRows.create(txnCtx, nodeCtx, projection.fetchSources(), projection.outputSymbols());
    EstimateCellsSize estimateRowSize = new EstimateCellsSize(projection.inputTypes());
    return (BatchIterator<Row> source) -> {
        final long maxBucketsSizeInBytes = getBucketsBytesThreshold.getAsLong();
        BatchIterator<ReaderBuckets> buckets = BatchIterators.partition(source, projection.getFetchSize(), () -> new ReaderBuckets(fetchRows, projection::getFetchSourceByReader, estimateRowSize, ramAccounting), ReaderBuckets::add, readerBuckets -> readerBuckets.ramBytesUsed() > maxBucketsSizeInBytes);
        return new AsyncFlatMapBatchIterator<>(buckets, new FetchMapper(fetchOperation, projection.nodeReaders()));
    };
}
Also used : TransactionContext(io.crate.metadata.TransactionContext) ByteSizeUnit(org.elasticsearch.common.unit.ByteSizeUnit) NodeContext(io.crate.metadata.NodeContext) LongSupplier(java.util.function.LongSupplier) BatchIterator(io.crate.data.BatchIterator) RamAccounting(io.crate.breaker.RamAccounting) Projector(io.crate.data.Projector) EstimateCellsSize(io.crate.breaker.EstimateCellsSize) BatchIterators(io.crate.data.BatchIterators) Row(io.crate.data.Row) AsyncFlatMapBatchIterator(io.crate.data.AsyncFlatMapBatchIterator) CircuitBreaker(org.elasticsearch.common.breaker.CircuitBreaker) FetchProjection(io.crate.execution.dsl.projection.FetchProjection) EstimateCellsSize(io.crate.breaker.EstimateCellsSize) BatchIterator(io.crate.data.BatchIterator) AsyncFlatMapBatchIterator(io.crate.data.AsyncFlatMapBatchIterator) Row(io.crate.data.Row)

Example 12 with NodeContext

use of io.crate.metadata.NodeContext in project crate by crate.

the class FileReadingCollectorTest method prepare.

@Before
public void prepare() throws Exception {
    NodeContext nodeCtx = new NodeContext(new Functions(Map.of()));
    inputFactory = new InputFactory(nodeCtx);
}
Also used : InputFactory(io.crate.expression.InputFactory) NodeContext(io.crate.metadata.NodeContext) Functions(io.crate.metadata.Functions) Before(org.junit.Before)

Example 13 with NodeContext

use of io.crate.metadata.NodeContext in project crate by crate.

the class FileReadingIteratorTest method prepare.

@Before
public void prepare() {
    NodeContext nodeCtx = new NodeContext(new Functions(Map.of()));
    inputFactory = new InputFactory(nodeCtx);
}
Also used : InputFactory(io.crate.expression.InputFactory) NodeContext(io.crate.metadata.NodeContext) Functions(io.crate.metadata.Functions) Before(org.junit.Before)

Example 14 with NodeContext

use of io.crate.metadata.NodeContext in project crate by crate.

the class SQLIntegrationTestCase method plan.

public PlanForNode plan(String stmt) {
    String[] nodeNames = internalCluster().getNodeNames();
    String nodeName = nodeNames[randomIntBetween(1, nodeNames.length) - 1];
    Analyzer analyzer = internalCluster().getInstance(Analyzer.class, nodeName);
    Planner planner = internalCluster().getInstance(Planner.class, nodeName);
    NodeContext nodeCtx = internalCluster().getInstance(NodeContext.class, nodeName);
    SessionContext sessionContext = new SessionContext(User.CRATE_USER, sqlExecutor.getCurrentSchema());
    CoordinatorTxnCtx coordinatorTxnCtx = new CoordinatorTxnCtx(sessionContext);
    RoutingProvider routingProvider = new RoutingProvider(Randomness.get().nextInt(), planner.getAwarenessAttributes());
    PlannerContext plannerContext = new PlannerContext(planner.currentClusterState(), routingProvider, UUID.randomUUID(), coordinatorTxnCtx, nodeCtx, 0, null);
    Plan plan = planner.plan(analyzer.analyze(SqlParser.createStatement(stmt), coordinatorTxnCtx.sessionContext(), ParamTypeHints.EMPTY), plannerContext);
    return new PlanForNode(plan, nodeName, plannerContext);
}
Also used : RoutingProvider(io.crate.metadata.RoutingProvider) CoordinatorTxnCtx(io.crate.metadata.CoordinatorTxnCtx) PlannerContext(io.crate.planner.PlannerContext) NodeContext(io.crate.metadata.NodeContext) SessionContext(io.crate.action.sql.SessionContext) Planner(io.crate.planner.Planner) Analyzer(io.crate.analyze.Analyzer) Plan(io.crate.planner.Plan)

Example 15 with NodeContext

use of io.crate.metadata.NodeContext in project crate by crate.

the class SysShardsExpressionsTest method prepare.

@Before
public void prepare() {
    NodeContext nodeCtx = createNodeContext();
    indexShard = mockIndexShard();
    CrateSettings crateSettings = new CrateSettings(clusterService, clusterService.getSettings());
    UserDefinedFunctionService udfService = new UserDefinedFunctionService(clusterService, nodeCtx);
    schemas = new Schemas(Map.of("sys", new SysSchemaInfo(this.clusterService, crateSettings)), clusterService, new DocSchemaInfoFactory(new TestingDocTableInfoFactory(Collections.emptyMap()), (ident, state) -> null, nodeCtx, udfService));
    resolver = new ShardReferenceResolver(schemas, new ShardRowContext(indexShard, clusterService));
    sysShards = schemas.getTableInfo(SysShardsTableInfo.IDENT);
}
Also used : UserDefinedFunctionService(io.crate.expression.udf.UserDefinedFunctionService) ShardRowContext(io.crate.expression.reference.sys.shard.ShardRowContext) SysSchemaInfo(io.crate.metadata.sys.SysSchemaInfo) DocSchemaInfoFactory(io.crate.metadata.doc.DocSchemaInfoFactory) CrateSettings(io.crate.metadata.settings.CrateSettings) TestingDocTableInfoFactory(io.crate.metadata.doc.TestingDocTableInfoFactory) TestingHelpers.createNodeContext(io.crate.testing.TestingHelpers.createNodeContext) NodeContext(io.crate.metadata.NodeContext) Schemas(io.crate.metadata.Schemas) ShardReferenceResolver(io.crate.metadata.shard.ShardReferenceResolver) Before(org.junit.Before)

Aggregations

NodeContext (io.crate.metadata.NodeContext)29 Symbol (io.crate.expression.symbol.Symbol)16 Row (io.crate.data.Row)14 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)12 List (java.util.List)12 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)10 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)10 Plan (io.crate.planner.Plan)10 PlannerContext (io.crate.planner.PlannerContext)10 SubQueryResults (io.crate.planner.operators.SubQueryResults)10 Function (java.util.function.Function)10 Nullable (javax.annotation.Nullable)10 RowConsumer (io.crate.data.RowConsumer)9 TransactionContext (io.crate.metadata.TransactionContext)9 DependencyCarrier (io.crate.planner.DependencyCarrier)9 ArrayList (java.util.ArrayList)9 Settings (org.elasticsearch.common.settings.Settings)9 Row1 (io.crate.data.Row1)8 OneRowActionListener (io.crate.execution.support.OneRowActionListener)8 Map (java.util.Map)7