Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Group


    public void testGroup() throws Exception {
        AkibanInformationSchema ais = ais(
          "CREATE TABLE c(cid INT PRIMARY KEY NOT NULL, name VARCHAR(128));" +
          "CREATE TABLE o(oid INT PRIMARY KEY NOT NULL, cid INT, GROUPING FOREIGN KEY(cid) REFERENCES c(cid));" +
          "CREATE TABLE i(iid INT PRIMARY KEY NOT NULL, oid INT, GROUPING FOREIGN KEY(oid) REFERENCES o(oid), sku VARCHAR(16));");
        Group coi = ais.getGroup(new TableName(SCHEMA, "c"));
        RowDef cRowDef = ais.getTable(new TableName(SCHEMA, "c")).rowDef();
        RowDef oRowDef = ais.getTable(new TableName(SCHEMA, "o")).rowDef();
        RowDef iRowDef = ais.getTable(new TableName(SCHEMA, "i")).rowDef();
        ProtobufRowDataConverter converter = converter(coi);
        encodeDecode(ais, converter, cRowDef,
View Full Code Here


    @Test
    public void testDecimal() throws Exception {
        AkibanInformationSchema ais = ais(
          "CREATE TABLE t(id INT PRIMARY KEY NOT NULL, n1 DECIMAL(6,2), n2 DECIMAL(20,10))");
        Group g = ais.getGroup(new TableName(SCHEMA, "t"));
        RowDef tRowDef = g.getRoot().rowDef();
        ProtobufRowDataConverter converter = converter(g);
        encodeDecode(ais, converter, tRowDef,
                     1L, new BigDecimal("3.14"), new BigDecimal("1234567890.0987654321"));
    }
View Full Code Here

    @Test
    public void testNulls() throws Exception {
        AkibanInformationSchema ais = ais(
          "CREATE TABLE t(id INT PRIMARY KEY NOT NULL, s VARCHAR(128) DEFAULT 'abc')");
        Group g = ais.getGroup(new TableName(SCHEMA, "t"));
        RowDef tRowDef = g.getRoot().rowDef();
        ProtobufRowDataConverter converter = converter(g);
        encodeDecode(ais, converter, tRowDef,
                     1L, "Barney");
        encodeDecode(ais, converter, tRowDef,
                     2L, null);
View Full Code Here

    protected Plan buildPlan(ForeignKey foreignKey, List<Column> crossReferencedColumns,
                             boolean hasOldRow, boolean hasNewRow) {
        Plan plan = new Plan();
        plan.ncols = crossReferencedColumns.size();
        Group group = foreignKey.getReferencingTable().getGroup();
        plan.schema = SchemaCache.globalSchema(group.getAIS());
        TableRowType tableRowType = plan.schema.tableRowType(foreignKey.getReferencingTable());
        Operator input;
        if (hasOldRow) {
            // referencing WHERE fk = $1 AND...
            plan.bindOldRow = true;
View Full Code Here

            .table("order").colInt("oid").colInt("c2").colInt("c_id").pk("oid", "c2").key("c_id", "c_id").joinTo("customer").on("c_id", "cid")
            .table("item").colInt("iid").colInt("o_id").colInt("o_c2").key("o_id", "o_id", "o_c2").joinTo("order").on("o_id", "oid").and("o_c2", "c2")
            .table("address").colInt("aid").colInt("c_id").key("c_id", "c_id").joinTo("customer").on("c_id", "cid")
            .ais();

        Group cGroup = ais.getGroup(new TableName("sch", "customer"));
        Table cTable = ais.getTable("sch", "customer");
        Table aTable = ais.getTable("sch", "address");
        Table oTable = ais.getTable("sch", "order");
        Table iTable = ais.getTable("sch", "item");

        assertNotNull("customer group", cGroup);
        assertEquals("customer group root", cGroup.getRoot(), cTable);

        assertEquals("address parent", cTable, aTable.getParentJoin().getParent());
        assertEquals("address join", "[JoinColumn(c_id -> cid)]", aTable.getParentJoin().getJoinColumns().toString());

        assertEquals("order parent", cTable, oTable.getParentJoin().getParent());
View Full Code Here

                        .table("address").colInt("aid").colInt("c_id").key("c_id", "c_id").joinTo("customer").on("c_id", "cid")
                .groupIndex("name_c2", Index.JoinType.LEFT).on("customer", "name").and("order", "c2")
                .groupIndex("iid_name_c2", Index.JoinType.LEFT).on("item", "iid").and("customer", "name").and("order", "c2")
                        .ais();

        Group cGroup = ais.getGroup(new TableName("sch", "customer"));
        Table cTable = ais.getTable("sch", "customer");
        Table aTable = ais.getTable("sch", "address");
        Table oTable = ais.getTable("sch", "order");
        Table iTable = ais.getTable("sch", "item");

        assertNotNull("customer group", cGroup);
        assertEquals("customer group root", cGroup.getRoot(), cTable);

        assertEquals("address parent", cTable, aTable.getParentJoin().getParent());
        assertEquals("address join", "[JoinColumn(c_id -> cid)]", aTable.getParentJoin().getJoinColumns().toString());

        assertEquals("order parent", cTable, oTable.getParentJoin().getParent());
View Full Code Here

       
        assertNull (table1.getIndex("test4"));
        assertNull (table2.getIndex("test4"));
       
        assertEquals (table1.getGroup().getName(), table2.getGroup().getName());
        Group group = table1.getGroup();

        assertNotNull (group.getIndex("test4"));
        assertFalse   (group.getIndex("test4").isUnique());
        assertEquals  (JoinType.LEFT, group.getIndex("test4").getJoinType());
        assertEquals  (2, group.getIndex("test4").getKeyColumns().size());
        assertEquals  ("c1", group.getIndex("test4").getKeyColumns().get(0).getColumn().getName());
        assertEquals  ("c1", group.getIndex("test4").getKeyColumns().get(0).getColumn().getName());
       
    }
View Full Code Here

       
        assertNull (table1.getIndex("test4"));
        assertNull (table2.getIndex("test4"));
       
        assertEquals (table1.getGroup().getName(), table2.getGroup().getName());
        Group group = table1.getGroup();

        assertNotNull (group.getIndex("test4"));
        assertEquals  (JoinType.RIGHT, group.getIndex("test4").getJoinType());
        assertFalse   (group.getIndex("test4").isUnique());
        assertEquals  (2, group.getIndex("test4").getKeyColumns().size());
        assertEquals  ("c1", group.getIndex("test4").getKeyColumns().get(0).getColumn().getName());
        assertEquals  ("c1", group.getIndex("test4").getKeyColumns().get(0).getColumn().getName());
       
    }
View Full Code Here

       
        String sql1 = "DROP INDEX test16";
        executeDDL(sql1);
        Table table1 = ais().getTable("test", "t1");
        assertNotNull (table1);
        Group group = table1.getGroup();
        assertNotNull (group);
        assertNull (group.getIndex("test16"));
    }
View Full Code Here

    private static Collection<GroupIndex> findGroupIndexesToBuild(ChangeSet changeSet, Table newTable) {
        if(changeSet == null) {
            return Collections.emptyList();
        }
        List<GroupIndex> groupIndexes = new ArrayList<>();
        Group group = newTable.getGroup();
        for(IndexChange ic : changeSet.getIndexChangeList()) {
            if(IndexType.GROUP.name().equals(ic.getIndexType())) {
                switch(ChangeType.valueOf(ic.getChange().getChangeType())) {
                    case ADD:
                    case MODIFY:
                        GroupIndex index = group.getIndex(ic.getChange().getNewName());
                        assert index != null : ic;
                        groupIndexes.add(index);
                        break;
                }
            }
View Full Code Here

TOP

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

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.