Custom column type in cassandra: List of arrays

Dave :

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>
);
Alex Ott :

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=104417&siteId=1