Question

I have just started with Cassandra, created a simple ColumnFamily and some data using command given on Getting started on Cassandra download page, by executing below queries.

CREATE TABLE users (
   user_id int PRIMARY KEY,
   fname text,
   lname text
);

INSERT INTO users (user_id,  fname, lname)
   VALUES (1745, 'john', 'smith');
INSERT INTO users (user_id,  fname, lname)
   VALUES (1744, 'john', 'doe');
INSERT INTO users (user_id,  fname, lname)
   VALUES (1746, 'john', 'smith');

My Hector code for fetching data:

RangeSlicesQuery<String, String, String> rangeSlicesQuery 
                = HFactory.createRangeSlicesQuery(keyspace, STR, STR, STR);
            rangeSlicesQuery.setColumnFamily(columnFamily)
            .setColumnNames(" fname ", " lname ")
            .setKeys("6", "5")
            .setRowCount(row_count);
QueryResult<OrderedRows<String, String, String>> result = rangeSlicesQuery.execute();

But when i fetch data using Hector API from Cassandra in Column name it contain blank space like column name fname will be: ' fname '. And for my queries from Java Hector API i need to use same column name with blank space to fetch or save data.
Anybody have any idea, what i have done wrong, or what do i do to remove those trailing space.
Thanks

Was it helpful?

Solution

This issue has been fixed by using "WITH COMPACT STORAGE" when creating column families. Discussion is here.

Instead of Hector i used Cassandra Java Driver pointed by Allan Elder, and my problem for trailing space in column name has been solved.
Doc for how to using Cassandra Java Driver is here and jars will be found by this project.
Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top