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()));
};
}
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);
}
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);
}
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);
}
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);
}
Aggregations