Search in sources :

Example 21 with TableSchema

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);
}
Also used : TableSchema(com.nearinfinity.honeycomb.mysql.schema.TableSchema)

Example 22 with TableSchema

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());
}
Also used : IndexRowKey(com.nearinfinity.honeycomb.hbase.rowkey.IndexRowKey) TableSchema(com.nearinfinity.honeycomb.mysql.schema.TableSchema)

Example 23 with TableSchema

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()));
}
Also used : IndexRowKey(com.nearinfinity.honeycomb.hbase.rowkey.IndexRowKey) TableSchema(com.nearinfinity.honeycomb.mysql.schema.TableSchema)

Example 24 with TableSchema

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());
}
Also used : IndexRowKey(com.nearinfinity.honeycomb.hbase.rowkey.IndexRowKey) TableSchema(com.nearinfinity.honeycomb.mysql.schema.TableSchema)

Example 25 with TableSchema

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));
}
Also used : TableSchema(com.nearinfinity.honeycomb.mysql.schema.TableSchema) Test(org.junit.Test)

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