How to access list with nested maps with Cassandra Java Driver

2020-05-07 Thread Andreas R.
I am having trouble with getting a list including maps with |Cassandra 
Java Driver|.


For below version:

|List>myList 
=state.getList(5,TypeTokens.mapOf(Integer.class,Integer.class));|


The error is like:

|InvalidRequest:Errorfrom server:code=2200[Invalidquery]message="Java 
source compilation failed: Line 3: TypeTokens cannot be resolved"|


And for version like below:

|List>myList =state.getList(5,Map.class);|

The error is like:

|InvalidRequest:Errorfrom server:code=2200[Invalidquery]message="Java 
source compilation failed: Line 3: Type mismatch: cannot convert from 
List to List>|


|state| is a UDT defined as:

|CREATE TYPE count_min_udt(n int,m int,p bigint,hash_a list 
,hash_b list ,values list>>);|


Am I using them wrong? I'd appreciate some help.

Thanks, Andreas



Re: UDTs, UDFs und UDAs

2020-04-30 Thread Andreas R.

 Hello

I am trying to extract sketches (e.g. bloom filter) from some given 
data. I came this far, questions below:


|CREATE TYPE bloomfilter_udt(||
n_as_sample_size int, 
m_as_number_of_buckets int,||
p_as_next_prime_above_m bigint, 
hash_for_string_coefficient_a list ,||
hash_for_number_coefficients_a list , 
hash_for_number_coefficients_b list ,||
bloom_filter_as_map map 
);||

CREATE OR REPLACE FUNCTION bloomfilter_udf(state bloomfilter_udt, value 
text, sample_size int) 

CALLED ON NULL INPUT||
RETURNS bloomfilter_udt 
LANGUAGE java||
AS 
$$||
//put n_as_sample_size in result 
//if(state.getUDTValue("n_as_sample_size") == 
null){state.setInt("n_as_sample_size", sample_size);};||

//do some more stuff to the bloomfilter_udt 
return state;||
$$; 

CREATE OR REPLACE AGGREGATE bloomfilter_uda(text, int)||
SFUNC bloomfilter_udf 
STYPE bloomfilter_udt||
INITCOND {};|||

1) I would pass the sample_size with a sub-query, e.g.
==> "SELECT bloomfilter_uda(name, (SELECT count(*) FROM test_table)) 
FROM test_table;" <==

Is that possible with Cassandra?

2) When I try to register the bloomfilter_uda, I get the following error:
==> InvalidRequest: Error from server: code=2200 [Invalid query] 
message="Invalid set literal for (dummy) of type bloomfilter_udt" <==

Can I just pass Cassandra data types as a state (map, list, set)?

3) If I assume, all of the above is my bad, how can I access the props 
of the state? Like

==> state.n_as_sample_size <==||
Is this somehow possible?

I am kind of struggling with Cassandra and I'd appreciate some help.

Thanks
Andreas

--
andreasrimmelspac...@gmail.com