Package com.foundationdb.qp.operator

Examples of com.foundationdb.qp.operator.StoreAdapter


    private void populateIndex(Session session, FullTextIndex index) {
        final FullTextIndexInfo indexInfo = getIndex(session, index.getIndexName(), index.getIndexedTable().getAIS());
        boolean success = false;
        try {
            StoreAdapter adapter = store.createAdapter(session, indexInfo.getSchema());
            QueryContext queryContext = new SimpleQueryContext(adapter);
            Cursor cursor = null;
            Indexer indexer = indexInfo.getIndexer();
            try(RowIndexer rowIndexer = new RowIndexer(indexInfo, indexer.getWriter(), false)) {
                cursor = API.cursor(indexInfo.fullScan(), queryContext, queryContext.createBindings());
View Full Code Here


            }
        }
    }

    private void updateIndex(Session session, FullTextIndexInfo indexInfo, Iterable<byte[]> rows) throws IOException {
        StoreAdapter adapter = store.createAdapter(session, indexInfo.getSchema());
        QueryContext queryContext = new SimpleQueryContext(adapter);
        QueryBindings queryBindings = queryContext.createBindings();

        Cursor cursor = null;
        IndexWriter writer = indexInfo.getIndexer().getWriter();
View Full Code Here

        SDType storeData = createStoreData(session, table.getGroup());
        try {
            Key hKey = getKey(session, storeData);
            constructHKey(session, table.rowDef(), rowData, hKey);

            StoreAdapter adapter = createAdapter(session, SchemaCache.globalSchema(table.getAIS()));
            HKey persistitHKey = adapter.newHKey(table.hKey());
            persistitHKey.copyFrom(hKey);

            for(GroupIndex groupIndex : groupIndexes) {
                if(columnDifferences == null || groupIndex.columnsOverlap(table, columnDifferences)) {
                    StoreGIMaintenance plan = StoreGIMaintenancePlans
                            .forAis(table.getAIS())
                            .forRowType(groupIndex, adapter.schema().tableRowType(table));
                    plan.run(action, persistitHKey, rowData, adapter, handler);
                } else {
                    SKIP_GI_MAINTENANCE.hit();
                }
            }
View Full Code Here

    private void cascadeDeleteMaintainGroupIndex(Session session,
                                                 Table table,
                                                 RowData rowData)
    {
        Operator plan = PlanGenerator.generateBranchPlan(table.getAIS(), table);
        StoreAdapter adapter = createAdapter(session, SchemaCache.globalSchema(table.getAIS()));
        QueryContext queryContext = new SimpleQueryContext(adapter);
        QueryBindings queryBindings = queryContext.createBindings();
        Cursor cursor = API.cursor(plan, queryContext, queryBindings);

        List<Column> lookupCols = table.getPrimaryKeyIncludingInternal().getColumns();
        RowDataValueSource pSource = new RowDataValueSource();
        for(int i = 0; i < lookupCols.size(); ++i) {
            Column col = lookupCols.get(i);
            pSource.bind(col.getFieldDef(), rowData);
            queryBindings.setValue(i, pSource);
        }
        try {
            Row row;
            cursor.openTopLevel();
            while((row = cursor.next()) != null) {
                Table aTable = row.rowType().table();
                RowData data = adapter.rowData(aTable.rowDef(), row, new RowDataCreator());
                maintainGroupIndexes(session,
                                     aTable,
                                     aTable.getGroupIndexes(),
                                     data,
                                     null,
View Full Code Here

        private HKeyBytesStream(Session session) {
            this.session = session;
            AkibanInformationSchema ais = getAIS(session);
            Table changesTable = ais.getTable(CHANGES_TABLE);
            Operator plan = API.groupScan_Default(changesTable.getGroup());
            StoreAdapter adapter = store.createAdapter(session, SchemaCache.globalSchema(ais));
            QueryContext context = new SimpleQueryContext(adapter);
            this.cursor = API.cursor(plan, context, context.createBindings());
            cursor.open();
            findNextIndex();
        }
View Full Code Here

        int t2 = ddl().getTableId(session(), new TableName(SCHEMA, "t2"));

        Schema schema = SchemaCache.globalSchema(ddl().getAIS(session()));
        RowType t1Type = schema.tableRowType(getTable(t1));
        RowType t2Type = schema.tableRowType(getTable(t2));
        StoreAdapter adapter = newStoreAdapter(schema);

        txnService().beginTransaction(session());

        Object[] r1 = { 1L, "MA", "Massachusetts" };
        Object[] r101 = { 101L, 1L, "Boston" };
        Object[] r102 = { 102L, 1L, "Cambridge" };
        Object[] r2 = { 2L, "NY", "New York" };
        Object[] r201 = { 201L, 2L, "New York" };
        Object[] r202 = { 202L, 2L, "Albany" };
        writeRow(t1, r1);
        writeRow(t2, r101);
        writeRow(t2, r102);
        writeRow(t1, r2);
        writeRow(t2, r201);
        writeRow(t2, r202);

        List<Object> raw = Arrays.<Object>asList(
          Arrays.asList(Arrays.asList(1L, 1L, "abbrev"), Arrays.asList("MA")),
          Arrays.asList(Arrays.asList(1L, 1L, "id"), Arrays.asList(1L)),
          Arrays.asList(Arrays.asList(1L, 1L, "name"), Arrays.asList("Massachusetts")),
          Arrays.asList(Arrays.asList(1L, 1L, 2L, 101L, "id"), Arrays.asList(101L)),
          Arrays.asList(Arrays.asList(1L, 1L, 2L, 101L, "name"), Arrays.asList("Boston")),
          Arrays.asList(Arrays.asList(1L, 1L, 2L, 101L, "sid"), Arrays.asList(1L)),
          Arrays.asList(Arrays.asList(1L, 1L, 2L, 102L, "id"), Arrays.asList(102L)),
          Arrays.asList(Arrays.asList(1L, 1L, 2L, 102L, "name"), Arrays.asList("Cambridge")),
          Arrays.asList(Arrays.asList(1L, 1L, 2L, 102L, "sid"), Arrays.asList(1L)),
          Arrays.asList(Arrays.asList(1L, 2L, "abbrev"), Arrays.asList("NY")),
          Arrays.asList(Arrays.asList(1L, 2L, "id"), Arrays.asList(2L)),
          Arrays.asList(Arrays.asList(1L, 2L, "name"), Arrays.asList("New York")),
          Arrays.asList(Arrays.asList(1L, 2L, 2L, 201L, "id"), Arrays.asList(201L)),
          Arrays.asList(Arrays.asList(1L, 2L, 2L, 201L, "name"), Arrays.asList("New York")),
          Arrays.asList(Arrays.asList(1L, 2L, 2L, 201L, "sid"), Arrays.asList(2L)),
          Arrays.asList(Arrays.asList(1L, 2L, 2L, 202L, "id"), Arrays.asList(202L)),
          Arrays.asList(Arrays.asList(1L, 2L, 2L, 202L, "name"), Arrays.asList("Albany")),
          Arrays.asList(Arrays.asList(1L, 2L, 2L, 202L, "sid"), Arrays.asList(2L))
        );
        assertEquals(raw, treeTuples(t1Type.table().getGroup()));

        Row[] expected = {
            new TestRow(t1Type, r1),
            new TestRow(t2Type, r101),
            new TestRow(t2Type, r102),
            new TestRow(t1Type, r2),
            new TestRow(t2Type, r201),
            new TestRow(t2Type, r202)
        };
        compareRows(expected, adapter.newGroupCursor(t1Type.table().getGroup()));
        txnService().commitTransaction(session());
    }
View Full Code Here

                .rows().toArray(new Row[4]);
        compareRows(expected, cursor(plan));
    }

    private Cursor cursor(Operator plan) {
        StoreAdapter adapter = newStoreAdapter(schema);
        QueryContext context = queryContext(adapter);
        QueryBindings bindings = context.createBindings();
        return API.cursor(plan, context, bindings);
    }
View Full Code Here

          "CREATE TABLE t1(id INT PRIMARY KEY NOT NULL, s VARCHAR(128)) STORAGE_FORMAT tuple");
        int t1 = ddl().getTableId(session(), new TableName(SCHEMA, "t1"));

        Schema schema = SchemaCache.globalSchema(ddl().getAIS(session()));
        RowType t1Type = schema.tableRowType(getTable(t1));
        StoreAdapter adapter = newStoreAdapter(schema);

        txnService().beginTransaction(session());

        Object[] r1 = { 1L, "Fred" };
        Object[] r2 = { 2L, "Barney" };
        writeRow(t1, r1);
        writeRow(t1, r2);

        Row[] expected = {
            new TestRow(t1Type, r1),
            new TestRow(t1Type, r2)
        };
        compareRows(expected, adapter.newGroupCursor(t1Type.table().getGroup()));

        txnService().commitTransaction(session());
    }
View Full Code Here

        int child = ddl().getTableId(session(), new TableName(SCHEMA, "child"));

        Schema schema = SchemaCache.globalSchema(ddl().getAIS(session()));
        RowType parentType = schema.tableRowType(getTable(parent));
        RowType childType = schema.tableRowType(getTable(child));
        StoreAdapter adapter = newStoreAdapter(schema);

        txnService().beginTransaction(session());

        Object[] r1 = { 1L, "Margaret" };
        Object[] r1a = { 101L, 1L, "Meg" };
        Object[] r1b = { 102L, 1L, "Jo" };
        Object[] r2 = { 2L, "Josephine" };
        writeRow(parent, r1);
        writeRow(child, r1a);
        writeRow(child, r1b);
        writeRow(parent, r2);

        Row[] expected = {
            new TestRow(parentType, r1),
            new TestRow(childType, r1a),
            new TestRow(childType, r1b),
            new TestRow(parentType, r2)
        };
        compareRows(expected, adapter.newGroupCursor(parentType.table().getGroup()));

        txnService().commitTransaction(session());
    }
View Full Code Here

    protected void runTest(API.SortOption sortOption, List<String[]> input, List<String[]> expected, boolean... fieldOrdering) {
        assertEquals("input = expected size", input.size(), expected.size());

        RowsBuilder inputRows = createBuilder(input);
        Schema schema = SchemaCache.globalSchema(ddl().getAIS(session()));
        StoreAdapter adapter = newStoreAdapter(schema);
        TestOperator inputOperator = new TestOperator(inputRows);

        QueryContext context = queryContext(adapter);
        QueryBindings bindings = context.createBindings();
        Cursor inputCursor = API.cursor(inputOperator, context, bindings);
View Full Code Here

TOP

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

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.