/** * Returns the definition of an aggregate in this keyspace. * * @param name the name of the aggregate. * @param argumentTypes the types of the aggregate's arguments. * @return the aggregate definition if it exists in this keyspace, {@code null} otherwise. */ public AggregateMetadata getAggregate(String name, DataType... argumentTypes) { return getAggregate(name, Lists.newArrayList(argumentTypes)); }
@Test(groups = "short", dataProvider = "existingKeyspaceName") @CassandraVersion("2.2.0") public void should_notify_of_aggregate_drop(String keyspace) { session1.execute( String.format( "CREATE FUNCTION %s.\"PLUS\"(s int, v int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java" + " AS 'return s+v;'", keyspace)); session1.execute( String.format( "CREATE AGGREGATE %s.\"SUM\"(int) SFUNC \"PLUS\" STYPE int INITCOND 0", keyspace)); session1.execute(String.format("DROP AGGREGATE %s.\"SUM\"", keyspace)); for (SchemaChangeListener listener : listeners) { ArgumentCaptor<AggregateMetadata> removed = ArgumentCaptor.forClass(AggregateMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)).onAggregateRemoved(removed.capture()); assertThat(removed.getValue()).isInKeyspace(handleId(keyspace)).hasSignature("\"SUM\"(int)"); } for (Metadata m : metadatas()) assertThat(m.getKeyspace(keyspace).getAggregate("\"SUM\"", DataType.cint())).isNull(); }
@Test(groups = "short", dataProvider = "existingKeyspaceName") @CassandraVersion("2.2.0") public void should_notify_of_aggregate_creation(String keyspace) { session1.execute( String.format( "CREATE FUNCTION %s.\"PLUS\"(s int, v int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java" + " AS 'return s+v;'", keyspace)); session1.execute( String.format( "CREATE AGGREGATE %s.\"SUM\"(int) SFUNC \"PLUS\" STYPE int INITCOND 0;", keyspace)); for (SchemaChangeListener listener : listeners) { ArgumentCaptor<AggregateMetadata> added = ArgumentCaptor.forClass(AggregateMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)).onAggregateAdded(added.capture()); assertThat(added.getValue()).isInKeyspace(handleId(keyspace)).hasSignature("\"SUM\"(int)"); } for (Metadata m : metadatas()) assertThat(m.getKeyspace(keyspace).getAggregate("\"SUM\"", DataType.cint())).isNotNull(); }
assertThat(m.getKeyspace(keyspace).getAggregate("\"SUM\"", DataType.cint()).getInitCond()) .isEqualTo(0); session1.execute( assertThat(m.getKeyspace(keyspace).getAggregate("\"SUM\"", DataType.cint()).getInitCond()) .isEqualTo(1);
/** * Returns the definition of an aggregate in this keyspace. * * @param name the name of the aggregate. * @param argumentTypes the types of the aggregate's arguments. * @return the aggregate definition if it exists in this keyspace, {@code null} otherwise. */ public AggregateMetadata getAggregate(String name, DataType... argumentTypes) { return getAggregate(name, Lists.newArrayList(argumentTypes)); }
/** * Returns the definition of an aggregate in this keyspace. * * @param name the name of the aggregate. * @param argumentTypes the types of the aggregate's arguments. * @return the aggregate definition if it exists in this keyspace, {@code null} otherwise. */ public AggregateMetadata getAggregate(String name, DataType... argumentTypes) { return getAggregate(name, Lists.newArrayList(argumentTypes)); }
/** * Returns the definition of an aggregate in this keyspace. * * @param name the name of the aggregate. * @param argumentTypes the types of the aggregate's arguments. * @return the aggregate definition if it exists in this keyspace, {@code null} otherwise. */ public AggregateMetadata getAggregate(String name, DataType... argumentTypes) { return getAggregate(name, Lists.newArrayList(argumentTypes)); }
AggregateMetadata aggregate = keyspace.getAggregate("mycount"); assertThat(aggregate).isNotNull(); assertThat(aggregate.getSignature()).isEqualTo("mycount()");
AggregateMetadata aggregate = keyspace.getAggregate("cat_tos", cint()); assertThat(aggregate).isNotNull(); assertThat(aggregate.getSignature()).isEqualTo("cat_tos(int)");
FunctionMetadata stateFunc = keyspace.getFunction("plus", cint(), cint()); FunctionMetadata finalFunc = keyspace.getFunction("announce", cint()); AggregateMetadata aggregate = keyspace.getAggregate("prettysum", cint()); assertThat(aggregate).isNotNull(); assertThat(aggregate.getSignature()).isEqualTo("prettysum(int)");
AggregateMetadata aggregate = keyspace.getAggregate(aggregateName); assertThat(aggregate).isNotNull(); assertThat(aggregate.getSignature()).isEqualTo(aggregateName + "()");
AggregateMetadata aggregate = keyspace.getAggregate("sum", cint()); assertThat(aggregate).isNotNull(); assertThat(aggregate.getSignature()).isEqualTo("sum(int)");
UserType addressType = keyspace.getUserType("\"Address\""); FunctionMetadata stateFunc = keyspace.getFunction("\"MY_FUNC\"", addressType, addressType); AggregateMetadata aggregate = keyspace.getAggregate("\"MY_AGGREGATE\"", addressType); assertThat(aggregate).isNotNull(); assertThat(aggregate.getSignature()).isEqualTo("\"MY_AGGREGATE\"(\"Address\")");
@Test(groups = "short", dataProvider = "existingKeyspaceName") @CassandraVersion("2.2.0") public void should_notify_of_aggregate_drop(String keyspace) { session1.execute( String.format( "CREATE FUNCTION %s.\"PLUS\"(s int, v int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java" + " AS 'return s+v;'", keyspace)); session1.execute( String.format( "CREATE AGGREGATE %s.\"SUM\"(int) SFUNC \"PLUS\" STYPE int INITCOND 0", keyspace)); session1.execute(String.format("DROP AGGREGATE %s.\"SUM\"", keyspace)); for (SchemaChangeListener listener : listeners) { ArgumentCaptor<AggregateMetadata> removed = ArgumentCaptor.forClass(AggregateMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)).onAggregateRemoved(removed.capture()); assertThat(removed.getValue()).isInKeyspace(handleId(keyspace)).hasSignature("\"SUM\"(int)"); } for (Metadata m : metadatas()) assertThat(m.getKeyspace(keyspace).getAggregate("\"SUM\"", DataType.cint())).isNull(); }
@Test(groups = "short", dataProvider = "existingKeyspaceName") @CassandraVersion("2.2.0") public void should_notify_of_aggregate_creation(String keyspace) { session1.execute( String.format( "CREATE FUNCTION %s.\"PLUS\"(s int, v int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java" + " AS 'return s+v;'", keyspace)); session1.execute( String.format( "CREATE AGGREGATE %s.\"SUM\"(int) SFUNC \"PLUS\" STYPE int INITCOND 0;", keyspace)); for (SchemaChangeListener listener : listeners) { ArgumentCaptor<AggregateMetadata> added = ArgumentCaptor.forClass(AggregateMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)).onAggregateAdded(added.capture()); assertThat(added.getValue()).isInKeyspace(handleId(keyspace)).hasSignature("\"SUM\"(int)"); } for (Metadata m : metadatas()) assertThat(m.getKeyspace(keyspace).getAggregate("\"SUM\"", DataType.cint())).isNotNull(); }
assertThat(m.getKeyspace(keyspace).getAggregate("\"SUM\"", DataType.cint()).getInitCond()) .isEqualTo(0); session1.execute( assertThat(m.getKeyspace(keyspace).getAggregate("\"SUM\"", DataType.cint()).getInitCond()) .isEqualTo(1);
AggregateMetadata aggregate = keyspace.getAggregate("cat_tos", cint()); assertThat(aggregate).isNotNull(); assertThat(aggregate.getSignature()).isEqualTo("cat_tos(int)");
AggregateMetadata aggregate = keyspace.getAggregate("deta", cint()); assertThat(aggregate).isNotNull(); assertThat(aggregate.getSignature()).isEqualTo("deta(int)");
UserType addressType = keyspace.getUserType("\"Address\""); FunctionMetadata stateFunc = keyspace.getFunction("\"MY_FUNC\"", addressType, addressType); AggregateMetadata aggregate = keyspace.getAggregate("\"MY_AGGREGATE\"", addressType); assertThat(aggregate).isNotNull(); assertThat(aggregate.getSignature()).isEqualTo("\"MY_AGGREGATE\"(\"Address\")");
AggregateMetadata aggregate = keyspace.getAggregate("sum", cint()); assertThat(aggregate).isNotNull(); assertThat(aggregate.getSignature()).isEqualTo("sum(int)");