0

currently we're using HBase to store our data. Therefore we created an abstract class that holds a Map, and this map is then stored via the Java API. a sample class would be

class User extends AHBase {
  public static String columnName = "nam".getBytes();
  //...
  public void setName(String name) {
    values.put(columnName, name.getBytes());
  }
  public String getName() {
    return new String(values.get(columnName));
  }
  public byte[] getColumnFamily() {...}
  public byte[] getTable() {...}
}

and a store is as simple as (simplified)

public void store(AHbase a) {
  List<Put> puts = new ArrayList<>();
  for (Entry<byte[], byte[] item : a.getValues().entrySet()) {
    Put p = new Put(a.getColumnFamily, item.getKey(), item.getValue());
    puts.add(p);
  }
  //...
}

we are now evaluating Cassandra, as it's said to be also a key-value store and it should be easy to just switch and do some basic evaluation (at least we thought so).

But now when checking out the latest version of Cassandra (2.1.2) it's kind of not what we expected.

Is there still a simple way to store key-value pairs (for a ColumnFamily) with basic put operations or similar? I want to avoid having to define the column names in advance.

Raedwald
  • 46,613
  • 43
  • 151
  • 237
divadpoc
  • 903
  • 10
  • 31

1 Answers1

1

Cassandra has definitely deviated away from the thrift model of storing data but you can still get a similar partition layout in cql with something like:

partition blob, key blob , value blob, PRIMARY KEY partition,key

or

key blob, value blob, PRIMARY KEY key

Depending on if you want to have multiple keys in a partition or not.

Thrift is still available but is definitely one foot out the door at the moment.

RussS
  • 16,476
  • 1
  • 34
  • 62
  • that's unfortunate (at least for us). thanks for your reply. maybe I'll wait for astyanax to be available for cassandra 2 and check out their changes/possibilities – divadpoc Dec 23 '14 at 15:34