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); 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());
resourceNameBytes); rm.add( queryPath, ByteBufferUtil.bytes(resourceValue),
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()); } }
ByteBuffer off = id; rm.add(new QueryPath(CassandraUtils.schemaInfoColumnFamily, id, ByteBuffer.wrap(myToken .getBytes("UTF-8"))), off, System.currentTimeMillis(), expirationTime); rm.add(new QueryPath(CassandraUtils.schemaInfoColumnFamily, id, ByteBuffer.wrap(myToken .getBytes("UTF-8"))), off, System.currentTimeMillis());
@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.add(columnFamily, e.getColumnAs(StaticBuffer.BB_FACTORY), e.getValueAs(StaticBuffer.BB_FACTORY), commitTime.getAdditionTime(times.getUnit()), ttl); } else { rm.add(columnFamily, e.getColumnAs(StaticBuffer.BB_FACTORY), e.getValueAs(StaticBuffer.BB_FACTORY), commitTime.getAdditionTime(times.getUnit()));
@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, ""); }