Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Table


    }

    @Override
    public void writeRow(Session session, RowDef rowDef, RowData rowData, Collection<TableIndex> tableIndexes,
                         Collection<GroupIndex> groupIndexes) {
        Table table = rowDef.table();
        trackTableWrite(session, table);
        constraintHandler.handleInsert(session, table, rowData);
        onlineHelper.handleInsert(session, table, rowData);
        writeRow(session, rowDef, rowData, tableIndexes, null, true);
        WRITE_ROW_GI_TAP.in();
View Full Code Here


        deleteRow(session, rowDef, rowData, cascadeDelete);
    }

    @Override
    public void deleteRow(Session session, RowDef rowDef, RowData rowData, boolean cascadeDelete) {
        Table table = rowDef.table();
        trackTableWrite(session, table);
        constraintHandler.handleDelete(session, table, rowData);
        onlineHelper.handleDelete(session, table, rowData);
        DELETE_ROW_GI_TAP.in();
        try {
            if(cascadeDelete) {
                cascadeDeleteMaintainGroupIndex(session, table, rowData);
            } else { // one row, one update to group indexes
                maintainGroupIndexes(session,
                                     table,
                                     table.getGroupIndexes(),
                                     rowData,
                                     null,
                                     StoreGIHandler.forTable(this, session, table),
                                     StoreGIHandler.Action.DELETE);
            }
View Full Code Here

        if (!(obj instanceof Map))
            throw new AkibanInternalException("Document not in expected format");
        Map<?,?> map = (Map<?,?>)obj;
        TableName tableName = TableName.create(defaultSchema,
                                               (String)map.get(TABLE_NAME_KEY));
        Table table = ais.getTable(tableName);
        if (table == null)
            throw new NoSuchTableException(tableName);
        String indexName = (String)map.get(INDEX_NAME_KEY);
        Index index = table.getIndex(indexName);
        if (index == null) {
            index = table.getGroup().getIndex(indexName);
            if (index == null) {
                if (statsIgnoreMissingIndexes)
                    return;
                throw new NoSuchIndexException(indexName);
            }
View Full Code Here

        updateRow(session, rowDef, oldRow, rowDef, newRow, selector);
    }

    @Override
    public void updateRow(Session session, RowDef oldRowDef, RowData oldRow, RowDef newRowDef, RowData newRow, ColumnSelector selector) {
        Table table = oldRowDef.table();
        trackTableWrite(session, table);
        // Note: selector is only used by the MySQL adapter, which does not have any
        // constraints on this side; newRow will be complete when there are any.
        // Similarly, all cases where newRowDef is not the same as oldRowDef should
        // be disallowed when there are constraints present.
        assert (((selector == null) && (oldRowDef == newRowDef)) ||
                table.getForeignKeys().isEmpty())
            : table;
        constraintHandler.handleUpdatePre(session, table, oldRow, newRow);
        onlineHelper.handleUpdatePre(session, table, oldRow, newRow);
        if(canSkipGIMaintenance(table)) {
            updateRow(session, oldRowDef, oldRow, newRowDef, newRow, selector, true);
        } else {
            UPDATE_ROW_GI_TAP.in();
            try {
                RowData mergedRow = mergeRows(oldRowDef, oldRow, newRowDef, newRow, selector);
                BitSet changedColumnPositions = changedColumnPositions(oldRowDef, oldRow, newRowDef, mergedRow);
                Collection<GroupIndex> groupIndexes = table.getGroupIndexes();
                maintainGroupIndexes(session,
                                     table,
                                     groupIndexes,
                                     oldRow,
                                     changedColumnPositions,
View Full Code Here

        truncateTree(session, group);
    }

    @Override
    public void truncateTableStatus(final Session session, final int rowDefId) {
        Table table = getAIS(session).getTable(rowDefId);
        table.rowDef().getTableStatus().truncate(session);
    }
View Full Code Here

             * Row being inserted might be the parent of orphan rows already present.
             * The hKeys of these orphan rows need to be maintained. The ones of interest
             * contain the PK from the inserted row, and nulls for other hKey fields nearer the root.
             */
            hKey.clear();
            Table table = rowDef.table();
            PersistitKeyAppender hKeyAppender = PersistitKeyAppender.create(hKey, table.getName());
            List<Column> pkColumns = table.getPrimaryKeyIncludingInternal().getColumns();
            for(HKeySegment segment : table.hKey().segments()) {
                RowDef segmentRowDef = segment.table().rowDef();
                hKey.append(segmentRowDef.table().getOrdinal());
                for(HKeyColumn hKeyColumn : segment.columns()) {
                    Column column = hKeyColumn.column();
                    if(pkColumns.contains(column)) {
View Full Code Here

            Key hKey = getKey(session, storeData);
            RowData rowData = new RowData();
            while(it.hasNext()) {
                it.next();
                expandRowData(session, storeData, rowData);
                Table table = ais.getTable(rowData.getRowDefId());
                assert (table != null) : rowData.getRowDefId();
                int ordinal = table.getOrdinal();
                if(tablesRequiringHKeyMaintenance == null || tablesRequiringHKeyMaintenance.get(ordinal)) {
                    PROPAGATE_REPLACE_TAP.in();
                    try {
                        for(RowListener listener : listenerService.getRowListeners()) {
                            listener.onDeletePre(session, table, hKey, rowData);
                        }
                        // Don't call deleteRow as the hKey does not need recomputed.
                        clear(session, storeData);
                        table.rowDef().getTableStatus().rowDeleted(session);
                        for(TableIndex index : table.rowDef().getIndexes()) {
                            long zValue = -1;
                            SpatialColumnHandler spatialColumnHandler = null;
                            if (index.isSpatial()) {
                                spatialColumnHandler = new SpatialColumnHandler(index);
                                zValue = spatialColumnHandler.zValue(rowData);
View Full Code Here

        }
        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,
                                     StoreGIHandler.forTable(this, session, table),
                                     StoreGIHandler.Action.CASCADE);
            }
View Full Code Here

    private static boolean canSkipGIMaintenance(Table table) {
        return table.getGroupIndexes().isEmpty();
    }

    private static RowDef getRowDef(AkibanInformationSchema ais, int tableID) {
        Table table = ais.getTable(tableID);
        assert (table != null) : tableID;
        return table.rowDef();
    }
View Full Code Here

        this.serviceManager = serviceManager;

    }

    private Table getTable(AkibanInformationSchema ais, String schemaName, String tableName) {
        Table table = ais.getTable(schemaName, tableName);
        if (table == null) {
            // TODO: Consider sending in-band as JSON.
            throw new NoSuchTableException(schemaName, tableName);
        }
        return table;
View Full Code Here

TOP

Related Classes of com.foundationdb.ais.model.Table

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.