Package com.foundationdb.qp.operator

Examples of com.foundationdb.qp.operator.QueryContext


        return plan;
    }

    protected void runOperatorPlan(Plan plan, Session session,
                                   RowData oldRow, RowData newRow) {
        QueryContext context =
            new SimpleQueryContext(store.createAdapter(session, plan.schema),
                                   serviceManager);
        QueryBindings bindings = context.createBindings();
        if (plan.bindOldRow) {
            RowDataValueSource source = new RowDataValueSource();
            for (int i = 0; i < plan.ncols; i++) {
                source.bind(plan.referencedFields[i], oldRow);
                bindings.setValue(i, source);
View Full Code Here


            PlanContext planContext = new PlanContext(compiler);

            BasePlannable result = compiler.compile(dmlStmt, null, planContext);

            Plannable plannable = result.getPlannable();
            QueryContext newContext = contextIfNull(context, adapter);
            getTransformCache(session, server);
            runPlan(session, newContext, schemaManager, txnService, (Operator) plannable, null);
        }finally{
            txnService.commitTransaction(session);
        }
View Full Code Here

        final AkibanInformationSchema origAIS = schemaManager.getAis(session);
        final AkibanInformationSchema newAIS = schemaManager.getOnlineAIS(session);

        final Schema origSchema = SchemaCache.globalSchema(origAIS);
        final StoreAdapter origAdapter = store.createAdapter(session, origSchema);
        final QueryContext origContext = new DelegatingContext(origAdapter, context);
        final QueryBindings origBindings = origContext.createBindings();

        final TransformCache transformCache = getTransformCache(session, null);
        Set<Table> origRoots = findOldRoots(changeSets, origAIS, newAIS);

        for(Table root : origRoots) {
View Full Code Here

    }

    private void concurrentDML(final Session session, TableTransform transform, Key hKey, RowData oldRowData, RowData newRowData) {
        final boolean doDelete = (oldRowData != null);
        final boolean doWrite = (newRowData != null);
        QueryContext context = null;
        switch(transform.changeLevel) {
            case INDEX:
                if(!transform.tableIndexes.isEmpty()) {
                    WriteIndexRow buffer = new WriteIndexRow (store);
                    for(TableIndex index : transform.tableIndexes) {
                        long oldZValue = -1;
                        long newZValue = -1;
                        SpatialColumnHandler spatialColumnHandler = null;
                        if (index.isSpatial()) {
                            spatialColumnHandler = new SpatialColumnHandler(index);
                            oldZValue = spatialColumnHandler.zValue(oldRowData);
                            newZValue = spatialColumnHandler.zValue(newRowData);
                        }
                        if(doDelete) {
                            store.deleteIndexRow(session, index, oldRowData, hKey, buffer, spatialColumnHandler, oldZValue, false);
                        }
                        if(doWrite) {
                            store.writeIndexRow(session, index, newRowData, hKey, buffer, spatialColumnHandler, newZValue, false);
                        }
                    }
                }
                if(!transform.groupIndexes.isEmpty()) {
                    if(doDelete) {
                        store.deleteIndexRows(session, transform.rowType.table(), oldRowData, transform.groupIndexes);
                    }
                    if(doWrite) {
                        store.writeIndexRows(session, transform.rowType.table(), newRowData, transform.groupIndexes);
                    }
                }
                break;
            case TABLE:
                if(transform.deleteOperator != null && transform.insertOperator != null) {
                    Schema schema = transform.rowType.schema();
                    StoreAdapter adapter = store.createAdapter(session, schema);
                    context = new SimpleQueryContext(adapter);
                    QueryBindings bindings = context.createBindings();
                    if (doDelete) {
                        Row origOldRow = new RowDataRow(transform.rowType, oldRowData);
                        bindings.setRow(OperatorAssembler.CREATE_AS_BINDING_POSITION, origOldRow);
                        try {
                            runPlan(context, transform.deleteOperator, bindings);
                        } catch (NoSuchRowException e) {
                            LOG.debug("row not present: {}", origOldRow);
                        }
                    }
                    if (doWrite) {
                        Row origOldRow = new RowDataRow(transform.rowType, newRowData);
                        bindings.setRow(OperatorAssembler.CREATE_AS_BINDING_POSITION, origOldRow);
                        try {
                            runPlan(context, transform.insertOperator, bindings);
                        } catch (NoSuchRowException e) {
                            LOG.debug("row not present: {}", origOldRow);
                        }
                    }
                    break;
                }
            case GROUP:
                Schema schema = transform.rowType.schema();
                StoreAdapter adapter = store.createAdapter(session, schema);
                context = new SimpleQueryContext(adapter);
                QueryBindings bindings = context.createBindings();
                if(doDelete) {
                    Row origOldRow = new RowDataRow(transform.rowType, oldRowData);
                    Row newOldRow = transformRow(context, bindings, transform, origOldRow);
                    try {
                        adapter.deleteRow(newOldRow, false);
View Full Code Here

        Table table = ais.getTable(tid);
        List<Column> columns = Collections.singletonList(table.getColumn("name"));
        InputStream istr = new ByteArrayInputStream(CSV.getBytes("UTF-8"));
        Schema schema = SchemaCache.globalSchema(ais);
        StoreAdapter adapter = newStoreAdapter(schema);
        QueryContext queryContext = new SimpleQueryContext(adapter) {
                @Override
                public ServiceManager getServiceManager() {
                    return serviceManager();
                }
                @Override
View Full Code Here

        DumpGroupLoadablePlan loadablePlan = new DumpGroupLoadablePlan();
        DirectObjectPlan plan = loadablePlan.plan();

        Schema schema = new Schema(ais());
        StoreAdapter adapter = newStoreAdapter(schema);
        QueryContext queryContext = new SimpleQueryContext(adapter) {
                @Override
                public String getCurrentSchema() {
                    return SCHEMA_NAME;
                }
            };
        QueryBindings queryBindings = queryContext.createBindings();
        queryBindings.setValue(0, new Value(MString.varcharFor(SCHEMA_NAME), SCHEMA_NAME));
        queryBindings.setValue(1, new Value(MString.varcharFor(groupName), groupName));
        if (multiple)
            queryBindings.setValue(2, new Value(MNumeric.INT.instance(false), 10));
        if (commitFreq > 0)
View Full Code Here

        PersistitCLILoadablePlan loadablePlan = new PersistitCLILoadablePlan();
        DirectObjectPlan plan = loadablePlan.plan();

        Schema schema = new Schema(ais());
        StoreAdapter adapter = newStoreAdapter(schema);
        QueryContext queryContext = queryContext(adapter);
        QueryBindings queryBindings = queryContext.createBindings();

        DirectObjectCursor cursor = plan.cursor(queryContext, queryBindings);
        queryBindings.setValue(0, new Value(MString.varcharFor("stat"), "stat"));
        queryBindings.setValue(1, new Value(MString.varcharFor("count=3"), "count=3"));
        queryBindings.setValue(2, new Value(MString.varcharFor("delay=2"), "delay=2"));
View Full Code Here

        Table table = ais().getTable(tableName);
        Schema schema = SchemaCache.globalSchema(ais());
        TableRowType rowType = schema.tableRowType(table);
        MemoryAdapter adapter = new MemoryAdapter(schema, session(), configService());

        QueryContext queryContext = new SimpleQueryContext(adapter);
        Row[] rows = objectToRows(expected, rowType);

        Cursor cursor = API.cursor(
                API.limit_Default(API.groupScan_Default(table.getGroup()), limit),
                queryContext, queryContext.createBindings());
        compareRows(rows, cursor, true);

    }
View Full Code Here

        Table table = ais().getTable(tableName);
        Schema schema = SchemaCache.globalSchema(ais());
        TableRowType rowType = schema.tableRowType(table);
        MemoryAdapter adapter = new MemoryAdapter(schema, session(), configService());

        QueryContext queryContext = new SimpleQueryContext(adapter);
       
        List<TPreparedExpression> pExpressions = new ArrayList<>(1);
      
        Value value = new Value(rowType.typeAt(columnNum));
        value.putNull();
        TPreptimeValue ptval = new TPreptimeValue (value.getType(), value);
        pExpressions.add(new TPreparedLiteral(ptval.type(), ptval.value()));
       
        ValuesRowType expectedType = schema.newValuesType(rowType.typeAt(columnNum));
       
        Row[] rows = objectToRows(expected, expectedType);
       
        Cursor cursor = API.cursor(
                API.project_Default(
                        API.groupScan_Default(table.getGroup()),
                        rowType, pExpressions),
                    queryContext,
                    queryContext.createBindings());
       
        compareRows(rows, cursor, true);
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.qp.operator.QueryContext

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.