use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseMetadataPropertyTest method testSchemaGet.
@Test
public void testSchemaGet() throws Exception {
long tableId;
for (String tableName : tableSchemas.keySet()) {
TableSchema expected = tableSchemas.get(tableName);
tableId = hbaseMetadata.getTableId(tableName);
TableSchema actual = hbaseMetadata.getSchema(tableId);
Assert.assertEquals(expected, actual);
}
}
use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseMetadataPropertyTest method testSchemaDeleteRemovesTable.
@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));
hbaseMetadata.deleteTable(tableName);
hbaseMetadata.getSchema(tableId);
}
use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseMetadataTest method testCreateIndex.
@Test
public void testCreateIndex() {
final TableSchema tableSchema = new TableSchema(COLUMN_SCHEMAS, ImmutableList.<IndexSchema>of());
// Create a new table with the configured details
hbaseMetadata.createTable(TABLE_NAME, tableSchema);
final long tableId = hbaseMetadata.getTableId(TABLE_NAME);
// Verify that the table schema has no indices after creation
final TableSchema schemaBefore = hbaseMetadata.getSchema(tableId);
assertNotNull(schemaBefore);
assertTrue(schemaBefore.getIndices().isEmpty());
// Add a new index to the table
hbaseMetadata.createTableIndex(tableId, new IndexSchema(INDEX_NAME, ImmutableList.<String>of(COLUMN_NAME), false));
// Verify that the table schema has been correctly updated
final TableSchema schemaAfter = hbaseMetadata.getSchema(tableId);
assertNotNull(schemaAfter);
final Collection<IndexSchema> schemaIndices = schemaAfter.getIndices();
assertEquals(1, schemaIndices.size());
final IndexSchema newIndexDetails = Iterables.find(schemaIndices, indexPredicate);
assertNotNull(newIndexDetails);
final List<String> indexColumns = newIndexDetails.getColumns();
assertEquals(1, indexColumns.size());
assertEquals(COLUMN_NAME, indexColumns.get(0));
assertEquals(false, newIndexDetails.getIsUnique());
// Verify that the new index has been stored correctly
final Map<String, Long> tableIndexInfo = hbaseMetadata.getIndexIds(tableId);
assertEquals(1, tableIndexInfo.size());
assertTrue(tableIndexInfo.containsKey(INDEX_NAME));
}
use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseMetadataTest method testLookupIndexIdsValidTableId.
@Test
public void testLookupIndexIdsValidTableId() {
final TableSchema tableSchema = new TableSchema(COLUMN_SCHEMAS, ImmutableList.of(new IndexSchema(INDEX_NAME, Lists.newArrayList(COLUMN_NAME), false)));
hbaseMetadata.createTable(TABLE_NAME, tableSchema);
final long tableId = hbaseMetadata.getTableId(TABLE_NAME);
final Map<String, Long> tableIndices = hbaseMetadata.getIndexIds(tableId);
assertEquals(1, tableIndices.size());
assertTrue(tableIndices.containsKey(INDEX_NAME));
}
use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseMetadataTest method testAutoInc.
@Test
public void testAutoInc() 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.getAutoInc(tableId), 0);
assertEquals(hbaseMetadata.incrementAutoInc(tableId, value), value);
assertEquals(hbaseMetadata.getAutoInc(tableId), value);
hbaseMetadata.setAutoInc(tableId, 13);
assertEquals(hbaseMetadata.getAutoInc(tableId), 13);
}
Aggregations