Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.TableIndex


        List<TableIndex> indexes = new ArrayList<>();
        for(TableIndex index : oldTable.getIndexesIncludingInternal()) {
            String oldName = index.getIndexName().getName();
            String preserveName = desc.getPreserveIndexes().get(oldName);
            if(preserveName == null) {
                TableIndex newIndex = newTable.getIndexIncludingInternal(oldName);
                if(newIndex != null) {
                    indexes.add(newIndex);
                }
            }
        }
View Full Code Here


            if (join.getParent().getPrimaryKey() == null) {
                output.reportFailure(new AISValidationFailure(
                        new JoinParentNoExplicitPK (join.getParent().getName())));
                continue;
            }
            TableIndex parentPK= join.getParent().getPrimaryKey().getIndex();
            if (parentPK.getKeyColumns().size() != join.getJoinColumns().size()) {
                output.reportFailure(new AISValidationFailure(
                        new JoinColumnMismatchException (join.getJoinColumns().size(),
                                join.getChild().getName(),
                                join.getParent().getName(),
                                parentPK.getKeyColumns().size())));

                continue;
            }
            Iterator<JoinColumn>  joinColumns = join.getJoinColumns().iterator();
            for (IndexColumn parentPKColumn : parentPK.getKeyColumns()) {
                JoinColumn joinColumn = joinColumns.next();
                if (parentPKColumn.getColumn() != joinColumn.getParent()) {
                    output.reportFailure(new AISValidationFailure (
                            new JoinToWrongColumnsException (
                                    join.getChild().getName(),
                                    joinColumn.getParent().getName(),
                                    parentPK.getTable().getName(), parentPKColumn.getColumn().getName())));
                }
            }
        }
    }
View Full Code Here

            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()) {
                    IndexColumn.create(indexCopy, (iCol.getColumn() == oldColumn) ? newColumn : iCol.getColumn(), iCol, iCol.getPosition());
                }
            }
        }
View Full Code Here

                throw new NoSuchColumnException(referencedColumnNames[i]);
            }
            referencedColumns.add(referencedColumn);
        }
        // Pick an index.
        TableIndex referencedIndex = ForeignKey.findReferencedIndex(referencedTable,
                                                                    referencedColumns);
        if (referencedIndex == null) {
            throw new ForeignKeyIndexRequiredException(constraintName, referencedName,
                                                       Arrays.toString(referencedColumnNames));
        }
View Full Code Here

            key.getReferencedIndex().isPrimaryKey()) {

            // Check the child table FK columns are the child table PK as well.
            // TODO: We may be able to relax this with further testing.
            List<Column> fkColumns = key.getReferencingColumns();
            TableIndex childPKIndex = key.getReferencingTable().getIndex(Index.PRIMARY);
            // this can occur if the child table has no declared primary key.
            if (childPKIndex == null) { return false; }
            List<IndexColumn> pkColumns = childPKIndex.getKeyColumns();
            if (fkColumns.size() != pkColumns.size()) return false;
            for (int i = 0; i < fkColumns.size(); i++) {
                if (!fkColumns.get(i).equals(pkColumns.get(i).getColumn())) {
                    return false;
                }
View Full Code Here

        for(TableIndex origIndex : origTable.getIndexesIncludingInternal()) {
            ChangeType indexChange = findOldName(indexChanges, origIndex.getIndexName().getName());
            if(indexChange == ChangeType.DROP) {
                continue;
            }
            TableIndex indexCopy = TableIndex.create(tableCopy, origIndex);
            int pos = 0;
            for(IndexColumn indexColumn : origIndex.getKeyColumns()) {
                String newName = findNewName(columnChanges, indexColumn.getColumn().getName());
                if(newName != null) {
                    IndexColumn.create(indexCopy, tableCopy.getColumn(newName), indexColumn, pos++);
                }
            }
            // DROP and MODIFY detection for indexes handled downstream
            if(indexCopy.getKeyColumns().isEmpty()) {
                tableCopy.removeIndexes(Collections.singleton(indexCopy));
            }
        }
    }
View Full Code Here

        // Look for incompatible spatial changes
        for(TableIndex oldIndex : oldTable.getIndexesIncludingInternal()) {
            String oldName = oldIndex.getIndexName().getName();
            String newName = findNewName(state.tableIndexChanges, oldName);
            TableIndex newIndex = (newName != null) ? newTable.getIndexIncludingInternal(newName) : null;
            if((newIndex != null) && oldIndex.isSpatial() && !Index.isSpatialCompatible(newIndex)) {
                newTable.removeIndexes(Collections.singleton(newIndex));

                // Remove any entry that already exists (e.g. MODIFY from compareColumns())
                Iterator<TableChange> it = state.tableIndexChanges.iterator();
View Full Code Here

                if(hKeyColumnTable != table) {
                    // HKey column from row of parent table
                    if (parentStoreData == null) {
                        // Initialize parent metadata and state
                        RowDef parentRowDef = rowDef.table().getParentTable().rowDef();
                        TableIndex parentPkIndex = parentRowDef.getPKIndex();
                        indexToHKey = parentPkIndex.indexToHKey();
                        parentStoreData = createStoreData(session, parentPkIndex);
                        parentPKIndexRow = readIndexRow(session, parentPkIndex, parentStoreData, rowDef, rowData);
                        i2hPosition = hKeyColumn.positionInHKey();
                    }
                    if(indexToHKey.isOrdinal(i2hPosition)) {
View Full Code Here

        BitSet tablesRequiringHKeyMaintenance;
        assert oldRow.getRowDefId() == newRow.getRowDefId();
        int fields = oldRowDef.getFieldCount();
        // Find the PK and FK fields
        BitSet keyField = new BitSet(fields);
        TableIndex pkIndex = oldRowDef.getPKIndex();
        int nkeys = pkIndex.getKeyColumns().size();
        IndexRowComposition indexRowComposition = pkIndex.indexRowComposition();
        for (int i = 0; i < nkeys; i++) {
            int pkFieldPosition = indexRowComposition.getFieldPosition(i);
            keyField.set(pkFieldPosition, true);
        }
        for (int fkFieldPosition : oldRowDef.getParentJoinFields()) {
View Full Code Here

                row(tid, "43.5435", "156.989"),
                row(tid, "32.456", "99.543"),
                row(tid, "53.00", "80.00")
        );
        createIndex(SCHEMA, TABLE, INDEX_NAME, "z_order_lat_lon(c1, c2)");
        TableIndex index = getTable(tid).getIndex("idx1");
        assertNotNull("Found index", index);
        assertEquals("Is spatial", true, index.isSpatial());
    }
View Full Code Here

TOP

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

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.