Package com.foundationdb.ais.model.aisb2

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


        this.constraintHandler = new PersistitConstraintHandler(this, config, typesRegistryService, serviceManager, (PersistitTransactionService)txnService);
        this.onlineHelper = new OnlineHelper(txnService, schemaManager, this, typesRegistryService, constraintHandler, withConcurrentDML);
        listenerService.registerRowListener(onlineHelper);

        // System routine
        NewAISBuilder aisb = AISBBasedBuilder.create(schemaManager.getTypesTranslator());
        aisb.procedure(TableName.SYS_SCHEMA, "persistitcli")
            .language("java", Routine.CallingConvention.LOADABLE_PLAN)
            .paramStringIn("command", 1024)
            .externalName(PersistitCLILoadablePlan.class.getCanonicalName());
        for(Routine proc : aisb.ais().getRoutines().values()) {
            schemaManager.registerSystemRoutine(proc);
        }
    }
View Full Code Here


    private abstract class MemTableBase extends BasicFactoryBase {

        protected abstract void buildTable(NewTableBuilder builder);

        public Table table(TypesTranslator typesTranslator) {
            NewAISBuilder builder = AISBBasedBuilder.create(typesTranslator);
            buildTable(builder.table(getName()));
            return builder.ais(false).getTable(getName());
        }
View Full Code Here

import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;

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 final static String ITEM_TABLE = "item";
    public final static String COMPONENT_TABLE = "component";

    public static NewAISBuilder createAndFillBuilder(String schema) {
        TypesTranslator typesTranslator = MTypesTranslator.INSTANCE;
        NewAISBuilder builder = AISBBasedBuilder.create(schema, typesTranslator);

        builder.table(CUSTOMER_TABLE).
                colBigInt("customer_id", false).
                colString("customer_name", 100, false).
                pk("customer_id");

        builder.table(ADDRESS_TABLE).
                colBigInt("customer_id", false).
                colInt("instance_id", false).
                colString("address_line1", 60, false).
                colString("address_line2", 60, false).
                colString("address_line3", 60, false).
                pk("customer_id", "instance_id").
                joinTo("customer").on("customer_id", "customer_id");

        builder.table(ORDER_TABLE).
                colBigInt("order_id", false).
                colBigInt("customer_id", false).
                colInt("order_date", false).
                pk("order_id").
                joinTo("customer").on("customer_id", "customer_id");

        builder.table(ITEM_TABLE).
                colBigInt("order_id", false).
                colBigInt("part_id", false).
                colInt("quantity", false).
                colInt("unit_price", false).
                pk("part_id").
                joinTo("order").on("order_id", "order_id");

        builder.table(COMPONENT_TABLE).
                colBigInt("part_id", false).
                colBigInt("component_id", false).
                colInt("supplier_id", false).
                colInt("unique_id", false).
                colString("description", 50, true).
View Full Code Here

        compareAndAssert(inAIS, outAIS, false);
    }
   
    @Test
    public void caoiWithGroupIndex() {
        NewAISBuilder builder = CAOIBuilderFiller.createAndFillBuilder(SCHEMA);
        builder.groupIndex("iprice_odate", Index.JoinType.RIGHT).
                on(CAOIBuilderFiller.ITEM_TABLE, "unit_price").
                and(CAOIBuilderFiller.ORDER_TABLE, "order_date");
       
        final AkibanInformationSchema inAIS = builder.ais();
        final AkibanInformationSchema outAIS = writeAndRead(inAIS);
        compareAndAssert(inAIS, outAIS, false);
    }
View Full Code Here

        compareAndAssert(inAIS, outAIS, false);
    }

    @Test
    public void caoiWithView() {
        NewAISBuilder builder = CAOIBuilderFiller.createAndFillBuilder(SCHEMA);
        builder.view("recent_orders").
            definition("CREATE VIEW recent_order AS SELECT * FROM order WHERE order_date > CURRENT_DATE - INTERVAL '30' DAY").
            references(CAOIBuilderFiller.ORDER_TABLE).
            colBigInt("order_id", false).
            colBigInt("customer_id", false).
                colInt("order_date", false);
        final AkibanInformationSchema inAIS = builder.ais();
        final AkibanInformationSchema outAIS = writeAndRead(inAIS);
        compareAndAssert(inAIS, outAIS, false);
    }
View Full Code Here

    public void writeWithRestrictedSchema() {
        final String SCHEMA1 = "test1";
        final String TABLE1 = "t1";
        final String SCHEMA2 = "test2";
        final String TABLE2 = "t2";
        NewAISBuilder builder = AISBBasedBuilder.create(typesTranslator());
        builder.table(SCHEMA1, TABLE1).colInt("id", false).colString("v", 250).pk("id");
        builder.table(SCHEMA2, TABLE2).colInt("tid", false).pk("tid");
        AkibanInformationSchema inAIS = builder.ais();
        AkibanInformationSchema outAIS1 = writeAndRead(inAIS, SCHEMA1);
        assertEquals("Serialized AIS has just schema 1", "[" + SCHEMA1 + "]", outAIS1.getSchemas().keySet().toString());
        AkibanInformationSchema outAIS2 = writeAndRead(inAIS, SCHEMA2);
        assertEquals("Serialized AIS has just schema 2", "[" + SCHEMA2 + "]", outAIS2.getSchemas().keySet().toString());
    }
View Full Code Here

    }

    @Test
    public void loadMultipleBuffers() {
        final int COUNT = 3;
        NewAISBuilder builder = AISBBasedBuilder.create(typesTranslator());
        builder.table(SCHEMA+0, "t0").colInt("id", false).pk("id");
        builder.table(SCHEMA+1, "t1").colBigInt("bid", false).colString("v", 32).pk("bid");
        builder.table(SCHEMA+2, "t2").colDouble("d").colInt("l").key("d_idx", "d");
        AkibanInformationSchema inAIS = builder.ais();


        ByteBuffer bbs[] = new ByteBuffer[COUNT];
        for(int i = 0; i < COUNT; ++i) {
            bbs[i] = createByteBuffer();
View Full Code Here

    @Test
    public void groupAndIndexTreeNames() {
        final String GROUP_TREENAME = "foo";
        final String PARENT_PK_TREENAME = "bar";
        final String GROUP_INDEX_TREENAME = "zap";
        NewAISBuilder builder = AISBBasedBuilder.create(SCHEMA, typesTranslator());
        builder.table("parent").colInt("pid", false).colString("v", 32).pk("pid").key("v", "v");
        builder.table("child").colInt("cid", false).colInt("pid").pk("pid").joinTo("parent").on("pid", "pid");
        builder.groupIndex("v_cid", Index.JoinType.LEFT).on("parent", "v").and("child", "cid");

        AkibanInformationSchema inAIS = builder.ais();
        Table inParent = inAIS.getTable(SCHEMA, "parent");
        inParent.getGroup().setStorageDescription(new TestStorageDescription(inParent.getGroup(), GROUP_TREENAME, identifier));
        inParent.getGroup().getIndex("v_cid").setStorageDescription(new TestStorageDescription(inParent.getGroup().getIndex("v_cid"), GROUP_INDEX_TREENAME, identifier));
        inParent.getIndex("PRIMARY").setStorageDescription(new TestStorageDescription(inParent.getIndex("PRIMARY"), PARENT_PK_TREENAME, identifier));
View Full Code Here

    }

    @Test
    public void tableVersionNumber() {
        final String TABLE = "t1";
        NewAISBuilder builder = AISBBasedBuilder.create(SCHEMA, typesTranslator());
        builder.table(TABLE).colInt("pid", false).pk("pid");

        AkibanInformationSchema inAIS = builder.ais();
        AkibanInformationSchema outAIS = writeAndRead(inAIS);
        assertSame("Table without version", null, outAIS.getTable(SCHEMA, TABLE).getVersion());

        final Integer VERSION = 5;
        inAIS.getTable(SCHEMA, TABLE).setVersion(VERSION);
View Full Code Here

TOP

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

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.