Question

I want to design a system for user point. The main two points of this system are point and log.

I want to use Cassandra to store the data. Two reason:

  1. Cassandra provides counter feature which I can use to store the point.
  2. The log of point changing may be too much I have to think about the scale of the storage. Cassandra can be easily scaled.

The basic data sturcture:

// row
name: user_id,
values: {
    point: {
        name: point,
        values: 1000
    },
    log: {
        name: log,
        values: {
            log_timestamp: {
                 name: timestamp,
                 values: xxxx
            },
            log_timestamp: {
                 name: timestamp,
                 values: xxxx
            },
            log_timestamp: {
                 name: timestamp,
                 values: xxxx
            },
            ……
        }
    }
}

My question is:

Is there any problem if the log is too many enough?

Was it helpful?

Solution

@lifei

What you want is somehow a table with:

  1. Row key (partition key) = userId
  2. 1 point counter
  3. 1 log collection with as many log_timestamp as possible

It is indeed very easy to create a table like this:

CREATE TABLE logs
(
  userId: int,
  log_timestamp long, //timestamp
  value text,
  PRIMARY KEY (userId,log_timestamp)
);

It is a clustered entity (wide row) with a maximum of 2 billions of log_timestamp/value couples.

For the point counter, unfortunately you have to create another column family to store it because Cassandra does not allow mixing counter value with other types.

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