Search in sources :

Example 11 with ColumnOrSuperColumn

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

the class ColumnOrSuperColumnHelper method extractEvtAndLvt.

public static EvtAndLvt extractEvtAndLvt(Collection<ColumnOrSuperColumn> coscCollection) {
    long maxEarliestValidTime = Long.MIN_VALUE;
    long minLatestValidTime = Long.MAX_VALUE;
    for (ColumnOrSuperColumn cosc : coscCollection) {
        EvtAndLvt evtAndLvt = ColumnOrSuperColumnHelper.extractEvtAndLvt(cosc);
        maxEarliestValidTime = Math.max(maxEarliestValidTime, evtAndLvt.getEarliestValidTime());
        minLatestValidTime = Math.min(minLatestValidTime, evtAndLvt.getLatestValidTime());
    }
    return new EvtAndLvt(maxEarliestValidTime, minLatestValidTime);
}
Also used : ColumnOrSuperColumn(org.apache.cassandra.thrift.ColumnOrSuperColumn)

Example 12 with ColumnOrSuperColumn

use of org.apache.cassandra.thrift.ColumnOrSuperColumn 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)

Example 13 with ColumnOrSuperColumn

use of org.apache.cassandra.thrift.ColumnOrSuperColumn in project brisk by riptano.

the class HistoricalPriceInserter method genDaysPrices.

private Map<String, List<Mutation>> genDaysPrices(ByteBuffer date) {
    Map<String, List<Mutation>> prices = new HashMap<String, List<Mutation>>();
    Mutation m = new Mutation();
    m.setColumn_or_supercolumn(new ColumnOrSuperColumn().setColumn(new Column().setName(date).setValue(ByteBufferUtil.bytes(String.valueOf((double) (Pricer.randomizer.nextDouble() * 1000)))).setTimestamp(System.currentTimeMillis())));
    prices.put("StockHist", Arrays.asList(m));
    return prices;
}
Also used : ColumnOrSuperColumn(org.apache.cassandra.thrift.ColumnOrSuperColumn) ColumnOrSuperColumn(org.apache.cassandra.thrift.ColumnOrSuperColumn) Column(org.apache.cassandra.thrift.Column) Mutation(org.apache.cassandra.thrift.Mutation)

Aggregations

ColumnOrSuperColumn (org.apache.cassandra.thrift.ColumnOrSuperColumn)13 Mutation (org.apache.cassandra.thrift.Mutation)9 Column (org.apache.cassandra.thrift.Column)4 ByteBuffer (java.nio.ByteBuffer)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Column (org.apache.cassandra.db.Column)2 IColumn (org.apache.cassandra.db.IColumn)2 org.apache.cassandra.thrift (org.apache.cassandra.thrift)2 CounterColumn (org.apache.cassandra.thrift.CounterColumn)2 CounterSuperColumn (org.apache.cassandra.thrift.CounterSuperColumn)2 Deletion (org.apache.cassandra.thrift.Deletion)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 SuperColumn (org.apache.cassandra.db.SuperColumn)1 AbstractType (org.apache.cassandra.db.marshal.AbstractType)1 BytesType (org.apache.cassandra.db.marshal.BytesType)1 SuperColumn (org.apache.cassandra.thrift.SuperColumn)1