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);
}
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));
}
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);
}
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);
}
}));
}
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());
}
Aggregations