Search in sources :

Example 6 with Composite

use of org.apache.cassandra.db.composites.Composite in project stargate-core by tuplejump.

the class RowIndexSupport method deleteRowsMarked.

public void deleteRowsMarked(Indexer indexer, DeletionInfo deletionInfo) {
    //this is a delete
    //get the range tombstones
    Iterator<RangeTombstone> rangeIterator = deletionInfo.rangeIterator();
    while (rangeIterator.hasNext()) {
        RangeTombstone rangeTombstone = rangeIterator.next();
        Composite start = rangeTombstone.min;
        String startPK = tableMapper.clusteringCType.getString(start);
        Composite end = rangeTombstone.max;
        String endPK = tableMapper.clusteringCType.getString(end);
        Query deleteQuery = LuceneUtils.getPKRangeDeleteQuery(startPK, endPK);
        indexer.delete(deleteQuery);
    }
}
Also used : Composite(org.apache.cassandra.db.composites.Composite) Query(org.apache.lucene.search.Query)

Example 7 with Composite

use of org.apache.cassandra.db.composites.Composite in project stargate-core by tuplejump.

the class RowIndexSupport method addPartitionKeyFields.

private void addPartitionKeyFields(ByteBuffer rowKey, long timestamp, IndexEntryBuilder builder) {
    CType keyCType = tableMapper.cfMetaData.getKeyValidatorAsCType();
    Composite compoundRowKey = keyCType.fromByteBuffer(rowKey);
    for (Map.Entry<String, ColumnDefinition> entry : options.partitionKeysIndexed.entrySet()) {
        ByteBuffer value = compoundRowKey.get(entry.getValue().position());
        addKeyField(timestamp, entry, value, builder);
    }
}
Also used : Composite(org.apache.cassandra.db.composites.Composite) CType(org.apache.cassandra.db.composites.CType) ByteBuffer(java.nio.ByteBuffer) ColumnDefinition(org.apache.cassandra.config.ColumnDefinition)

Example 8 with Composite

use of org.apache.cassandra.db.composites.Composite in project janusgraph by JanusGraph.

the class CassandraEmbeddedKeyColumnValueStore method getSlice.

@Override
public EntryList getSlice(KeySliceQuery query, StoreTransaction txh) throws BackendException {
    /**
     * This timestamp mimics the timestamp used by
     * {@link org.apache.cassandra.thrift.CassandraServer#get(ByteBuffer,ColumnPath,ConsistencyLevel)}.
     *
     * That method passes the server's System.currentTimeMillis() to
     * {@link ReadCommand#create(String, ByteBuffer, String, long, IDiskAtomFilter)}.
     * {@code create(...)} in turn passes that timestamp to the SliceFromReadCommand constructor.
     */
    final long nowMillis = times.getTime().toEpochMilli();
    Composite startComposite = CellNames.simpleDense(query.getSliceStart().asByteBuffer());
    Composite endComposite = CellNames.simpleDense(query.getSliceEnd().asByteBuffer());
    SliceQueryFilter sqf = new SliceQueryFilter(startComposite, endComposite, false, query.getLimit() + (query.hasLimit() ? 1 : 0));
    ReadCommand sliceCmd = new SliceFromReadCommand(keyspace, query.getKey().asByteBuffer(), columnFamily, nowMillis, sqf);
    List<Row> slice = read(sliceCmd, getTx(txh).getReadConsistencyLevel().getDB());
    if (null == slice || 0 == slice.size())
        return EntryList.EMPTY_LIST;
    int sliceSize = slice.size();
    if (1 < sliceSize)
        throw new PermanentBackendException("Received " + sliceSize + " rows for single key");
    Row r = slice.get(0);
    if (null == r) {
        log.warn("Null Row object retrieved from Cassandra StorageProxy");
        return EntryList.EMPTY_LIST;
    }
    ColumnFamily cf = r.cf;
    if (null == cf) {
        log.debug("null ColumnFamily (\"{}\")", columnFamily);
        return EntryList.EMPTY_LIST;
    }
    if (cf.isMarkedForDelete())
        return EntryList.EMPTY_LIST;
    return CassandraHelper.makeEntryList(Iterables.filter(cf.getSortedColumns(), new FilterDeletedColumns(nowMillis)), entryGetter, query.getSliceEnd(), query.getLimit());
}
Also used : Composite(org.apache.cassandra.db.composites.Composite) SliceQueryFilter(org.apache.cassandra.db.filter.SliceQueryFilter)

Aggregations

Composite (org.apache.cassandra.db.composites.Composite)8 ColumnSlice (org.apache.cassandra.db.filter.ColumnSlice)3 SliceQueryFilter (org.apache.cassandra.db.filter.SliceQueryFilter)3 IndexEntry (com.tuplejump.stargate.lucene.IndexEntryCollector.IndexEntry)2 ColumnDefinition (org.apache.cassandra.config.ColumnDefinition)2 CellName (org.apache.cassandra.db.composites.CellName)2 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 ColumnIdentifier (org.apache.cassandra.cql3.ColumnIdentifier)1 CType (org.apache.cassandra.db.composites.CType)1 QueryFilter (org.apache.cassandra.db.filter.QueryFilter)1 Query (org.apache.lucene.search.Query)1