@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); }
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; }
int shardedId = getShardedDocId(id); ByteBuffer idCol = ByteBufferUtil.bytes(String.valueOf(shardedId)); ByteBuffer keyCol = ByteBuffer.wrap(key.getBytes("UTF-8"));
ByteBuffer id = ByteBufferUtil.bytes(String.valueOf(nextOffset)); ByteBuffer off = id;
/** * Compose. * * @param value * the value * @param clazz * the clazz * @return the byte[] */ private static byte[] compose(Object value, Class clazz) { return ByteBufferUtil.bytes((Long) value).array(); }
/** * Compose. * * @param value * the value * @param clazz * the clazz * @return the byte[] */ private static byte[] compose(Object value, Class clazz) { return ByteBufferUtil.bytes((String) value).array(); }
/** * Compose. * * @param value * the value * @param clazz * the clazz * @return the byte[] */ private static byte[] compose(Object value, Class clazz) { return ByteBufferUtil.bytes((Integer) value).array(); }
/** * Compose. * * @param value * the value * @param clazz * the clazz * @return the byte[] */ private static byte[] compose(Object value, Class clazz) { return ByteBufferUtil.bytes((Double) value).array(); }
/** * Compose. * * @param value * the value * @param clazz * the clazz * @return the byte[] */ private static byte[] compose(Object value, Class clazz) { return ByteBufferUtil.bytes((Float) value).array(); }
@Test public void testFromCassandraAsBytes() { assertEquals(new Integer(1), ext.fromBytes(ByteBufferUtil.bytes(1).array())); assertEquals(new Integer(-1), ext.fromBytes(ByteBufferUtil.bytes(-1).array())); assertEquals(new Integer(0), ext.fromBytes(ByteBufferUtil.bytes(0).array())); assertEquals(new Integer(Integer.MAX_VALUE), ext.fromBytes(ByteBufferUtil.bytes(Integer.MAX_VALUE).array())); assertEquals(new Integer(Integer.MIN_VALUE), ext.fromBytes(ByteBufferUtil.bytes(Integer.MIN_VALUE).array())); }
@Test public void testFromCassandra() { assertEquals(new Integer(1), ext.fromByteBuffer(ByteBufferUtil.bytes(1))); assertEquals(new Integer(-1), ext.fromByteBuffer(ByteBufferUtil.bytes(-1))); assertEquals(new Integer(0), ext.fromByteBuffer(ByteBufferUtil.bytes(0))); assertEquals(new Integer(Integer.MAX_VALUE), ext.fromByteBuffer(ByteBufferUtil.bytes(Integer.MAX_VALUE))); assertEquals(new Integer(Integer.MIN_VALUE), ext.fromByteBuffer(ByteBufferUtil.bytes(Integer.MIN_VALUE))); }
@Test public void testFromCassandra() { assertEquals(new Long(1), ext.fromByteBuffer(ByteBufferUtil.bytes(1L))); assertEquals(new Long(0), ext.fromByteBuffer(ByteBufferUtil.bytes(0L))); assertEquals(new Long(-1), ext.fromByteBuffer(ByteBufferUtil.bytes(-1L))); assertEquals(new Long(Long.MIN_VALUE), ext.fromByteBuffer(ByteBufferUtil.bytes(Long.MIN_VALUE))); assertEquals(new Long(Long.MAX_VALUE), ext.fromByteBuffer(ByteBufferUtil.bytes(Long.MAX_VALUE))); }
static ByteBuffer createCompositeKey(String s, UUID uuid, int i, boolean lastIsOne) { ByteBuffer bytes = ByteBufferUtil.bytes(s); int totalSize = 0; if (s != null) {
log.debug("Executing cql query {}.", cqlQuery); return conn.execute_cql_query(ByteBufferUtil.bytes(cqlQuery), org.apache.cassandra.thrift.Compression.NONE); } catch (Exception ex) { if (log.isErrorEnabled()) {
@Test public void test() throws Exception { Assert.assertEquals(str, s.fromByteBuffer(s.toByteBuffer(str))); if (str != null) { Assert .assertEquals(str, ByteBufferUtil.string(ByteBufferUtil.bytes(str))); } if (str != null) { UTF8Type.instance.validate(s.toByteBuffer(str)); } } }
.bytes("create table \"SECONDARY_TABLE\"(\"OBJECT_ID\" text PRIMARY KEY, \"AGE\" int)"), org.apache.cassandra.thrift.Compression.NONE, org.apache.cassandra.thrift.ConsistencyLevel.ANY);