use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class MutationFactory method doToIndices.
private void doToIndices(long tableId, final Row row, final Collection<IndexSchema> indices, final IndexAction action) {
for (IndexSchema index : indices) {
long indexId = store.getIndexId(tableId, index.getIndexName());
TableSchema schema = store.getSchema(tableId);
IndexRowKeyBuilder builder = IndexRowKeyBuilder.newBuilder(tableId, indexId).withUUID(row.getUUID()).withRow(row, index.getIndexName(), schema);
action.execute(builder);
}
}
use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseMetadata method createTableIndex.
/**
* Performs all metadata operations necessary to create a table index
*
* @param tableId The id of the table to create the index
* @param indexSchema The {@link com.nearinfinity.honeycomb.mysql.schema.IndexSchema} representing the index details, not null
*/
public void createTableIndex(final long tableId, final IndexSchema indexSchema) {
Verify.isValidId(tableId);
checkNotNull(indexSchema, "The index schema is invalid");
final List<Put> puts = Lists.newArrayList();
final List<IndexSchema> indexDetailMap = ImmutableList.of(indexSchema);
// Update the table schema to store the new index schema details
final TableSchema existingSchema = getSchema(tableId);
final TableSchema updatedSchema = existingSchema.schemaCopy();
updatedSchema.addIndices(indexDetailMap);
// Write the updated table schema and created index
puts.add(putTableSchema(tableId, updatedSchema));
puts.add(putIndices(tableId, indexDetailMap));
performMutations(ImmutableList.<Delete>of(), puts);
}
use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseTable method ascendingIndexScanAfter.
@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).withSortOrder(SortOrder.Ascending).build();
IndexRowKey endRow = IndexRowKeyBuilder.newBuilder(tableId, indexId + 1).withSortOrder(SortOrder.Ascending).build();
return createScannerForRange(incrementRowKey(startRow.encode()), endRow.encode());
}
use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseTable method descendingIndexScanBefore.
@Override
public Scanner descendingIndexScanBefore(QueryKey key) {
final TableSchema schema = store.getSchema(tableId);
long indexId = store.getIndexId(tableId, key.getIndexName());
IndexRowKey startRow = IndexRowKeyBuilder.newBuilder(tableId, indexId).withQueryKey(key, schema).withSortOrder(SortOrder.Descending).build();
IndexRowKey endRow = IndexRowKeyBuilder.newBuilder(tableId, indexId + 1).withSortOrder(SortOrder.Descending).build();
return createScannerForRange(incrementRowKey(startRow.encode()), endRow.encode());
}
use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseMetadataPropertyTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
provider = mock(HTableProvider.class);
when(provider.get()).thenReturn(table);
hbaseMetadata = new HBaseMetadata(provider);
hbaseMetadata.setColumnFamily("nic");
for (int i = 0; i < 20; i++) {
TableSchema schema = tableSchemaGen.next();
final String tableName = TableSchemaGenerator.MYSQL_NAME_GEN.next();
tableSchemas.put(tableName, schema);
hbaseMetadata.createTable(tableName, schema);
}
}
Aggregations