Package com.nearinfinity.honeycomb.mysql.schema

Examples of com.nearinfinity.honeycomb.mysql.schema.TableSchema


        }
    }

    @Test(expected = TableNotFoundException.class)
    public void testSchemaDeleteRemovesTable() throws Exception {
        TableSchema schema = tableSchemaGen.next();
        final String tableName = TableSchemaGenerator.MYSQL_NAME_GEN.next();
        hbaseMetadata.createTable(tableName, schema);

        long tableId = hbaseMetadata.getTableId(tableName);
        Assert.assertEquals(schema, hbaseMetadata.getSchema(tableId));
View Full Code Here


                            byte[] serializedTableSchema, long autoInc) {
        Verify.isNotNullOrEmpty(tableName);
        checkNotNull(serializedTableSchema, "Schema cannot be null");

        store = storeFactory.createStore(tableName);
        TableSchema tableSchema = TableSchema.deserialize(serializedTableSchema);
        Verify.isValidTableSchema(tableSchema);
        store.createTable(tableName, tableSchema);
        store.incrementAutoInc(tableName, autoInc);
    }
View Full Code Here

     */
    public void dropIndex(String indexName) {
        Verify.isNotNullOrEmpty(indexName, "The index name is invalid");
        checkTableOpen();

        TableSchema tableSchema = store.getSchema(tableName);
        IndexSchema indexSchema = tableSchema.getIndexSchema(indexName);
        table.deleteTableIndex(indexSchema);
        store.dropIndex(tableName, indexName);
    }
View Full Code Here

        checkNotNull(serializedRow);

        Row row = Row.deserialize(serializedRow);

        Table t = store.openTable(tableName);
        TableSchema schema = store.getSchema(tableName);
        IndexSchema indexSchema = schema.getIndexSchema(indexName);

        QueryKey key = new QueryKey(indexName, QueryType.EXACT_KEY, row.getRecords());
        Scanner scanner = t.indexScanExact(key);

        try {
View Full Code Here

        indices.add(new IndexSchema(TestConstants.INDEX2, Lists.newArrayList(TestConstants.COLUMN1, TestConstants.COLUMN2), false));

        // Add unique index on one column
        indices.add(new IndexSchema(TestConstants.INDEX3, Lists.newArrayList(TestConstants.COLUMN1), true));

        return new TableSchema(columns, indices);
    }
View Full Code Here

     * @param rowBytes Serialized row to be written
     */
    public void insertRow(byte[] rowBytes) {
        checkTableOpen();
        checkNotNull(rowBytes);
        TableSchema schema = store.getSchema(tableName);
        Row row = Row.deserialize(rowBytes);
        row.setRandomUUID();
        String auto_inc_col = schema.getAutoIncrementColumn();
        if (auto_inc_col != null) {
            ByteBuffer bb = row.getRecords().get(auto_inc_col);
            if (bb != null) {
                long auto_inc = bb.getLong();
                long next_auto_inc = auto_inc + 1;
                if (auto_inc > next_auto_inc) { // The autoincrement will wrap around. MySQL says don't wrap.
                    next_auto_inc = auto_inc;
                }
                bb.rewind();
                store.setAutoInc(tableName, next_auto_inc);
            }
        }

        table.insertRow(row);
        if (schema.hasUniqueIndices()) {
            table.flush();
        }
    }
View Full Code Here

    public void updateRow(byte[] oldRowBytes, byte[] rowBytes) {
        checkTableOpen();
        checkNotNull(rowBytes);
        Row updatedRow = Row.deserialize(rowBytes);
        TableSchema schema = store.getSchema(tableName);
        Row oldRow = Row.deserialize(oldRowBytes);
        oldRow.setUUID(updatedRow.getUUID());
        ImmutableList<IndexSchema> changedIndices = Util.getChangedIndices(schema.getIndices(), oldRow.getRecords(), updatedRow.getRecords());
        table.updateRow(oldRow, updatedRow, changedIndices);
        if (schema.hasUniqueIndices()) {
            table.flush();
        }
    }
View Full Code Here

    @Override
    protected TableSchema getTableSchema() {
        final List<ColumnSchema> columns = Lists.newArrayList();
        columns.add(ColumnSchema.builder("test", ColumnType.LONG).setIsAutoIncrement(true).build());
        return new TableSchema(columns, ImmutableList.<IndexSchema>of());
    }
View Full Code Here

        return createScannerForRange(startRow.encode(), endRow.encode());
    }

    @Override
    public Scanner ascendingIndexScanAt(QueryKey key) {
        final TableSchema schema = store.getSchema(tableId);
        long indexId = store.getIndexId(tableId, key.getIndexName());

        IndexRowKey startRow = IndexRowKeyBuilder
                .newBuilder(tableId, indexId)
                .withQueryKey(key, schema)
View Full Code Here

        return createScannerForRange(startRow.encode(), endRow.encode());
    }

    @Override
    public Scanner ascendingIndexScanAfter(QueryKey key) {
        final TableSchema schema = store.getSchema(tableId);
        long indexId = store.getIndexId(tableId, key.getIndexName());

        IndexRowKey startRow = IndexRowKeyBuilder
                .newBuilder(tableId, indexId)
                .withQueryKey(key, schema)
View Full Code Here

TOP

Related Classes of com.nearinfinity.honeycomb.mysql.schema.TableSchema

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.