Search in sources :

Example 1 with CounterColumn

use of org.apache.cassandra.thrift.CounterColumn in project scale7-pelops by s7.

the class SelectorIntegrationTest method testGetCounterColumnFromRow.

@Test
public void testGetCounterColumnFromRow() {
    CounterColumn counterColumn = createSelector().getCounterColumnFromRow(CF_COUNTER, fromLong(50), fromLong(50), ConsistencyLevel.QUORUM);
    assertEquals("Wrong counter column value returned", 50, counterColumn.getValue());
}
Also used : CounterColumn(org.apache.cassandra.thrift.CounterColumn) AbstractIntegrationTest(org.scale7.cassandra.pelops.support.AbstractIntegrationTest) Test(org.junit.Test)

Example 2 with CounterColumn

use of org.apache.cassandra.thrift.CounterColumn in project eiger by wlloyd.

the class ColumnOrSuperColumnHelper method extractEvtAndLvt.

public static EvtAndLvt extractEvtAndLvt(ColumnOrSuperColumn cosc) {
    EvtAndLvt result = null;
    if (cosc.isSetColumn()) {
        result = new EvtAndLvt(cosc.column.earliest_valid_time, cosc.column.latest_valid_time);
    } else if (cosc.isSetCounter_column()) {
        result = new EvtAndLvt(cosc.counter_column.earliest_valid_time, cosc.counter_column.latest_valid_time);
    } else if (cosc.isSetSuper_column()) {
        long maxEarliestValidTime = Long.MIN_VALUE;
        long minLatestValidTime = Long.MAX_VALUE;
        for (Column column : cosc.super_column.columns) {
            maxEarliestValidTime = Math.max(maxEarliestValidTime, column.earliest_valid_time);
            minLatestValidTime = Math.min(minLatestValidTime, column.latest_valid_time);
        }
        result = new EvtAndLvt(maxEarliestValidTime, minLatestValidTime);
    } else {
        long maxEarliestValidTime = Long.MIN_VALUE;
        long minLatestValidTime = Long.MAX_VALUE;
        for (CounterColumn column : cosc.counter_super_column.columns) {
            maxEarliestValidTime = Math.max(maxEarliestValidTime, column.earliest_valid_time);
            minLatestValidTime = Math.min(minLatestValidTime, column.latest_valid_time);
        }
        result = new EvtAndLvt(maxEarliestValidTime, minLatestValidTime);
    }
    logger.trace("extractEVTandLVT(" + toString(cosc) + ")=" + result);
    return result;
}
Also used : CounterColumn(org.apache.cassandra.thrift.CounterColumn) ColumnOrSuperColumn(org.apache.cassandra.thrift.ColumnOrSuperColumn) Column(org.apache.cassandra.thrift.Column) CounterColumn(org.apache.cassandra.thrift.CounterColumn)

Example 3 with CounterColumn

use of org.apache.cassandra.thrift.CounterColumn in project eiger by wlloyd.

the class ColumnOrSuperColumnHelper method toString.

public static String toString(ColumnOrSuperColumn cosc) {
    if (cosc.isSetColumn()) {
        StringBuilder sb = new StringBuilder(ByteBufferUtil.bytesToHex(cosc.column.name));
        sb.append(":");
        sb.append(cosc.column.isSetValue() ? ByteBufferUtil.bytesToHex(cosc.column.value) : "-");
        sb.append("@");
        sb.append(cosc.column.isSetTimestamp() ? cosc.column.timestamp : "-");
        return sb.toString();
    } else if (cosc.isSetCounter_column()) {
        return ByteBufferUtil.bytesToHex(cosc.counter_column.name) + ":" + cosc.counter_column.value;
    } else if (cosc.isSetSuper_column()) {
        String superColumnString = new String(ByteBufferUtil.bytesToHex(cosc.super_column.name) + "={");
        for (Column column : cosc.super_column.columns) {
            superColumnString += ByteBufferUtil.bytesToHex(column.name) + ":" + ByteBufferUtil.bytesToHex(column.value) + "@" + column.timestamp + ", ";
        }
        return superColumnString.substring(0, superColumnString.length() - 2) + "}";
    } else {
        String superColumnString = new String(ByteBufferUtil.bytesToHex(cosc.super_column.name) + "={");
        for (CounterColumn column : cosc.counter_super_column.columns) {
            superColumnString += ByteBufferUtil.bytesToHex(column.name) + ":" + column.value + ", ";
        }
        return superColumnString.substring(0, superColumnString.length() - 2) + "}";
    }
}
Also used : CounterColumn(org.apache.cassandra.thrift.CounterColumn) ColumnOrSuperColumn(org.apache.cassandra.thrift.ColumnOrSuperColumn) Column(org.apache.cassandra.thrift.Column) CounterColumn(org.apache.cassandra.thrift.CounterColumn)

Aggregations

CounterColumn (org.apache.cassandra.thrift.CounterColumn)3 Column (org.apache.cassandra.thrift.Column)2 ColumnOrSuperColumn (org.apache.cassandra.thrift.ColumnOrSuperColumn)2 Test (org.junit.Test)1 AbstractIntegrationTest (org.scale7.cassandra.pelops.support.AbstractIntegrationTest)1