Package com.foundationdb.ais.model.aisb2

Examples of com.foundationdb.ais.model.aisb2.NewAISBuilder


    @Test
    public void dropPrimaryKeyMiddleOfGroup() {
        TableName cName = new TableName(SCHEMA, "c");
        TableName oName = new TableName(SCHEMA, "o");
        TableName iName = new TableName(SCHEMA, "i");
        NewAISBuilder builder1 = AISBBasedBuilder.create(typesTranslator);
        builder1.table(cName).colBigInt("id", false).pk("id")
                .table(oName).colBigInt("id", false).colBigInt("cid", true).pk("id").joinTo(SCHEMA, "c", "fk1").on("cid", "id")
                .table(iName).colBigInt("id", false).colBigInt("oid", true).pk("id").joinTo(SCHEMA, "o", "fk2").on("oid", "id");
        NewAISBuilder builder2 = AISBBasedBuilder.create(typesTranslator);
        builder2.table(cName).colBigInt("id", false).pk("id")
                .table(oName).colBigInt("id", false).colBigInt("cid", true).joinTo(SCHEMA, "c", "fk1").on("cid", "id")
                .table(iName).colBigInt("id", false).colBigInt("oid", true).pk("id").joinTo(SCHEMA, "o", "fk2").on("oid", "id");
        Table t1 = builder1.unvalidatedAIS().getTable(oName);
        Table t2 = builder2.unvalidatedAIS().getTable(oName);
        validate(
                t1, t2,
                asList(TableChange.createAdd(Column.ROW_ID_NAME)),
                AUTO_CHANGES,
                ChangeLevel.GROUP,
View Full Code Here


    // Group Index changes
    //

    @Test
    public void dropColumnInGroupIndex() {
        NewAISBuilder builder = AISBBasedBuilder.create(SCHEMA, typesTranslator);
        builder.table("p").colInt("id").colInt("x").pk("id")
               .table(TABLE).colInt("id").colInt("pid").colInt("y").pk("id").joinTo(SCHEMA, "p", "fk").on("pid", "id")
               .groupIndex("x_y", Index.JoinType.LEFT).on(TABLE, "y").and("p", "x");
        Table t1 = builder.unvalidatedAIS().getTable(TABLE_NAME);
        builder = AISBBasedBuilder.create(SCHEMA, typesTranslator);
        builder.table("p").colInt("id").colInt("x").pk("id")
               .table(TABLE).colInt("id").colInt("pid").pk("id").joinTo(SCHEMA, "p", "fk").on("pid", "id");
        Table t2 = builder.unvalidatedAIS().getTable(TABLE_NAME);
        final String KEY1 = Index.PRIMARY;
        final String KEY2 = "fk";
        validate(
                t1, t2,
                asList(TableChange.createDrop("y")),
View Full Code Here

    }

    @Test
    public void dropGFKFrommMiddleWithGroupIndexes() {
        TableName iName = new TableName(SCHEMA, "i");
        NewAISBuilder builder = AISBBasedBuilder.create(SCHEMA, typesTranslator);
        builder.table("p").colInt("id").colInt("x").pk("id")
               .table(TABLE).colInt("id").colInt("pid").colInt("y").pk("id").joinTo(SCHEMA, "p", "fk1").on("pid", "id")
               .table(iName).colInt("id").colInt("tid").colInt("z").pk("id").joinTo(SCHEMA, TABLE, "fk2").on("tid", "id")
               .groupIndex("x_y", Index.JoinType.LEFT).on(TABLE, "y").and("p", "x")                  // spans 2
               .groupIndex("x_y_z", Index.JoinType.LEFT).on("i", "z").and(TABLE, "y").and("p", "x"); // spans 3
        Table t1 = builder.unvalidatedAIS().getTable(TABLE_NAME);
        builder = AISBBasedBuilder.create(SCHEMA, typesTranslator);
        builder.table("p").colInt("id").colInt("x").pk("id")
                .table(TABLE).colInt("id").colInt("pid").colInt("y").pk("id").key("fk1", "pid")
                .table(iName).colInt("id").colInt("tid").colInt("z").pk("id").joinTo(SCHEMA, TABLE, "fk2").on("tid", "id");
        Table t2 = builder.unvalidatedAIS().getTable(TABLE_NAME);
        validate(
                t1, t2,
                NO_CHANGES,
                NO_CHANGES,
                ChangeLevel.GROUP,
View Full Code Here

    //

    private void fkTest(boolean isAdd) {
        TableName PARENT = new TableName(SCHEMA, "p");
        Table t1 = table(builder(PARENT).colBigInt("pid").pk("pid").table(TABLE).colBigInt("cid").colBigInt("pid").pk("cid"), TABLE_NAME);
        NewAISBuilder builder = builder(PARENT).colBigInt("pid").pk("pid").table(TABLE).colBigInt("cid").colBigInt("pid").pk("cid");
        AkibanInformationSchema ais = builder.unvalidatedAIS();
        Table t2 = ais.getTable(TABLE_NAME);
        Table p2 = ais.getTable(PARENT);
        ForeignKey.create(ais, "__fk_1", t2, asList(t2.getColumn("pid")), p2, asList(p2.getColumn("pid")), Action.RESTRICT, Action.RESTRICT, false, false);
        Table pre = isAdd ? t1 : t2;
        Table post = isAdd ? t2 : t1;
View Full Code Here

    public static final int IDENT_MAX = 128;
    public static final int PATH_MAX = 1024;

    private void registerSystemProcedures() {
        NewAISBuilder aisb = AISBBasedBuilder.create(schemaManager.getTypesTranslator());

        aisb.defaultSchema(TableName.SYS_SCHEMA);
        aisb.procedure("dump_group")
            .language("java", Routine.CallingConvention.LOADABLE_PLAN)
            .paramStringIn("schema_name", IDENT_MAX)
            .paramStringIn("table_name", IDENT_MAX)
            .paramLongIn("insert_max_row_count")
            .externalName(DumpGroupLoadablePlan.class.getCanonicalName());
        aisb.procedure("group_protobuf")
            .language("java", Routine.CallingConvention.LOADABLE_PLAN)
            .paramStringIn("schema_name", IDENT_MAX)
            .paramStringIn("table_name", IDENT_MAX)
            .externalName(GroupProtobufLoadablePlan.class.getCanonicalName());

        // Query logging
        aisb.procedure("query_log_set_enabled")
            .language("java", Routine.CallingConvention.JAVA)
            .paramBooleanIn("enabled")
            .externalName(QueryLoggingRoutines.class.getCanonicalName(), "setEnabled");
        aisb.procedure("query_log_is_enabled")
            .language("java", Routine.CallingConvention.JAVA)
            .returnBoolean("is_enabled")
            .externalName(QueryLoggingRoutines.class.getCanonicalName(), "isEnabled");
        aisb.procedure("query_log_set_file")
            .language("java", Routine.CallingConvention.JAVA)
            .paramStringIn("filename", PATH_MAX)
            .externalName(QueryLoggingRoutines.class.getCanonicalName(), "setFile");
        aisb.procedure("query_log_get_file")
            .language("java", Routine.CallingConvention.JAVA)
            .returnString("filename", PATH_MAX)
            .externalName(QueryLoggingRoutines.class.getCanonicalName(), "getFile");
        aisb.procedure("query_log_set_millis")
            .language("java", Routine.CallingConvention.JAVA)
            .paramLongIn("milliseconds")
            .externalName(QueryLoggingRoutines.class.getCanonicalName(), "setMillis");
        aisb.procedure("query_log_get_millis")
            .language("java", Routine.CallingConvention.JAVA)
            .returnLong("milliseconds")
            .externalName(QueryLoggingRoutines.class.getCanonicalName(), "getMillis");

        aisb.defaultSchema(TableName.SQLJ_SCHEMA);
        aisb.procedure("install_jar")
            .language("java", Routine.CallingConvention.JAVA)
            .paramStringIn("url", PATH_MAX)
            .paramStringIn("jar", PATH_MAX)
            .paramLongIn("deploy")
            .externalName(SQLJJarRoutines.class.getCanonicalName(), "install");
        aisb.procedure("replace_jar")
            .language("java", Routine.CallingConvention.JAVA)
            .paramStringIn("url", PATH_MAX)
            .paramStringIn("jar", PATH_MAX)
            .externalName(SQLJJarRoutines.class.getCanonicalName(), "replace");
        aisb.procedure("remove_jar")
            .language("java", Routine.CallingConvention.JAVA)
            .paramStringIn("jar", PATH_MAX)
            .paramLongIn("undeploy")
            .externalName(SQLJJarRoutines.class.getCanonicalName(), "remove");

        Collection<Routine> procs = aisb.ais().getRoutines().values();
        for (Routine proc : procs) {
            schemaManager.registerSystemRoutine(proc);
        }
    }
View Full Code Here

public class PrimaryKeyParserTest {
    private static Index createIndex(int colCount, boolean binary) {
        NewAISBuilder builder = AISBBasedBuilder.create("test",
                                                        MTypesTranslator.INSTANCE);
        String[] colNames = new String[colCount];
        NewTableBuilder table = builder.table("t");
        char colName = 'a';
        for(int i = 0; i < colCount; ++i) {
            colNames[i] = String.valueOf(colName++);
            if (binary) {
                table.colVarBinary(colNames[i], 16, false);
            }
            else {
                table.colInt(colNames[i], false);
            }
        }
        table.pk(colNames);
        return builder.ais(true).getTable("test", "t").getPrimaryKey().getIndex();
    }
View Full Code Here

    }

    public RowDataFormatTest(TableMaker tableMaker, Object[] fields, String bytesString) {
        TypesTranslator typesTranslator = MTypesTranslator.INSTANCE;
        NewAISBuilder aisBuilder = AISBBasedBuilder.create(SCHEMA, typesTranslator);
        NewTableBuilder tableBuilder = aisBuilder.table(TABLE).colInt("pkid");
        tableMaker.make(tableBuilder);
        tableBuilder.pk("pkid");
        AkibanInformationSchema ais = aisBuilder.ais();
        Table table = ais.getTable(SCHEMA, TABLE);
        table.setTableId(1);
        new SchemaFactory().buildRowDefs(ais);
        rowDef = ais.getTable(SCHEMA, TABLE).rowDef();
View Full Code Here

TOP

Related Classes of com.foundationdb.ais.model.aisb2.NewAISBuilder

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.