Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Column


        rowDef.setParentJoinFields(parentJoinFields);
        rowDef.setIndexes(indexList);
        rowDef.setGroupIndexes(groupIndexList.toArray(new GroupIndex[groupIndexList.size()]));

        rowDef.getTableStatus().setRowDef(rowDef);
        Column autoIncColumn = table.getAutoIncrementColumn();
        if(autoIncColumn != null) {
            long initialAutoIncrementValue = autoIncColumn.getInitialAutoIncrementValue();
            rowDef.getTableStatus().setAutoIncrement(session, initialAutoIncrementValue);
        }

        return rowDef;
    }
View Full Code Here


                final String msg = "row " + rowIndex + ", col " + colIndex;
                final Object expected = expectedRows[rowIndex][colIndex];
                final ValueSource actual = row.value(colIndex);
               
                if(expected == null || actual.isNull()) {
                    Column column = row.rowType().table().getColumn(colIndex);
                    if(!Boolean.TRUE.equals(column.getNullable())) {
                        fail(String.format("Expected (%s) or actual (%s) NULL for column (%s) declared NOT NULL",
                                           expected, actual, column));
                    }
                }
View Full Code Here

    public void nonDefaultCharsetAndCollations() {
        // AIS char/col not serialized (will be on Schema when that exists)
        final AkibanInformationSchema inAIS = CAOIBuilderFiller.createAndFillBuilder(SCHEMA).ais(false);
        inAIS.getTable(SCHEMA, CAOIBuilderFiller.ORDER_TABLE).
                setCharsetAndCollation("utf16", "sv_se_ci");
        Column column = inAIS.getTable(SCHEMA, CAOIBuilderFiller.CUSTOMER_TABLE).getColumn("customer_name");
        TInstance type = column.getType();
        type = type.typeClass().instance(
                        type.attribute(StringAttribute.MAX_LENGTH),
                        StringFactory.Charset.LATIN1.ordinal(),
                        AkCollatorFactory.getAkCollator("en_us").getCollationId(),
                        type.nullability());
        column.setType(type);
        inAIS.freeze();
       
        final AkibanInformationSchema outAIS = writeAndRead(inAIS);
        compareAndAssert(inAIS, outAIS, false);
    }
View Full Code Here

    public void partialParentWithFullChild() {
        final AkibanInformationSchema inAIS = new AkibanInformationSchema();
       
        Table stubCustomer = Table.create(inAIS, SCHEMA, "c", 1);
        TInstance bigint = typesRegistry().getTypeClass("MCOMPAT", "BIGINT").instance(false);
        Column cId = Column.create(stubCustomer, "id", 2, bigint);

        Table realOrder = Table.create(inAIS, SCHEMA, "o", 2);
        Column oId = Column.create(realOrder, "oid", 0, bigint);
        Column oCid = Column.create(realOrder, "cid", 1, bigint);
        TInstance date = typesRegistry().getTypeClass("MCOMPAT", "DATE").instance(true);
        Column.create(realOrder, "odate", 2, date);
        Index orderPK = TableIndex.create(inAIS, realOrder, Index.PRIMARY, 0, true, true, new TableName(SCHEMA, "pkey"));
        IndexColumn.create(orderPK, oId, 0, true, null);
        Index akFk = TableIndex.create(inAIS, realOrder, "_fk1", 1, false, false);
View Full Code Here

    public void partialTableWithIndexes() {
        final AkibanInformationSchema inAIS = new AkibanInformationSchema();

        Table stubCustomer = Table.create(inAIS, SCHEMA, "c", 1);
        TInstance varchar32 = typesRegistry().getTypeClass("MCOMPAT", "VARCHAR").instance(32, true);
        Column cFirstName = Column.create(stubCustomer, "first_name", 3, varchar32);
        Column cLastName = Column.create(stubCustomer, "last_name", 4, varchar32);
        TInstance int_null = typesRegistry().getTypeClass("MCOMPAT", "INT").instance(true);
        Column cPayment = Column.create(stubCustomer, "payment", 6, int_null);
        Index iName = TableIndex.create(inAIS, stubCustomer, "name", 2, false, false);
        IndexColumn.create(iName, cLastName, 0, true, null);
        IndexColumn.create(iName, cFirstName, 1, true, null);
        Index iPayment = TableIndex.create(inAIS, stubCustomer, "payment", 3, false, false);
        IndexColumn.create(iPayment, cPayment, 0, true, null);
View Full Code Here

        builder.table("customers").
            colBigInt("customer_id", false).
            colString("customer_name", 100, false).
            pk("customer_id");
        AkibanInformationSchema inAIS = builder.unvalidatedAIS();
        Column idColumn = inAIS.getTable(new TableName (SCHEMA, "customers")).getColumn(0);
        idColumn.setDefaultIdentity(true);
        idColumn.setIdentityGenerator(inAIS.getSequence(sequenceName));
       
        AkibanInformationSchema outAIS = writeAndRead(builder.ais());
       
        assertNotNull(outAIS.getSequence(sequenceName));
        Column outColumn = outAIS.getTable(new TableName(SCHEMA, "customers")).getColumn(0);
        assertNotNull (outColumn.getDefaultIdentity());
        assertTrue (outColumn.getDefaultIdentity());
        assertNotNull (outColumn.getIdentityGenerator());
        assertSame (outColumn.getIdentityGenerator(), outAIS.getSequence(sequenceName));
    }
View Full Code Here

        NewAISBuilder builder = AISBBasedBuilder.create(SCHEMA, typesTranslator());
        builder.table(TABLE).colBigInt("id");
        AkibanInformationSchema inAIS = builder.unvalidatedAIS();

        // Note: If storage* methods go away, or are non-null by default, that is *good* and these can go away
        Column inCol = inAIS.getTable(SCHEMA, TABLE).getColumn(0);
        assertNull("storedMaxStorageSize null by default", inCol.getMaxStorageSizeWithoutComputing());
        assertNull("storedPrefixSize null by default", inCol.getPrefixSizeWithoutComputing());

        AkibanInformationSchema outAIS = writeAndRead(inAIS);
        Column outCol = outAIS.getTable(SCHEMA, TABLE).getColumn(0);
        assertNull("storedMaxStorageSize null preserved", outCol.getMaxStorageSizeWithoutComputing());
        assertNull("storedPrefixSize null preserved", outCol.getPrefixSizeWithoutComputing());

        inCol.getMaxStorageSize();
        inCol.getPrefixSize();

        outAIS = writeAndRead(inAIS);
        outCol = outAIS.getTable(SCHEMA, TABLE).getColumn(0);
        assertEquals("storedMaxStorageSize", Long.valueOf(8L), outCol.getMaxStorageSizeWithoutComputing());
        assertEquals("storedPrefixSize", Integer.valueOf(0), outCol.getPrefixSizeWithoutComputing());
    }
View Full Code Here

        final String TABLE = "t";
        NewAISBuilder builder = AISBBasedBuilder.create(SCHEMA, typesTranslator());
        builder.table(TABLE).colBigInt("id");

        AkibanInformationSchema inAIS = builder.unvalidatedAIS();
        Column inCol = inAIS.getTable(SCHEMA, TABLE).getColumn("id");

        AkibanInformationSchema outAIS = writeAndRead(inAIS);
        Column outCol = outAIS.getTable(SCHEMA, TABLE).getColumn("id");
        assertEquals("default defaultValue null", inCol.getDefaultValue(), outCol.getDefaultValue());

        inCol.setDefaultValue("100");
        outAIS = writeAndRead(inAIS);
        outCol = outAIS.getTable(SCHEMA, TABLE).getColumn("id");
        assertEquals("defaultValue", inCol.getDefaultValue(), outCol.getDefaultValue());
    }
View Full Code Here

        public PhysicalResultColumn getResultColumn(ResultField field) {
            String type = String.valueOf(field.getSQLtype());
            if (field.getType() != null) {
                type = field.getType().toStringConcise(true);
            }
            Column column = field.getAIScolumn();
            if (column != null) {
                type = column.getTypeDescription();
            }
            return new TestResultColumn(field.getName(), type);
        }
View Full Code Here

        while (i.hasNext()) {
            Entry<String,JsonNode> field = i.next();
            if (field.getValue().isContainerNode()) {
                throw new InvalidChildCollectionException(field.getKey());
            } else if (field.getValue().isValueNode()) {
                Column column = getColumn (context.table, field.getKey());
                if (field.getValue().isNull()) {
                    context.allValues.put(column, null);
                } else {
                    context.allValues.put (column, field.getValue().asText());
                }
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.