@Test(expected = NullPointerException.class) public void testRemoveIndexUnknownIndexName() { tableSchema.removeIndex(UNKNOWN_INDEX); }
@Test(expected = IllegalArgumentException.class) public void testRemoveIndexEmptyIndexName() { tableSchema.removeIndex(""); }
@Test(expected = NullPointerException.class) public void testRemoveIndexInvalidIndexName() { tableSchema.removeIndex(null); }
/** * 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); }
@Test public void testRemoveIndexValidIndexName() { final TableSchema schema = new TableSchema(COLUMNS, INDICES); assertEquals(INDICES.size(), schema.getIndices().size()); // Remove all of the indexes from the schema for(final IndexSchema indexSchema : INDICES ) { schema.removeIndex(indexSchema.getIndexName()); } assertEquals(0, schema.getIndices().size()); }