Example usage for org.apache.cassandra.db CBuilder add

List of usage examples for org.apache.cassandra.db CBuilder add

Introduction

In this page you can find the example usage for org.apache.cassandra.db CBuilder add.

Prototype

public abstract CBuilder add(Object value);

Source Link

Usage

From source file:com.mirantis.magnetodb.cassandra.db.index.MagnetoDBLocalSecondaryIndex.java

License:Apache License

protected CellName makeIndexColumnName(ByteBuffer rowKey, Cell cell) {
    CBuilder builder = getIndexComparator().prefixBuilder();
    builder.add(cell.value());
    CellName cellName = cell.name();//from   ww w  . ja  v  a  2 s  . c o  m
    for (int i = 0; i < Math.min(columnDef.position(), cellName.size()); i++)
        builder.add(cellName.get(i));

    return getIndexComparator().create(builder.build(), columnDef);
}

From source file:com.mirantis.magnetodb.cassandra.db.index.MagnetoDBLocalSecondaryIndex.java

License:Apache License

public IndexedEntry decodeEntry(Cell indexEntry) {
    if (isQueryPropertiesField)
        throw new UnsupportedOperationException();

    CBuilder builder = baseCfs.getComparator().builder();
    for (int i = 0; i < columnDef.position(); i++)
        builder.add(indexEntry.name().get(i + 1));
    return new IndexedEntry(builder, indexEntry.name().get(0));
}

From source file:com.protectwise.cassandra.db.compaction.AbstractClusterDeletingConvictor.java

License:Apache License

Composite buildClusterKey(Composite name) {
    final CBuilder builder = clusterType.builder();
    for (int i = 0; builder.remainingCount() > 0; i++) {
        builder.add(name.get(i));
    }//from  w  w  w.j  a  v  a 2s. c o  m
    return builder.build();
}

From source file:com.tuplejump.stargate.cassandra.TableMapper.java

License:Apache License

public Row getRowWithMetaColumn(ByteBuffer metaColumnValue) {

    if (isMetaColumn) {
        ColumnFamily cleanColumnFamily = ArrayBackedSortedColumns.factory.create(table.metadata);
        CellNameType cellNameType = table.getComparator();
        boolean hasCollections = cellNameType.hasCollections();
        int prefixSize = cellNameType.size() - (hasCollections ? 2 : 1);
        CBuilder builder = cellNameType.builder();
        for (int i = 0; i < prefixSize; i++) {
            AbstractType<?> type = cellNameType.subtype(i);
            builder.add(Fields.defaultValue(type));
        }//from w ww.  j a v a  2s.  c o m
        Composite prefix = builder.build();
        Iterable<ColumnDefinition> cols = table.metadata.regularAndStaticColumns();
        for (ColumnDefinition columnDef : cols) {
            if (columnDef.equals(primaryColumnDefinition)) {
                addColumn(table, cleanColumnFamily, primaryColumnDefinition, prefix, metaColumnValue);
            } else {
                addColumn(table, cleanColumnFamily, columnDef, prefix, Fields.defaultValue(columnDef.type));
            }
        }
        DecoratedKey dk = table.partitioner.decorateKey(defaultPartitionKey);
        return new Row(dk, cleanColumnFamily);

    } else {
        return null;
    }
}

From source file:com.tuplejump.stargate.cassandra.TableMapper.java

License:Apache License

public final Composite start(CellName cellName) {
    CBuilder builder = clusteringCType.builder();
    for (int i = 0; i < cellName.clusteringSize(); i++) {
        ByteBuffer component = cellName.get(i);
        builder.add(component);
    }//from  w w w .  ja  v  a  2  s . com
    return builder.build();
}