Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Index


        AISMerge merge = AISMerge.newForAddIndex(aisCloner, getNameGenerator(session), getAISForChange(session));
        Set<String> schemas = new HashSet<>();
        Collection<Integer> tableIDs = new HashSet<>(indexes.size());
        for(Index proposed : indexes) {
            Index newIndex = merge.mergeIndex(proposed);
            if(keepStorage && (proposed.getStorageDescription() != null)) {
                newIndex.copyStorageDescription(proposed);
            }
            tableIDs.addAll(newIndex.getAllTableIDs());
            schemas.add(DefaultNameGenerator.schemaNameForIndex(newIndex));
        }
        merge.merge();
        AkibanInformationSchema newAIS = merge.getAIS();
        saveAISChange(session, newAIS, schemas, tableIDs);
View Full Code Here


        try {
            final Table table = getTable(session, tableName);
            Collection<Index> tableIndexes = new HashSet<>();
            Collection<Index> allIndexes = tableIndexes;
            for(String indexName : indexNamesToDrop) {
                Index index = table.getIndex(indexName);
                if(index != null) {
                    tableIndexes.add(index);
                }
                else if ((index = table.getFullTextIndex(indexName)) != null) {
                    if (allIndexes == tableIndexes) {
                        allIndexes = new HashSet<>(allIndexes);
                    }
                }
                else {
                    throw new NoSuchIndexException(indexName);
                }
                // no primary key nor connected to a FK
                if(index.isPrimaryKey() || index.isConnectedToFK()) {
                    throw new ProtectedIndexException(indexName, table.getName());
                }
                if (allIndexes != tableIndexes) {
                    allIndexes.add(index);
                }
View Full Code Here

            if (group == null) {
                throw new NoSuchGroupException(groupName);
            }
            Collection<Index> indexes = new HashSet<>();
            for(String indexName : indexNamesToDrop) {
                final Index index = group.getIndex(indexName);
                if(index == null) {
                    throw new NoSuchIndexException(indexName);
                }
                indexes.add(index);
            }
View Full Code Here

                    indexes.add(index);
            }
        }
        else {
            for (String indexName : indexesToUpdate) {
                Index index = table.getIndex(indexName);
                if (index == null) {
                    index = table.getGroup().getIndex(indexName);
                    if (index == null)
                        throw new NoSuchIndexException(indexName);
                }
View Full Code Here

        List<HasStorage> storageToRemove = new ArrayList<>();
        for(TableChange ic : validator.getState().tableIndexChanges) {
            switch(ic.getChangeType()) {
                case MODIFY:
                case DROP:
                    Index index = origTable.getIndexIncludingInternal(ic.getOldName());
                    storageToRemove.add(index);
                break;
            }
        }
View Full Code Here

            }
        }

        @Override
        public void visit(IndexColumn indexColumn) {
            Index index = indexColumn.getIndex();
            boolean nonPointSpatialIndex =
                index.isSpatial() &&
                index.firstSpatialArgument() == index.lastSpatialArgument();
            TInstance columnType = indexColumn.getColumn().getType();
            if (!(!nonPointSpatialIndex && TypeValidator.isSupportedForIndex(columnType) ||
                  nonPointSpatialIndex && TypeValidator.isSupportedForNonPiontSpatialIndex(columnType))) {
                failures.reportFailure(new AISValidationFailure (
                        new UnsupportedIndexDataTypeException (
                                new TableName (index.getIndexName().getSchemaName(),
                                index.getIndexName().getTableName()),
                                index.getIndexName().getName(),
                                indexColumn.getColumn().getName(),
                                indexColumn.getColumn().getTypeName())));
            }
        }
View Full Code Here

    }

    private static String[] columnNamesFromListOrPK(ResultColumnList list, PrimaryKey pk) {
        String[] names = (list == null) ? null: list.getColumnNames();
        if(((names == null) || (names.length == 0)) && (pk != null)) {
            Index index = pk.getIndex();
            names = new String[index.getKeyColumns().size()];
            int i = 0;
            for(IndexColumn iCol : index.getKeyColumns()) {
                names[i++] = iCol.getColumn().getName();
            }
        }
        if(names == null) {
            names = new String[0];
View Full Code Here

            Table table,
            QueryContext context,
            DDLFunctions ddl
            ) {
        IndexColumnList columnList = id.getIndexColumnList();
        Index tableIndex;
        TableName constraintName = null;
        if(indexName == null) {
            indexName = namer.generateIndexName(null, columnList.get(0).getColumnName());
        }
        if(id.isUnique()) {
            constraintName = builder.getNameGenerator().generateUniqueConstraintName(table.getName().getSchemaName(), indexName);
        }
        if (columnList.functionType() == IndexColumnList.FunctionType.FULL_TEXT) {
            logger.debug ("Building Full text index on table {}", table.getName()) ;
            tableIndex = IndexDDL.buildFullTextIndex(builder, table.getName(), indexName, id, null, null);
        } else if (IndexDDL.checkIndexType (id, table.getName()) == Index.IndexType.TABLE) {
            logger.debug ("Building Table index on table {}", table.getName()) ;
            tableIndex = IndexDDL.buildTableIndex (builder, table.getName(), indexName, id, constraintName, null, null);
        } else {
            logger.debug ("Building Group index on table {}", table.getName());
            tableIndex = IndexDDL.buildGroupIndex(builder, table.getName(), indexName, id, null, null);
        }

        boolean indexIsSpatial = columnList.functionType() == IndexColumnList.FunctionType.Z_ORDER_LAT_LON;
        // Can't check isSpatialCompatible before the index columns have been added.
        if (indexIsSpatial && !Index.isSpatialCompatible(tableIndex)) {
            throw new BadSpatialIndexException(tableIndex.getIndexName().getTableName(), null);
        }
        StorageFormatNode sfn = id.getStorageFormat();
        if (sfn != null) {
            tableIndex.setStorageDescription(ddl.getStorageFormatRegistry().parseSQL(sfn, tableIndex));
        }
        return tableIndex.getIndexName().getName();
    }
View Full Code Here

                Arrays.asList(93L, 72L, 82L)
        );
    }

    protected void traversePK(int rowDefId, List<?>... expectedIndexes) throws Exception {
        Index pkIndex = getRowDef(rowDefId).getPKIndex();

        try(CloseableTransaction txn = txnService().beginCloseableTransaction(session())) {
            CollectingIndexKeyVisitor visitor = new CollectingIndexKeyVisitor();
            store().traverse(session(), pkIndex, visitor, -1, 0);
            assertEquals("traversed indexes", Arrays.asList(expectedIndexes), visitor.records());
View Full Code Here

                                               new NoSuchConstraintException(origTable.getName(), name));
                                    name = null;
                                }
                                break;
                            case UNIQUE:
                                Index index = origTable.getIndex(name);
                                if(index == null || !index.isUnique()) {
                                    skipOrThrow(context,
                                                cdn.getExistenceCheck(),
                                                null,
                                                new NoSuchUniqueException(origTable.getName(), cdn.getName()));
                                    name = null;
View Full Code Here

TOP

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

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.