Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Column


    private void explainColumnExpression(TPreparedExpression expression, ColumnExpression column) {
        CompoundExplainer explainer = new CompoundExplainer(Type.EXTRA_INFO);
        explainer.addAttribute(Label.POSITION,
                               PrimitiveExplainer.getInstance(column.getPosition()));
        Column aisColumn = column.getColumn();
        if (aisColumn != null) {
            explainer.addAttribute(Label.TABLE_CORRELATION,
                                   PrimitiveExplainer.getInstance(column.getTable().getName()));
            TableName tableName = aisColumn.getTable().getName();
            explainer.addAttribute(Label.TABLE_SCHEMA,
                                   PrimitiveExplainer.getInstance(tableName.getSchemaName()));
            explainer.addAttribute(Label.TABLE_NAME,
                                   PrimitiveExplainer.getInstance(tableName.getTableName()));
            explainer.addAttribute(Label.COLUMN_NAME,
                                   PrimitiveExplainer.getInstance(aisColumn.getName()));
        }
        explainContext.putExtraInfo(expression, explainer);
    }
View Full Code Here


        while (logicalColumn < startBoundColumns) {
            if (logicalColumn == firstSpatialColumn) {
                types[physicalColumn] = InternalIndexTypes.LONG.instance(SpatialHelper.isNullable(keyRange));
                logicalColumn += dimensions;
            } else {
                Column column = indexColumns.get(logicalColumn).getColumn();
                sortKeyAdapter.setColumnMetadata(column, physicalColumn, types);
                logicalColumn++;
            }
            physicalColumn++;
        }
View Full Code Here

        firstSpatialField = index.firstSpatialArgument();
        lastSpatialField = index.lastSpatialArgument();
        int spatialColumns = lastSpatialField - firstSpatialField + 1;
        for (int c = 0; c < spatialColumns; c++) {
            IndexColumn indexColumn = index.getKeyColumns().get(firstSpatialField + c);
            Column column = indexColumn.getColumn();
            tinstances[c] = column.getType();
            fieldDefs[c] = column.getFieldDef();
        }
    }
View Full Code Here

            startBoundColumns = keyRange.boundColumns();
            List<IndexColumn> indexColumns = index.getAllColumns();
            int nColumns = indexColumns.size();
            types = sortKeyAdapter.createTInstances(nColumns);
            for (int f = 0; f < nColumns; f++) {
                Column column = indexColumns.get(f).getColumn();
                sortKeyAdapter.setColumnMetadata(column, f, types);
            }
            startKey = adapter.takeIndexRow(keyRange.indexRowType());
            endKey = adapter.takeIndexRow(keyRange.indexRowType());
        }
View Full Code Here

                final Row row = rowIt.next();
                key.indexTo(0);

              
                for(IndexColumn indexColumn : index.getKeyColumns()) {
                    Column column = indexColumn.getColumn();
                    int colPos = column.getPosition();
                    Object objFromRow = ValueSources.toObject(row.value(colPos));
                    PersistitKeyValueSource valueSource = new PersistitKeyValueSource(indexColumn.getColumn().getType());
                    valueSource.attach(key, indexColumn);
                   
                    final Object lastConvertedValue;
                    try {
                        lastConvertedValue = ValueSources.toObject(valueSource);
                    } catch (Exception e) {
                        throw new RuntimeException("with type" + column.getTypeDescription(), e);
                    }

                    // Work around for dropping of 0 value sigfigs from key.decode()   
                    int compareValue = 1;
                    if(objFromRow instanceof BigDecimal && lastConvertedValue instanceof BigDecimal) {
View Full Code Here

    private static Index createSimpleIndex(Table curTable, String columnName) {
        AkibanInformationSchema ais = new AkibanInformationSchema();
        Table newTable = Table.create(ais, curTable.getName().getSchemaName(), curTable.getName().getTableName(), 0);
        Index newIndex = TableIndex.create(ais, newTable, columnName, 0, false, false);
        Column curColumn = curTable.getColumn(columnName);
        Column newColumn = Column.create(newTable,  curColumn.getName(), curColumn.getPosition(), curColumn.getType());
        IndexColumn.create(newIndex, newColumn, 0, true, null);
        return newIndex;
    }
View Full Code Here

    @Test
    public void alterColumnDefaultIdentity() {
        final int id = createTable(SCHEMA, C_TABLE,
                                   "id INT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY");
        Column column = getTable(id).getColumn("id");
        assertEquals("identity is default", true, column.getDefaultIdentity());
        Sequence seq = column.getIdentityGenerator();
        assertNotNull("id column has sequence", seq);

        runAlter(ChangeLevel.METADATA, "ALTER TABLE c ALTER COLUMN id DROP DEFAULT");
        assertNull("Old seq was dropped", ais().getSequence(seq.getSequenceName()));

        runAlter(ChangeLevel.METADATA, "ALTER TABLE c ALTER COLUMN id SET GENERATED ALWAYS AS IDENTITY");
        Column newColumn = getTable(id).getColumn("id");
        assertEquals("altered is always", false, newColumn.getDefaultIdentity());
        seq = newColumn.getIdentityGenerator();
        assertEquals("Sequence name suffix",
                     true,
                     seq.getSequenceName().getTableName().endsWith("_seq"));
    }
View Full Code Here

       
        final TableIndex index = TableIndex.create(ais, newTable, indexName, 0, isUnique, false, isUnique ? new TableName(curTable.getName().getSchemaName(), "ukey") : null);

        int pos = 0;
        for (String colName : refColumns) {
            Column col = curTable.getColumn(colName);
            Column refCol = Column.create(newTable, col.getName(), col.getPosition(), col.getType());
            IndexColumn.create(index, refCol, pos++, true, null);
        }
        return index;
    }
View Full Code Here

    public void unknownColumnName() throws InvalidOperationException {
        int tId = createTable("test", "t", "id int not null primary key");
        AkibanInformationSchema ais = createAISWithTable(tId);
        Table table = ais.getTable("test", "t");
        Index index = TableIndex.create(ais, table, "id", 0, false, false);
        Column refCol = Column.create(table, "foo", 0, typesRegistry().getTypeClass("MCOMPAT", "INT").instance(true));
        IndexColumn.create(index, refCol, 0, true, 0);
        ddl().createIndexes(session(), Arrays.asList(index));
    }
View Full Code Here

    public void mismatchedColumnType() throws InvalidOperationException {
        int tId = createTable("test", "t", "id int not null primary key");
        AkibanInformationSchema ais = createAISWithTable(tId);
        Table table = ais.getTable("test", "t");
        Index index = TableIndex.create(ais, table, "id", 0, false, false);
        Column refCol = Column.create(table, "id", 0, typesRegistry().getTypeClass("MCOMPAT", "BLOB").instance(true));
        IndexColumn.create(index, refCol, 0, true, 0);
        ddl().createIndexes(session(), Arrays.asList(index));
    }
View Full Code Here

TOP

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

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.