I am trying to convert sstables to json using sstable2json utility. It works fine but for counter columns it gives a very long string value.
My create table statement : CREATE TABLE counters1 (value counter, name varchar, surname varchar, PRIMARY KEY (name, surname) );
Sample data :

Now after converting to json what I get is :
[ {"key": "hari", "cells": [["ram:value","0001800086d46a8fd6cb484e9257a02ddd14fe0600000000000000010000000000000001",1452867057744000,"c",-9223372036854775808]]} ]
Q1) Is there a way to get meaningful value from this? (0001800086d46a8fd6cb484e9257a02ddd14fe0600000000000000010000000000000001)
Q2) How does cassandra reads from the same sstable and displays "1"
Thanks
Counters changed a lot in 2.1, see http://www.datastax.com/dev/blog/whats-new-in-cassandra-2-1-a-better-implementation-of-counters. Which also has a great explaination of counters in pre-2.0 (what you are looking at). The context in the sstable mostly is made up of a tuple of counter id (timeuuid), shard logical clock, and shard value. (16 byte id, and two longs). This is whats being displayed in the sstable2json. Theres a little more in the header which describes some local/global element index. Check out https://github.com/apache/cassandra/blob/cassandra-2.0/src/java/org/apache/cassandra/db/context/CounterContext.java#L675 for more details.
But I would recommend using 2.1 counters to avoid some issues and have a little more simplicity. Its going to be pretty non-trivial to build your counter value from the sstables manually though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With