Search in sources :

Example 11 with TableSchema

use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.

the class MySqlBugIT method getTableSchema.

/**
     * Provides the {@link com.nearinfinity.honeycomb.mysql.schema.TableSchema} to use for a test case
     *
     * @return The schema used for testing
     */
@Override
protected TableSchema getTableSchema() {
    final List<ColumnSchema> columns = Lists.newArrayList();
    final List<IndexSchema> indices = Lists.newArrayList();
    // Add nullable, non-autoincrementing columns
    columns.add(ColumnSchema.builder(TestConstants.COLUMN1, ColumnType.LONG).build());
    columns.add(ColumnSchema.builder(TestConstants.COLUMN2, ColumnType.LONG).build());
    // Add non-unique index on one column
    indices.add(new IndexSchema(TestConstants.INDEX1, Lists.newArrayList(TestConstants.COLUMN1), false));
    // Add non-unique compound index on (c1, c2)
    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);
}
Also used : TableSchema(com.nearinfinity.honeycomb.mysql.schema.TableSchema) ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema) IndexSchema(com.nearinfinity.honeycomb.mysql.schema.IndexSchema)

Example 12 with TableSchema

use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.

the class HBaseMetadataTest method testLookupTableIdValidTableName.

@Test
public void testLookupTableIdValidTableName() {
    final TableSchema schema = TABLE_SCHEMA_GEN.next();
    final String tableName = TableSchemaGenerator.MYSQL_NAME_GEN.next();
    hbaseMetadata.createTable(tableName, schema);
    assertEquals(1, hbaseMetadata.getTableId(tableName));
}
Also used : TableSchema(com.nearinfinity.honeycomb.mysql.schema.TableSchema) Test(org.junit.Test)

Example 13 with TableSchema

use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.

the class HBaseMetadataTest method testRowCount.

@Test
public void testRowCount() throws Exception {
    TableSchema table = TABLE_SCHEMA_GEN.next();
    final String tableName = TableSchemaGenerator.MYSQL_NAME_GEN.next();
    hbaseMetadata.createTable(tableName, table);
    long tableId = hbaseMetadata.getTableId(tableName);
    long value = LONG_GEN.next();
    assertEquals(hbaseMetadata.getRowCount(tableId), 0);
    assertEquals(hbaseMetadata.incrementRowCount(tableId, value), value);
    assertEquals(hbaseMetadata.getRowCount(tableId), value);
    hbaseMetadata.truncateRowCount(tableId);
    assertEquals(hbaseMetadata.getRowCount(tableId), 0);
}
Also used : TableSchema(com.nearinfinity.honeycomb.mysql.schema.TableSchema) Test(org.junit.Test)

Example 14 with TableSchema

use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.

the class HBaseMetadataTest method testLookupTableSchemaValidTableId.

@Test
public void testLookupTableSchemaValidTableId() {
    final TableSchema tableSchema = new TableSchema(COLUMN_SCHEMAS, ImmutableList.<IndexSchema>of());
    hbaseMetadata.createTable(TABLE_NAME, tableSchema);
    final long tableId = hbaseMetadata.getTableId(TABLE_NAME);
    final TableSchema schemaTwo = hbaseMetadata.getSchema(tableId);
    assertEquals(1, schemaTwo.getColumns().size());
    assertTrue(Iterables.any(schemaTwo.getColumns(), new Predicate<ColumnSchema>() {

        @Override
        public boolean apply(ColumnSchema input) {
            return input.getColumnName().equals(COLUMN_NAME);
        }
    }));
}
Also used : TableSchema(com.nearinfinity.honeycomb.mysql.schema.TableSchema) ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema) Predicate(com.google.common.base.Predicate) Test(org.junit.Test)

Example 15 with TableSchema

use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.

the class TableSchemaGenerator method next.

@Override
public TableSchema next() {
    final List<ColumnSchema> columnSchemas = COLUMNS_GEN.next();
    ImmutableList.Builder<String> columns = ImmutableList.builder();
    for (ColumnSchema columnSchema : columnSchemas) {
        columns.add(columnSchema.getColumnName());
    }
    final Generator<List<IndexSchema>> indexGen = CombinedGenerators.lists(new IndexSchemaGenerator(columns.build()), numIndicesGen);
    return new TableSchema(columnSchemas, indexGen.next());
}
Also used : TableSchema(com.nearinfinity.honeycomb.mysql.schema.TableSchema) ImmutableList(com.google.common.collect.ImmutableList) ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList)

Aggregations

TableSchema (com.nearinfinity.honeycomb.mysql.schema.TableSchema)34 Test (org.junit.Test)17 IndexSchema (com.nearinfinity.honeycomb.mysql.schema.IndexSchema)12 ColumnSchema (com.nearinfinity.honeycomb.mysql.schema.ColumnSchema)9 IndexRowKey (com.nearinfinity.honeycomb.hbase.rowkey.IndexRowKey)5 AvroTableSchema (com.nearinfinity.honeycomb.mysql.gen.AvroTableSchema)5 Predicate (com.google.common.base.Predicate)1 ImmutableList (com.google.common.collect.ImmutableList)1 UnsignedBytes (com.google.common.primitives.UnsignedBytes)1 MockHTable (com.nearinfinity.honeycomb.MockHTable)1 Scanner (com.nearinfinity.honeycomb.Scanner)1 Table (com.nearinfinity.honeycomb.Table)1 IndexRowKeyBuilder (com.nearinfinity.honeycomb.hbase.rowkey.IndexRowKeyBuilder)1 RowKey (com.nearinfinity.honeycomb.hbase.rowkey.RowKey)1 HandlerProxy (com.nearinfinity.honeycomb.mysql.HandlerProxy)1 Row (com.nearinfinity.honeycomb.mysql.Row)1 HoneycombIntegrationTest (integrationtests.HoneycombIntegrationTest)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1