Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Index


     * @param indexName Name of index to compare to.
     * @throws Exception On error.
     */
    private void testKeyToObjectInternal(int tableId, int expectedRowCount, String indexName) throws Exception {
        final Table table = getTable(tableId);
        final Index index = table.getIndex(indexName);
        assertNotNull("expected index named: "+indexName, index);
       
        final List<Row> allRows = scanAll(tableId);
        assertEquals("rows scanned", expectedRowCount, allRows.size());

        final Iterator<Row> rowIt = allRows.iterator();

        store().traverse(session(), index, new IndexVisitor<Key,Value>() {
            private int rowCounter = 0;

            @Override
            protected void visit(Key key, Value value) {
                if(!rowIt.hasNext()) {
                    Assert.fail("More index entries than rows: rows("+allRows+") index("+index+")");
                }

                final Row row = rowIt.next();
                key.indexTo(0);

              
                for(IndexColumn indexColumn : index.getKeyColumns()) {
                    Column column = indexColumn.getColumn();
                    int colPos = column.getPosition();
                    Object objFromRow = ValueSources.toObject(row.value(colPos));
                    PersistitKeyValueSource valueSource = new PersistitKeyValueSource(indexColumn.getColumn().getType());
                    valueSource.attach(key, indexColumn);
View Full Code Here


    }

    private static Index createSimpleIndex(Table curTable, String columnName) {
        AkibanInformationSchema ais = new AkibanInformationSchema();
        Table newTable = Table.create(ais, curTable.getName().getSchemaName(), curTable.getName().getTableName(), 0);
        Index newIndex = TableIndex.create(ais, newTable, columnName, 0, false, false);
        Column curColumn = curTable.getColumn(columnName);
        Column newColumn = Column.create(newTable,  curColumn.getName(), curColumn.getPosition(), curColumn.getType());
        IndexColumn.create(newIndex, newColumn, 0, true, null);
        return newIndex;
    }
View Full Code Here

    @Test
    public void secondaryIndexNoData() throws Exception {
        int tid = createTable("s", "t", "id int not null primary key, c char(10)");
        createIndex("s", "t", "c", "c");
        Table t = getTable(tid);
        Index c = t.getIndex("c");
        ddl().dropTable(session(), t.getName());
        expectNoTree(t);
        expectNoTree(c);
    }
View Full Code Here

        writeRows(row(tid, 1L, "abcd"),
                  row(tid, 2L, "efgh"),
                  row(tid, 3L, "ijkl"));
        Table t = getTable(tid);
        expectTree(t);
        Index c = t.getIndex("c");
        expectTree(c);
        ddl().dropTable(session(), t.getName());
        expectNoTree(t);
        expectNoTree(c);
    }
View Full Code Here

    public void addSecondaryIndexNoData() throws Exception {
        int tid = createTable("s", "t", "id int not null primary key, other int");
        Table t = getTable(tid);
        ddl().createIndexes(session(), Collections.singleton(createSimpleIndex(t, "other")));
        t = getTable(tid);
        Index other = t.getIndex("other");
        ddl().dropTable(session(), t.getName());
        expectNoTree(t);
        expectNoTree(other);
    }
View Full Code Here

        Table t = getTable(tid);
        expectTree(t);
        ddl().createIndexes(session(), Collections.singleton(createSimpleIndex(t, "other")));
        t = getTable(tid);
        expectTree(t);
        Index other = t.getIndex("other");
        expectTree(other);
        ddl().dropTable(session(), t.getName());
        expectNoTree(t);
        expectNoTree(other);
    }
View Full Code Here

    public void dropSecondaryIndexNoData() throws Exception {
        int tid = createTable("s", "t", "id int not null primary key, c char(10)");
        createIndex("s", "t", "c", "c");
        createIndex("s", "t", "c2", "c");
        Table t = getTable(tid);
        Index c = t.getIndex("c");
        ddl().dropTableIndexes(session(), t.getName(), Collections.singleton("c"));
        expectNoTree(c);
        ddl().dropTable(session(), t.getName());
        expectNoTree(t);
    }
View Full Code Here

        writeRows(row(tid, 1L, "mnop"),
                  row(tid, 2L, "qrst"),
                  row(tid, 3L, "uvwx"));
        Table t = getTable(tid);
        expectTree(t);
        Index c = t.getIndex("c");
        expectTree(c);
        ddl().dropTableIndexes(session(), t.getName(), Collections.singleton("c"));
        expectNoTree(c);
        expectTree(t);
        ddl().dropTable(session(), t.getName());
View Full Code Here

        int pid = createTable("s", "p", "id int not null primary key");
        int cid = createTable("s", "c", "id int not null primary key, i int, pid int, grouping foreign key(pid) references p(id)");
        createIndex("s", "c", "i", "i");
        Table p = getTable(pid);
        Table c = getTable(cid);
        Index i = c.getIndex("i");
        ddl().dropTable(session(), c.getName());
        expectNoTree(i);
        ddl().dropTable(session(), p.getName());
        expectNoTree(p);
    }
View Full Code Here

        expectTree(p);
        writeRows(row(cid, 10L, 100L, 1L),
                  row(cid, 20L, 100L, 2L));
        Table c = getTable(cid);
        expectTree(c);
        Index i = c.getIndex("i");
        expectTree(i);
        ddl().dropTable(session(), c.getName());
        expectNoTree(i);
        ddl().dropTable(session(), p.getName());
        expectNoTree(p);
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.