Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Index


    @Test(expected=IndexLacksColumnsException.class)
    public void noIndexColumns() throws InvalidOperationException {
        int tId = createTable("test", "t", "id int not null primary key, foo int");
        AkibanInformationSchema ais = createAISWithTable(tId);
        Index index = addIndex(ais, tId, "Failure", false);
        ddl().createIndexes(session(), Arrays.asList(index));
    }
View Full Code Here


    @Test(expected=ProtectedIndexException.class)
    public void createPrimaryKey() throws InvalidOperationException {
        int tId = createTable("test", "atable", "id int");
        AkibanInformationSchema ais = createAISWithTable(tId);
        Table table = ais.getTable("test", "atable");
        Index index = TableIndex.create(ais, table, "PRIMARY", 1, true, true);
        ddl().createIndexes(session(), Arrays.asList(index));
    }
View Full Code Here

   
    @Test(expected=DuplicateIndexException.class)
    public void duplicateIndexName() throws InvalidOperationException {
        int tId = createTable("test", "t", "id int not null primary key");
        AkibanInformationSchema ais = createAISWithTable(tId);
        Index index = addIndex(ais, tId, "PRIMARY", false, "id");
        ddl().createIndexes(session(), Arrays.asList(index));
    }
View Full Code Here

    @Test(expected=NoSuchColumnException.class)
    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

    @Test(expected=IllegalArgumentException.class)
    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

    @Test
    public void basicConfirmInAIS() throws InvalidOperationException {
        int tId = createTable("test", "t", "id int not null primary key, name varchar(255)");
       
        AkibanInformationSchema ais = createAISWithTable(tId);
        Index index = addIndex(ais, tId, "name", false, "name");
        ddl().createIndexes(session(), Arrays.asList(index));

        // Index should exist on the Table
        Table table = getTable("test", "t");
        assertNotNull(table);
View Full Code Here

        int tId = createTable("test", "t", "id int not null primary key, name varchar(255)");
        writeRow(tId, 1, "bob");
        writeRow(tId, 2, "jim");
       
        AkibanInformationSchema ais = createAISWithTable(tId);
        Index index = addIndex(ais, tId, "name", false, "name");
        ddl().createIndexes(session(), Arrays.asList(index));

        AkibanInformationSchema aisCheck = ais();
        Index indexCheck = aisCheck.getTable(tId).getIndex("name");
        assertNotNull(indexCheck);
        assertFalse(indexCheck.isUnique());
        assertFalse(indexCheck.isPrimaryKey());
        assertFalse(indexCheck.isConnectedToFK());
        assertEquals("Index count", 1, indexCheck.getKeyColumns().size());
       
        List<Row> rows = scanAllIndex(getTable(tId).getIndex("name"));
        assertEquals("rows from index scan", 2, rows.size());
    }
View Full Code Here

        writeRow(iId, 4, 2, "fob");
        writeRow(iId, 5, 2, "baz");
       
        // Create index on an varchar (note: in the "middle" of a group, shifts IDs after, etc)
        AkibanInformationSchema ais = createAISWithTable(oId);
        Index index = addIndex(ais, oId, "tag", false, "tag");
        ddl().createIndexes(session(), Arrays.asList(index));

        // Check that AIS was updated and DDL gets created correctly
        AkibanInformationSchema aisCheck = ais();
        Index indexCheck = aisCheck.getTable(oId).getIndex("tag");
        assertNotNull(indexCheck);
        assertFalse(indexCheck.isUnique());
        assertFalse(indexCheck.isPrimaryKey());
        assertFalse(indexCheck.isConnectedToFK());
        assertEquals("Index count", 1, indexCheck.getKeyColumns().size());
       
        // Get all customers
        List<Row> rows = scanAll(cId);
        assertEquals("customers from table scan", 1, rows.size());
        // Get all orders
View Full Code Here

        writeRow(tId, 2, "zap", "snap");
        writeRow(tId, 3, "baz", "fob");
        expectRowCount(tId, 3);
       
        AkibanInformationSchema ais = createAISWithTable(tId);
        Index index = addIndex(ais, tId, "name", false, "first", "last");
        ddl().createIndexes(session(), Arrays.asList(index));

        AkibanInformationSchema aisCheck = ais();
        Index indexCompound = aisCheck.getTable(tId).getIndex("name");
        List<IndexColumn> ids = indexCompound.getKeyColumns();
        assertEquals("column first", "first", ids.get(0).getColumn().getName());
        assertEquals("column first", "last", ids.get(1).getColumn().getName());
        assertEquals(ids.size(), 2);
            
        List<Row> rows = scanAllIndex(getTable(tId).getIndex("name"));
View Full Code Here

        writeRow(tId, 2, "WA");
        writeRow(tId, 3, "MA");
        expectRowCount(tId, 3);
       
        AkibanInformationSchema ais = createAISWithTable(tId);
        Index index = addIndex(ais, tId, "state", true, "state");
        ddl().createIndexes(session(), Arrays.asList(index));

        AkibanInformationSchema aisCheck = ais();
        Index indexCheck = aisCheck.getTable(tId).getIndex("state");
        assertNotNull(indexCheck);
        assertTrue(indexCheck.isUnique());
        assertFalse(indexCheck.isPrimaryKey());
        assertFalse(indexCheck.isConnectedToFK());
        assertEquals("column name: state", "state", indexCheck.getKeyColumns().get(0).getColumn().getName());
        assertEquals("Index count", 1, indexCheck.getKeyColumns().size());

        List<Row> rows = scanAllIndex(getTable(tId).getIndex("state"));
        assertEquals("rows from index scan", 3, rows.size());
    }
View Full Code Here

TOP

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

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.