/** * Returns the definition of a function in this keyspace. * * @param name the name of the function. * @param argumentTypes the types of the function's arguments. * @return the function definition if it exists in this keyspace, {@code null} otherwise. */ public FunctionMetadata getFunction(String name, DataType... argumentTypes) { return getFunction(name, Lists.newArrayList(argumentTypes)); }
@Test(groups = "short", dataProvider = "existingKeyspaceName") @CassandraVersion("2.2.0") public void should_notify_of_function_drop(String keyspace) { session1.execute( String.format( "CREATE FUNCTION %s.\"ID\"(i int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return i;'", keyspace)); session1.execute(String.format("DROP FUNCTION %s.\"ID\"", keyspace)); for (SchemaChangeListener listener : listeners) { ArgumentCaptor<FunctionMetadata> removed = ArgumentCaptor.forClass(FunctionMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)).onFunctionRemoved(removed.capture()); assertThat(removed.getValue()).isInKeyspace(handleId(keyspace)).hasSignature("\"ID\"(int)"); } for (Metadata m : metadatas()) assertThat(m.getKeyspace(keyspace).getFunction("\"ID\"", DataType.cint())).isNull(); }
@Test(groups = "short", dataProvider = "existingKeyspaceName") @CassandraVersion("2.2.0") public void should_notify_of_function_creation(String keyspace) { session1.execute( String.format( "CREATE FUNCTION %s.\"ID\"(i int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return i;'", keyspace)); for (SchemaChangeListener listener : listeners) { ArgumentCaptor<FunctionMetadata> added = ArgumentCaptor.forClass(FunctionMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)).onFunctionAdded(added.capture()); assertThat(added.getValue()).isInKeyspace(handleId(keyspace)).hasSignature("\"ID\"(int)"); } for (Metadata m : metadatas()) assertThat(m.getKeyspace(keyspace).getFunction("\"ID\"", DataType.cint())).isNotNull(); }
@Test(groups = "short", dataProvider = "existingKeyspaceName") @CassandraVersion("2.2.0") public void should_notify_of_function_update(String keyspace) { session1.execute( String.format( "CREATE FUNCTION %s.\"ID\"(i int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return i;'", keyspace)); for (SchemaChangeListener listener : listeners) { ArgumentCaptor<FunctionMetadata> added = ArgumentCaptor.forClass(FunctionMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)).onFunctionAdded(added.capture()); assertThat(added.getValue()).isInKeyspace(handleId(keyspace)).hasSignature("\"ID\"(int)"); } for (Metadata m : metadatas()) assertThat(m.getKeyspace(keyspace).getFunction("\"ID\"", DataType.cint())).isNotNull(); session1.execute( String.format( "CREATE OR REPLACE FUNCTION %s.\"ID\"(i int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return i + 1;'", keyspace)); for (SchemaChangeListener listener : listeners) { ArgumentCaptor<FunctionMetadata> current = ArgumentCaptor.forClass(FunctionMetadata.class); ArgumentCaptor<FunctionMetadata> previous = ArgumentCaptor.forClass(FunctionMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)) .onFunctionChanged(current.capture(), previous.capture()); assertThat(previous.getValue()).hasBody("return i;"); assertThat(current.getValue()).hasBody("return i + 1;"); } for (Metadata m : metadatas()) assertThat(m.getKeyspace(keyspace).getFunction("\"ID\"", DataType.cint()).getBody()) .isEqualTo("return i + 1;"); }
/** * Returns the definition of a function in this keyspace. * * @param name the name of the function. * @param argumentTypes the types of the function's arguments. * @return the function definition if it exists in this keyspace, {@code null} otherwise. */ public FunctionMetadata getFunction(String name, DataType... argumentTypes) { return getFunction(name, Lists.newArrayList(argumentTypes)); }
FunctionMetadata function = keyspace.getFunction("pi"); assertThat(function).isNotNull(); assertThat(function.getKeyspace()).isEqualTo(keyspace);
/** * Returns the definition of a function in this keyspace. * * @param name the name of the function. * @param argumentTypes the types of the function's arguments. * @return the function definition if it exists in this keyspace, {@code null} otherwise. */ public FunctionMetadata getFunction(String name, DataType... argumentTypes) { return getFunction(name, Lists.newArrayList(argumentTypes)); }
/** * Returns the definition of a function in this keyspace. * * @param name the name of the function. * @param argumentTypes the types of the function's arguments. * @return the function definition if it exists in this keyspace, {@code null} otherwise. */ public FunctionMetadata getFunction(String name, DataType... argumentTypes) { return getFunction(name, Lists.newArrayList(argumentTypes)); }
FunctionMetadata function = keyspace.getFunction("plus", cint(), cint()); assertThat(function).isNotNull(); assertThat(function.getKeyspace()).isEqualTo(keyspace);
FunctionMetadata stateFunc = keyspace.getFunction("plus", cint(), cint()); FunctionMetadata finalFunc = keyspace.getFunction("announce", cint()); AggregateMetadata aggregate = keyspace.getAggregate("prettysum", cint()); assertThat(aggregate).isNotNull();
FunctionMetadata stateFunc = keyspace.getFunction("inc", cint()); AggregateMetadata aggregate = keyspace.getAggregate("mycount"); assertThat(aggregate).isNotNull();
FunctionMetadata stateFunc = keyspace.getFunction("cat", text(), cint()); AggregateMetadata aggregate = keyspace.getAggregate("cat_tos", cint()); assertThat(aggregate).isNotNull();
FunctionMetadata function = keyspace.getFunction("\"NUM_PHONES_ACCU\"", cint(), addressType); assertThat(function).isNotNull(); assertThat(function.getKeyspace()).isEqualTo(keyspace);
FunctionMetadata stateFunc = keyspace.getFunction(aggregateName + "_id", custom); AggregateMetadata aggregate = keyspace.getAggregate(aggregateName); assertThat(aggregate).isNotNull();
FunctionMetadata stateFunc = keyspace.getFunction("plus2", cint(), cint()); AggregateMetadata aggregate = keyspace.getAggregate("sum", cint()); assertThat(aggregate).isNotNull();
.getMetadata() .newTupleType(cluster().getMetadata().newTupleType(cint()), map(cint(), cint())); FunctionMetadata function = keyspace.getFunction("complex", argumentType); assertThat(function).isNotNull(); assertThat(function.getKeyspace()).isEqualTo(keyspace);
FunctionMetadata stateFunc = keyspace.getFunction("\"MY_FUNC\"", addressType, addressType); AggregateMetadata aggregate = keyspace.getAggregate("\"MY_AGGREGATE\"", addressType); assertThat(aggregate).isNotNull();
@Test(groups = "short", dataProvider = "existingKeyspaceName") @CassandraVersion("2.2.0") public void should_notify_of_function_drop(String keyspace) { session1.execute( String.format( "CREATE FUNCTION %s.\"ID\"(i int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return i;'", keyspace)); session1.execute(String.format("DROP FUNCTION %s.\"ID\"", keyspace)); for (SchemaChangeListener listener : listeners) { ArgumentCaptor<FunctionMetadata> removed = ArgumentCaptor.forClass(FunctionMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)).onFunctionRemoved(removed.capture()); assertThat(removed.getValue()).isInKeyspace(handleId(keyspace)).hasSignature("\"ID\"(int)"); } for (Metadata m : metadatas()) assertThat(m.getKeyspace(keyspace).getFunction("\"ID\"", DataType.cint())).isNull(); }
@Test(groups = "short", dataProvider = "existingKeyspaceName") @CassandraVersion("2.2.0") public void should_notify_of_function_creation(String keyspace) { session1.execute( String.format( "CREATE FUNCTION %s.\"ID\"(i int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return i;'", keyspace)); for (SchemaChangeListener listener : listeners) { ArgumentCaptor<FunctionMetadata> added = ArgumentCaptor.forClass(FunctionMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)).onFunctionAdded(added.capture()); assertThat(added.getValue()).isInKeyspace(handleId(keyspace)).hasSignature("\"ID\"(int)"); } for (Metadata m : metadatas()) assertThat(m.getKeyspace(keyspace).getFunction("\"ID\"", DataType.cint())).isNotNull(); }
FunctionMetadata stateFunc = keyspace.getFunction("detf", cint(), cint()); AggregateMetadata aggregate = keyspace.getAggregate("deta", cint()); assertThat(aggregate).isNotNull();