@Override public void collect(int docNumber) throws IOException { deleteLucandraDocument(indexName, docNumber, autoCommit); numRemoved.incrementAndGet(); //delete the id reference rm.delete(new QueryPath(CassandraUtils.schemaInfoColumnFamily, ByteBufferUtil.bytes(Integer.toString(docNumber))), System.currentTimeMillis()-1); }
NamesQueryFilter nqf = new NamesQueryFilter(names); SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(ks, ByteBufferUtil.zeroByteBuffer(1), cf, 1L, nqf); StorageProxy.read(ImmutableList.<ReadCommand> of(cmd), ConsistencyLevel.QUORUM);
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);
public SimpleExpression add(ColumnDefinition def, Operator op, ByteBuffer value) { SimpleExpression expression = new SimpleExpression(def, op, value); add(expression); return expression; }
public void addThriftExpression(CFMetaData metadata, ByteBuffer name, Operator op, ByteBuffer value) { assert (this instanceof ThriftFilter); add(new ThriftExpression(metadata, name, op, value)); }
@Override public void onPartitionClose() { // Normally, we don't count static rows as from a CQL point of view, it will be merge with other // rows in the partition. However, if we only have the static row, it will be returned as one row // so count it. if (countPartitionsWithOnlyStaticData && hasLiveStaticRow && rowInCurrentPartition == 0) incrementRowCount(); super.onPartitionClose(); }
/** * @return a QueryFilter object that will return columns matching the given names * @param key the row to slice * @param cfName column family to query * @param columns the column names to restrict the results to, sorted in comparator order */ public static QueryFilter getNamesFilter(DecoratedKey key, String cfName, SortedSet<CellName> columns, long timestamp) { return new QueryFilter(key, cfName, new NamesQueryFilter(columns), timestamp); }
public ColumnCounter columnCounter(CellNameType comparator, long now) { if (compositesToGroup < 0) return new ColumnCounter(now); else if (compositesToGroup == 0) return new ColumnCounter.GroupByPrefix(now, null, 0); else if (reversed) return new ColumnCounter.GroupByPrefixReversed(now, comparator, compositesToGroup); else return new ColumnCounter.GroupByPrefix(now, comparator, compositesToGroup); }
public SimpleExpression add(ColumnDefinition def, Operator op, ByteBuffer value) { SimpleExpression expression = new SimpleExpression(def, op, value); add(expression); return expression; }
public static void addMutations(Map<ByteBuffer, RowMutation> mutationList, String columnFamily, ByteBuffer column, ByteBuffer key, ByteBuffer value) { // Find or create row mutation RowMutation rm = mutationList.get(key); if (rm == null) { rm = new RowMutation(CassandraUtils.keySpace, key); mutationList.put(key, rm); } if (value == null) { // remove if (column != null) { rm.delete(new QueryPath(columnFamily, null, column), System.currentTimeMillis()-1); } else { rm.delete(new QueryPath(columnFamily), System.currentTimeMillis()-1); } } else { // insert rm.add(new QueryPath(columnFamily, null, column), value, System.currentTimeMillis()); } }
public void flush(String core) throws IOException { // Make sure all writes are in for this core writer.commit(core, true); ByteBuffer cacheKey = CassandraUtils.hashKeyBytes((core).getBytes("UTF-8"), CassandraUtils.delimeterBytes, "cache".getBytes("UTF-8")); RowMutation rm = new RowMutation(CassandraUtils.keySpace, cacheKey); rm.add(new QueryPath(CassandraUtils.schemaInfoColumnFamily, CassandraUtils.cachedColBytes, CassandraUtils.cachedColBytes), ByteBufferUtil.EMPTY_BYTE_BUFFER, System.currentTimeMillis()); CassandraUtils.robustInsert(ConsistencyLevel.QUORUM, rm); // also directly notify the local readers SolandraComponent.cacheCheck.put(core, System.currentTimeMillis() - CassandraUtils.cacheInvalidationInterval - 1); }
public RowMutation getIdMutation(String indexName, String key, Long id) throws IOException { int shard = getShardFromDocId(id); ByteBuffer idCol = ByteBufferUtil.bytes(String.valueOf(getShardedDocId(id))); ByteBuffer keyCol = ByteBuffer.wrap(key.getBytes("UTF-8")); // Permanently mark the id as taken ByteBuffer idKey = CassandraUtils.hashKeyBytes((indexName + "~" + shard).getBytes("UTF-8"), CassandraUtils.delimeterBytes, "ids".getBytes("UTF-8")); RowMutation rm = new RowMutation(CassandraUtils.keySpace, idKey); rm.add(new QueryPath(CassandraUtils.schemaInfoColumnFamily, idCol, ByteBuffer .wrap(getToken().getBytes("UTF-8"))), keyCol, System.currentTimeMillis()); return rm; }
List<Row> rows = CassandraUtils.robustRead(keyKey, new QueryPath(CassandraUtils.schemaInfoColumnFamily, CassandraUtils.cachedColBytes), Arrays .asList(CassandraUtils.cachedColBytes), ConsistencyLevel.QUORUM);
ByteBuffer resourceNameBytes = ByteBufferUtil.bytes(resourceName); QueryPath queryPath = new QueryPath( CassandraUtils.schemaInfoColumnFamily, coreNameBytes,
RowMutation rm = new RowMutation(CassandraUtils.keySpace, shardKey); rm.add(new QueryPath(CassandraUtils.schemaInfoColumnFamily, ByteBuffer.wrap(String.valueOf(shard).getBytes( "UTF-8")), ByteBuffer.wrap(myToken.getBytes("UTF-8"))), ByteBuffer.wrap(String.valueOf(offset).getBytes("UTF-8")), System.currentTimeMillis());
public Long checkForUpdate(String indexName, String key) throws IOException { ByteBuffer keyCol = ByteBuffer.wrap(key.getBytes("UTF-8")); ByteBuffer keyKey = CassandraUtils.hashKeyBytes((indexName + "~" + key).getBytes("UTF-8"), CassandraUtils.delimeterBytes, "keys".getBytes("UTF-8")); List<Row> rows = CassandraUtils.robustRead(keyKey, new QueryPath(CassandraUtils.schemaInfoColumnFamily), Arrays.asList(keyCol), ConsistencyLevel.QUORUM); if (rows.size() == 1) { Row row = rows.get(0); if (row.cf != null) { IColumn col = row.cf.getColumn(keyCol); if (col != null) { Collection<IColumn> subCols = col.getSubColumns(); if (subCols != null && !subCols.isEmpty()) { ByteBuffer idVal = col.getSubColumns().iterator().next().name(); Long id = Long.valueOf(ByteBufferUtil.string(idVal)); return id; } } } } return null; }
ByteBuffer resourceNameBytes = ByteBufferUtil.bytes(resourceName); QueryPath queryPath = new QueryPath( CassandraUtils.schemaInfoColumnFamily, coreNameBytes);
ByteBuffer keyCol = ByteBuffer.wrap(term.text().getBytes("UTF-8")); List<Row> rows = CassandraUtils.robustRead(keyKey, new QueryPath(CassandraUtils.schemaInfoColumnFamily), Arrays.asList(keyCol), ConsistencyLevel.QUORUM); rm.delete(new QueryPath(CassandraUtils.schemaInfoColumnFamily, keyCol), System.currentTimeMillis()); CassandraUtils.delimeterBytes, "ids".getBytes("UTF-8")); RowMutation rm2 = new RowMutation(CassandraUtils.keySpace, idKey); rm2.delete(new QueryPath(CassandraUtils.schemaInfoColumnFamily, sidName), System.currentTimeMillis());
ByteBuffer off = id; rm.add(new QueryPath(CassandraUtils.schemaInfoColumnFamily, id, ByteBuffer.wrap(myToken .getBytes("UTF-8"))), off, System.currentTimeMillis(), expirationTime); List<Row> rows = CassandraUtils.robustRead(key, new QueryPath( CassandraUtils.schemaInfoColumnFamily), Arrays.asList(id), ConsistencyLevel.QUORUM); rm.add(new QueryPath(CassandraUtils.schemaInfoColumnFamily, id, ByteBuffer.wrap(myToken .getBytes("UTF-8"))), off, System.currentTimeMillis());