use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseMetadata method deleteTableIndex.
/**
* Performs all metadata operations necessary to remove the specified index from the specified table
*
* @param tableId The id of the table to create the index
* @param indexName The identifying name of the index, not null or empty
*/
public void deleteTableIndex(final long tableId, final String indexName) {
Verify.isValidId(tableId);
Verify.isNotNullOrEmpty(indexName, "The index name is invalid");
final List<Put> puts = Lists.newArrayList();
final List<Delete> deletes = Lists.newArrayList();
// Update the table schema to remove index schema details
final TableSchema existingSchema = getSchema(tableId);
final TableSchema updatedSchema = existingSchema.schemaCopy();
updatedSchema.removeIndex(indexName);
// Delete the old index
deletes.add(generateIndexDelete(tableId, indexName));
// Write the updated table schema
puts.add(putTableSchema(tableId, updatedSchema));
performMutations(deletes, puts);
}
use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseTable method descendingIndexScanAt.
@Override
public Scanner descendingIndexScanAt(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(startRow.encode(), endRow.encode());
}
use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseTable method indexScanExact.
@Override
public Scanner indexScanExact(QueryKey key) {
final TableSchema schema = store.getSchema(tableId);
long indexId = store.getIndexId(tableId, key.getIndexName());
IndexRowKey row = IndexRowKeyBuilder.newBuilder(tableId, indexId).withQueryKey(key, schema).withSortOrder(SortOrder.Ascending).build();
// Scan is [start, end) : increment to set end to next possible row
return createScannerForRange(row.encode(), incrementRowKey(row.encode()));
}
use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseTable method ascendingIndexScanAt.
@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).withSortOrder(SortOrder.Ascending).build();
IndexRowKey endRow = IndexRowKeyBuilder.newBuilder(tableId, indexId + 1).withSortOrder(SortOrder.Ascending).build();
return createScannerForRange(startRow.encode(), endRow.encode());
}
use of com.nearinfinity.honeycomb.mysql.schema.TableSchema in project honeycomb by altamiracorp.
the class HBaseMetadataTest method testLookupColumnIdsValidTableId.
@Test
public void testLookupColumnIdsValidTableId() {
final TableSchema tableSchema = new TableSchema(COLUMN_SCHEMAS, ImmutableList.<IndexSchema>of());
hbaseMetadata.createTable(TABLE_NAME, tableSchema);
final long tableId = hbaseMetadata.getTableId(TABLE_NAME);
final Map<String, Long> tableColumns = hbaseMetadata.getColumnIds(tableId);
assertEquals(1, tableColumns.size());
assertTrue(tableColumns.containsKey(COLUMN_NAME));
}
Aggregations