Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Table


    // If this is an ancestor of that, then the return value is the number of generations separating the two.
    // (parent = 1). If this is not an ancestor of that, return -1.
    public int levelsApart(SingleBranchTypeComposition that)
    {
        // Find rootmost table in that
        Table thatRoot = that.tables.iterator().next();
        while (thatRoot.getParentTable() != null && that.tables.contains(thatRoot.getParentTable())) {
            thatRoot = thatRoot.getParentTable();
        }
        // this is an ancestor of that if that's rootmost table has an ancestor in this.
        int generationsApart = 0;
        Table thatAncestor = thatRoot;
        boolean ancestor = false;
        while (thatAncestor != null && !ancestor) {
            thatAncestor = thatAncestor.getParentTable();
            ancestor = this.tables.contains(thatAncestor);
            generationsApart++;
        }
        return ancestor ? generationsApart : -1;
    }
View Full Code Here


            validateGroup (ais, group, output);
        }
    }

    private static void validateGroup (AkibanInformationSchema ais, Group group, AISValidationOutput output) {
        Table rootTable = group.getRoot();
        if(rootTable == null) {
            return; // Caught elsewhere
        }
        boolean rootMemoryTable = rootTable.hasMemoryTableFactory();
        for (Table table : ais.getTables().values()) {
            if (table.getGroup() == group &&
                    table.hasMemoryTableFactory() != rootMemoryTable) {
                output.reportFailure(new AISValidationFailure (
                        new GroupMixedTableTypes(group.getName(), rootMemoryTable, table.getName())));
View Full Code Here

    private void setOrdinals() {
        this.ordinals = new int [hKeySegments+1];
        this.keyDepth = new int [hKeySegments];
        int ordinalIndex = 0;
        for (HKeySegment hKeySegment : rowType().hKey().segments()) {
            Table segmentTable = hKeySegment.table();
            ordinals[ordinalIndex] = segmentTable.getOrdinal();
            keyDepth[ordinalIndex] = hKeySegment.columns().size();
            ordinalIndex++;
        }
    }
View Full Code Here

    private static RowType leafmostCommonType(RowType leftType, RowType rightType)
    {
        Set<Table> common = new HashSet<>(leftType.typeComposition().tables());
        common.retainAll(rightType.typeComposition().tables());
        Table leafmostCommon = null;
        for (Table table : common) {
            if (leafmostCommon == null || table.getDepth() > leafmostCommon.getDepth()) {
                leafmostCommon = table;
            }
        }
        assert leafmostCommon != null : String.format("leftType: %s, rightType: %s", leftType, rightType);
        return leftType.schema().tableRowType(leafmostCommon);
View Full Code Here

        assertEquals("ChangeLevel", expectedChangeLevel, actual);
    }

    protected void runRenameTable(TableName oldName, TableName newName) {
        AkibanInformationSchema aisCopy = aisCloner().clone(ddl().getAIS(session()));
        Table oldTable = aisCopy.getTable(oldName);
        assertNotNull("Found old table " + oldName, oldTable);
        AISTableNameChanger changer = new AISTableNameChanger(aisCopy.getTable(oldName), newName);
        changer.doChange();
        Table newTable = aisCopy.getTable(newName);
        assertNotNull("Found new table " + newName, oldTable);
        runAlter(ChangeLevel.METADATA, oldName, newTable, NO_CHANGES, NO_CHANGES);
    }
View Full Code Here

        runAlter(ChangeLevel.METADATA, oldName, newTable, NO_CHANGES, NO_CHANGES);
    }

    protected void runRenameColumn(TableName tableName, String oldColName, String newColName) {
        AkibanInformationSchema aisCopy = aisCloner().clone(ddl().getAIS(session()));
        Table tableCopy = aisCopy.getTable(tableName);
        assertNotNull("Found table " + tableName, tableCopy);
        Column oldColumn = tableCopy.getColumn(oldColName);
        assertNotNull("Found old column " + oldColName, oldColumn);

        // Have to do this manually as parser doesn't support it, duplicates much of the work in AlterTableDDL
        List<Column> columns = new ArrayList<>(tableCopy.getColumns());
        tableCopy.dropColumns();
        for(Column column : columns) {
            Column.create(tableCopy, column, (column == oldColumn) ? newColName : null, null);
        }

        Column newColumn = tableCopy.getColumn(newColName);
        assertNotNull("Found new column " + newColName, newColumn);

        List<TableIndex> indexes = new ArrayList<>(tableCopy.getIndexes());
        for(TableIndex index : indexes) {
            if(index.containsTableColumn(tableName, oldColName)) {
                tableCopy.removeIndexes(Collections.singleton(index));
                if (index.getConstraintName() != null) {
                    aisCopy.removeConstraint(index.getConstraintName());
                }
                TableIndex indexCopy = TableIndex.create(tableCopy, index);
                for(IndexColumn iCol : index.getKeyColumns()) {
View Full Code Here

        if(tableID == 0) {
            return;
        }

        AkibanInformationSchema ais = ddl().getAIS(session());
        Table table = ais.getTable(tableID);
        List<Row> tableRows = new ArrayList<>(scanAll(tableID));

        for(TableIndex index : table.getIndexesIncludingInternal()) {
            if(index.getKeyColumns().size() == 1) {
                int idxPos = 0;
                int colPos = index.getKeyColumns().get(idxPos).getColumn().getPosition();
                Collections.sort(tableRows, new SingleColumnComparator(colPos));
View Full Code Here

        giRowType = null;
        adapter = null;
    }

    private TableRowType tableRowType(int tableId) {
        Table table = ddl().getAIS(session()).getTable(tableId);
        TableRowType rowType = schema.tableRowType(table);
        if (rowType == null) {
            throw new NullPointerException(table.toString());
        }
        return rowType;
    }
View Full Code Here

                                  DropTableNode dropTable,
                                  QueryContext context) {
        TableName tableName = convertName(defaultSchemaName, dropTable.getObjectName());
        AkibanInformationSchema ais = ddlFunctions.getAIS(session);
       
        Table table = ais.getTable(tableName);
        if(table == null) {
            if(skipOrThrow(context, dropTable.getExistenceCheck(), table, new NoSuchTableException(tableName))) {
                return;
            }
        }
View Full Code Here

                                    QueryContext context)
    {
        TableName tableName = convertName(defaultSchemaName, dropGroup.getObjectName());
        AkibanInformationSchema ais = ddlFunctions.getAIS(session);

        Table curTable = ais.getTable(tableName);
        if((curTable == null) &&
           skipOrThrow(context, dropGroup.getExistenceCheck(), curTable, new NoSuchTableException(tableName))) {
            return;
        }

        if (!curTable.isRoot()) {
            throw new DropGroupNotRootException (tableName);
        }
       
        final Group root = curTable.getGroup();
        for (Table table : ais.getTables().values()) {
            if (table.getGroup() == root) {
                ViewDDL.checkDropTable(ddlFunctions, session, table.getName());
                checkForeignKeyDropTable(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.