Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7916755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:55:09+00:00 2026-06-03T14:55:09+00:00

I have a simple column family ‘Users’ System.out.println( read User); long timestamp = System.currentTimeMillis();

  • 0

I have a simple column family ‘Users’

    System.out.println("  read User");
    long timestamp = System.currentTimeMillis();
    clientA.insert(ByteBuffer.wrap("mike".getBytes()), new ColumnParent("Users"), 
            new Column(ByteBuffer.wrap("email".getBytes())).setValue(ByteBuffer.wrap("mike@gmail.com".getBytes())).setTimestamp(timestamp)
            , ConsistencyLevel.ONE);

    clientA.insert(ByteBuffer.wrap("mike".getBytes()), new ColumnParent("Users"), 
            new Column(ByteBuffer.wrap("totalPosts".getBytes())).setValue(ByteBuffer.allocate(4).putInt(27).array()).setTimestamp(timestamp)
            , ConsistencyLevel.ONE);

    SlicePredicate predicate = new SlicePredicate();
    predicate.setSlice_range(new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), false, 10));

    ColumnParent parent = new ColumnParent("Users");

    List<ColumnOrSuperColumn> results = clientA.get_slice(ByteBuffer.wrap("mike".getBytes()), 
            parent, 
            predicate, 
            ConsistencyLevel.ONE);

    for (ColumnOrSuperColumn result : results) {
        Column column = result.column;
        System.out.println(new String(column.getName()) + " -> "+ new String(column.getValue())+", "+column.getValue().length);
    }

it returns

  read User
email -> mike@gmail.com, 14
totalPosts -> 

So totalPosts can’t be read with the thrift client

with cassandra-cli

[default@test] get Users[‘mike’][‘totalPosts’];
=> (column=totalPosts, value=0000001b, timestamp=1336493080621)
Elapsed time: 10 msec(s).

How can I retrieve this Integer value with Java thrift client?

using cassandra 1.1

edit:
it seems due to this part

for (ColumnOrSuperColumn result : results) {
        Column column = result.column;
        System.out.println(new String(column.getName()) + " -> "+Arrays.toString(column.getValue()));
    }

returns

email -> [109, 105, 107, 101, 64, 103, 109, 97, 105, 108, 46, 99, 111, 109]
totalPosts -> [0, 0, 0, 27]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:55:10+00:00Added an answer on June 3, 2026 at 2:55 pm

    Your column values are being returned as bytes, the same way you’re inserting them. So the value for the ’email’ column is [109, 105, 107, 101, 64, 103, 109, 97, 105, 108, 46, 99, 111, 109], which interpreted as ascii is mike@gmail.com. And the number 27 which you write into the ByteBuffer as [0, 0, 0, 27] (via the putint call) comes out the same way.

    If you absolutely have to be using the raw thrift interface, you’ll probably want to retrieve your totalPosts int using ByteBuffer.getInt(). But if at all possible, I recommend using a library to wrap around the ugliness of the thrift interface, which should take care of value serialization issues like this. Maybe look at Hector, or skip the old interface entirely and go straight to CQL with Cassandra-JDBC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's assume I have a keyspace with a column family that stores user objects
I have a simple markup .content{ -webkit-column-width: 100px; width : 200px; height: 100px; }
I have a simple table with autoincrementing ID's and one text column. id(int), value(nvarchar)
I have a simple DropDownList . A column with the control DropDownList . The
I have a simple cakephp app with table articles that has a cat_id column
Here's a sample of the scenario I'm facing. Say I have this column family:
When I have a simple DataSet that has a table with simple column names
I have a simple two column layout with a footer at the bottom. When
I have a simple 4-column Excel spreadsheet that matches universities to their ID codes
I have a simple 2-column table, where both columns are integers: 3;1 1;2 2;1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.