Hi,

I'm trying to deserialize the commit log in Cassandra for a research
project. I have succeeded so far in deserializing the cell names and the
cell values from the mutation entries in the commit log.

However, am struggling to deserialize the primary key entries of the
mutations since per design the cell values are empty for the primary keys.
The closest I could get is to retrieve the partition key name from the
column definition of the column family metadata. But I don't know how to
get the actual value of the primary key ?

Thanks for your help.

Below is my approach to deserialize the mutation:

// function in CommitLog.java
public ReplayPosition add(Mutation mutation){

    Collection<ColumnFamily> myCollection  =   mutation.getColumnFamilies();

    for(ColumnFamily cf:myCollection) {

        CFMetaData cfm = cf.metadata();

        // Retrieve name of partition key
        logger.info("partition key={}.",
cfm.partitionKeyColumns().get(0).name.toString());

        for (Cell cell : cf){

            // Retrieve cell name
            String name = cfm.comparator.getString(cell.name());
            logger.info("name={}.", name);

            // Retrieve cell value
            String value =
cfm.getValueValidator(cell.name()).getString(cell.value());
            logger.info("value={}.", value);
        }
    }

}

Reply via email to