@Test(groups = "unit") public void should_create_index() throws Exception { // Given //When SchemaStatement statement = createIndex("myIndex").ifNotExists().onTable("ks", "test").andColumn("col"); // Then assertThat(statement.getQueryString()) .isEqualTo("\n\tCREATE INDEX IF NOT EXISTS myIndex ON ks.test(col)"); }
@Test(groups = "unit") public void should_create_index_on_keys_of_map_column() throws Exception { // Given //When SchemaStatement statement = createIndex("myIndex").ifNotExists().onTable("ks", "test").andKeysOfColumn("col"); // Then assertThat(statement.getQueryString()) .isEqualTo("\n\tCREATE INDEX IF NOT EXISTS myIndex ON ks.test(KEYS(col))"); } }
protected void createIndex(CassandraSessionPool.Session session, String indexLabel, HugeKeys column) { String indexName = joinTableName(this.table(), indexLabel); SchemaStatement index = SchemaBuilder.createIndex(indexName) .ifNotExists() .onTable(this.table()) .andColumn(formatKey(column)); LOG.debug("Create index: {}", index); session.execute(index); }
@Test(groups = "unit") public void should_create_index() throws Exception { // Given //When SchemaStatement statement = createIndex("myIndex").ifNotExists().onTable("ks", "test").andColumn("col"); // Then assertThat(statement.getQueryString()) .isEqualTo("\n\tCREATE INDEX IF NOT EXISTS myIndex ON ks.test(col)"); }
@Test(groups = "unit") public void should_create_index_on_keys_of_map_column() throws Exception { // Given //When SchemaStatement statement = createIndex("myIndex").ifNotExists().onTable("ks", "test").andKeysOfColumn("col"); // Then assertThat(statement.getQueryString()) .isEqualTo("\n\tCREATE INDEX IF NOT EXISTS myIndex ON ks.test(KEYS(col))"); } }
protected void createIndex(CassandraSessionPool.Session session, String indexLabel, HugeKeys column) { String indexName = joinTableName(this.table(), indexLabel); SchemaStatement index = SchemaBuilder.createIndex(indexName) .ifNotExists() .onTable(this.table()) .andColumn(formatKey(column)); LOG.debug("Create index: {}", index); session.execute(index); }