Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Index


        writeRow(tId, 2, "WA");
        writeRow(tId, 3, "MA");
        writeRow(tId, 4, "IA");

        AkibanInformationSchema ais = createAISWithTable(tId);
        Index index = addIndex(ais, tId, "state", true, "state");

        try {
            ddl().createIndexes(session(), Arrays.asList(index));
            Assert.fail("DuplicateKeyException expected!");
        } catch(DuplicateKeyException e) {
View Full Code Here


        writeRow(tId, 2, 5000, "10.50");
        writeRow(tId, 3, 47000, "9.99");
        expectRowCount(tId, 3);
       
        AkibanInformationSchema ais = createAISWithTable(tId);
        Index index1 = addIndex(ais, tId, "otherId", true, "otherId");
        Index index2 = addIndex(ais, tId, "price", false, "price");
        ddl().createIndexes(session(), Arrays.asList(index1, index2));

        AkibanInformationSchema aisCheck = ais();
        Index indexCheck = aisCheck.getTable(tId).getIndex("otherId");
        assertNotNull(indexCheck);
        assertTrue(indexCheck.isUnique());
        assertFalse(indexCheck.isPrimaryKey());
        assertFalse(indexCheck.isConnectedToFK());
        assertEquals("column name: otherId", "otherId", indexCheck.getKeyColumns().get(0).getColumn().getName());
        assertEquals("Index count", 1, indexCheck.getKeyColumns().size());
       
        Index indexCheck2 = aisCheck.getTable(tId).getIndex("price");
        assertNotNull(indexCheck2);
        assertFalse(indexCheck2.isUnique());
        assertFalse(indexCheck2.isPrimaryKey());
        assertFalse(indexCheck2.isConnectedToFK());
        assertEquals("column name: price", "price", indexCheck2.getKeyColumns().get(0).getColumn().getName());
        assertEquals("Index count", 1, indexCheck2.getKeyColumns().size());
       
        List<Row> rows = scanAllIndex(getTable(tId).getIndex("otherId"));
        assertEquals("rows from index scan", 3, rows.size());

        rows = scanAllIndex(getTable(tId).getIndex("price"));
View Full Code Here

        writeRow(tId, 2, 20, 5000, "10.50");
        writeRow(tId, 3, 30, 47000, "9.99");
        writeRow(tId, 4, 40, 47000, "9.99");

        AkibanInformationSchema ais = createAISWithTable(tId);
        Index index1 = addIndex(ais, tId, "otherId", true, "i2");
        Index index2 = addIndex(ais, tId, "price", false, "price");

        try {
            ddl().createIndexes(session(), Arrays.asList(index1, index2));
            Assert.fail("DuplicateKeyException expected!");
        } catch(DuplicateKeyException e) {
View Full Code Here

        writeRow(tid, 1, 42);
        writeRow(tid, 2, 43);
        writeRow(uid, 1, 44);
       
        AkibanInformationSchema ais = createAISWithTable(tid, uid);
        Index index1 = addIndex(ais, tid, "foo", false, "foo");
        Index index2 = addIndex(ais, uid, "bar", false, "bar");
        ddl().createIndexes(session(), Arrays.asList(index1, index2));

        AkibanInformationSchema aisCheck = ais();
        Index tidIndex = aisCheck.getTable(tid).getIndex("foo");
        Index uidIndex = aisCheck.getTable(uid).getIndex("bar");
        assertNotNull(tidIndex);
        assertTrue(tidIndex.isTableIndex());
        assertFalse(tidIndex.isUnique());
        assertNotNull(uidIndex);
        assertTrue(uidIndex.isTableIndex());
        assertFalse(uidIndex.isUnique());
       
        List<Row> rows = scanAllIndex(getTable(tid).getIndex("foo"));
        assertEquals("t rows from index scan", 2, rows.size());
       
        rows = scanAllIndex(getTable(uid).getIndex("bar"));
View Full Code Here

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

    @Test
    public void twoIndexesAtOnceCheckIDs() throws InvalidOperationException {
        int tId = createTable("test", "t", "id int not null primary key, foo int, bar int");
        AkibanInformationSchema ais = createAISWithTable(tId);
        Index index1 = addIndex(ais, tId, "foo", false, "foo");
        Index index2 = addIndex(ais, tId, "bar", false, "bar");
        ddl().createIndexes(session(), Arrays.asList(index1, index2));
        checkIndexIDsInGroup(getTable(tId).getGroup());
    }
View Full Code Here

    @Test
    public void twoIndexSeparatelyCheckIDs() throws InvalidOperationException {
        int tId = createTable("test", "t", "id int not null primary key, foo int, bar int");
        final AkibanInformationSchema ais = createAISWithTable(tId);
        Index index = addIndex(ais, tId, "foo", false, "foo");
        ddl().createIndexes(session(), Arrays.asList(index));
        checkIndexIDsInGroup(getTable(tId).getGroup());

        Index index2 = addIndex(ais, tId, "bar", false, "bar");
        ddl().createIndexes(session(), Arrays.asList(index2));
        checkIndexIDsInGroup(getTable(tId).getGroup());
    }
View Full Code Here

    protected static final String TABLE = "frosty";

    @Test
    public void oldKeysAreRemoved_1Row() throws InvalidOperationException {
        int tableId = table();
        Index index = nameIndex();
        runTest(
                tableId,
                Arrays.asList(
                        row(tableId, 2, "c")
                ),
View Full Code Here

    }

    @Test
    public void oldKeysAreRemoved_2Rows_Partial_IndexChanged() throws InvalidOperationException {
        int tableId = table();
        Index index = nameIndex();
        runTest(
                tableId,
                Arrays.asList(
                        row(tableId, 1, "b"),
                        row(tableId, 2, "c")
View Full Code Here

    }

    @Test
    public void oldKeysAreRemoved_2Rows_IndexChanged() throws InvalidOperationException {
        int tableId = table();
        Index index = nameIndex();
        runTest(
                tableId,
                Arrays.asList(
                        row(tableId, 1, "b"),
                        row(tableId, 2, "c")
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.