Nomad
Nomad

Reputation: 781

Custom column type in cassandra: List of arrays

How can I define a table schema for a custom column type, as described below?

I did look at the Datastax documentation for UDTs on frozen types. But, I am not able to apply that to my java code. What changes are required for Cassandra TYPE node, so that I can serialize/deserialize easily?. It should store List of Double arrays in column node.

static class Testf {
        String id;
        String name;
        List<Double[]> nodes;
    }

Table schema:

CREATE TABLE IF NOT EXISTS myks.testf(
id text,
name text,
nodes list<FROZEN<node>>,
PRIMARY KEY (id) );

CREATE TYPE myks.node (
     node map<double>
);

Upvotes: 4

Views: 931

Answers (1)

Alex Ott
Alex Ott

Reputation: 87154

The easiest way will be to use ObjectMapper from Java driver. You can add necessary annotations for your class, and then map class to Cassandra table & back. But you'll need to create a separate class to match your node UDT.

Upvotes: 2

Related Questions