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; }
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); }
RowMutation rm = new RowMutation(CassandraUtils.keySpace, shardKey);
CassandraUtils.delimeterBytes, "resources".getBytes("UTF-8")); RowMutation rm = new RowMutation(CassandraUtils.keySpace, coreKey);
final RowMutation rm = new RowMutation(CassandraUtils.keySpace, idKey); workingMutations.put(idKey, rm);
CassandraUtils.delimeterBytes, "ids".getBytes("UTF-8")); RowMutation rm = new RowMutation(CassandraUtils.keySpace, idKey); rm.add(new QueryPath(CassandraUtils.schemaInfoColumnFamily, idCol, ByteBuffer.wrap(myToken .getBytes("UTF-8"))), keyCol, System.currentTimeMillis()); RowMutation rm2 = new RowMutation(CassandraUtils.keySpace, keyKey); rm2.add(new QueryPath(CassandraUtils.schemaInfoColumnFamily, keyCol, idVal), CassandraUtils.finalTokenBytes, System.currentTimeMillis());
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()); } }
RowMutation rm = new RowMutation(CassandraUtils.keySpace, keyKey); rm.delete(new QueryPath(CassandraUtils.schemaInfoColumnFamily, keyCol), System.currentTimeMillis()); RowMutation rm2 = new RowMutation(CassandraUtils.keySpace, idKey); rm2.delete(new QueryPath(CassandraUtils.schemaInfoColumnFamily, sidName), System.currentTimeMillis());
RowMutation rm = new RowMutation(CassandraUtils.keySpace, key); rm = new RowMutation(CassandraUtils.keySpace, key);
@Override public ResponseData batchMutate(Object key, Map<?, ?> nv) throws OperationException { ByteBuffer rKey = kser.toByteBuffer(key); RowMutation change = new RowMutation(ks, rKey); for (Map.Entry entry : nv.entrySet()) { ByteBuffer name = colser.toByteBuffer(entry.getKey()); ByteBuffer val = valser.toByteBuffer(entry.getValue()); ColumnPath cp = new ColumnPath(cf).setColumn(name); change.add(new QueryPath(cp), val, System.currentTimeMillis()); } try { StorageProxy.mutate(Arrays.asList(change), wConsistecy); } catch (Exception e) { throw new OperationException(e); } return new ResponseData("", 0, ""); }
rm = new RowMutation(keySpaceName, key.asByteBuffer()); rowMutations.put(key, rm);
@Override public ResponseData put(Object key, Object colName, Object value) throws OperationException { ByteBuffer rKey = kser.toByteBuffer(key); ByteBuffer name = colser.toByteBuffer(colName); ByteBuffer val = valser.toByteBuffer(value); RowMutation change = new RowMutation(ks, rKey); ColumnPath cp = new ColumnPath(cf).setColumn(name); change.add(new QueryPath(cp), val, System.currentTimeMillis()); try { StorageProxy.mutate(Arrays.asList(change), wConsistecy); } catch (Exception e) { throw new OperationException(e); } return new ResponseData("", 0, ""); }