List of usage examples for org.apache.cassandra.utils ByteBufferUtil hexToBytes
public static ByteBuffer hexToBytes(String str)
From source file:com.stratio.cassandra.index.schema.ColumnMapperBlobTest.java
License:Apache License
@Test public void testValueByteBuffer() { ColumnMapperBlob mapper = new ColumnMapperBlob(); ByteBuffer bb = ByteBufferUtil.hexToBytes("f1"); String parsed = mapper.indexValue("test", bb); Assert.assertEquals("f1", parsed); }
From source file:com.stratio.cassandra.lucene.schema.mapping.BlobMapperTest.java
License:Apache License
@Test public void testValueByteBuffer() { BlobMapper mapper = new BlobMapper("field", null, null); ByteBuffer bb = ByteBufferUtil.hexToBytes("f1"); String parsed = mapper.base("test", bb); assertEquals("f1", parsed); }
From source file:net.imagini.cassandra.DumpSSTables.SSTableExport.java
License:Apache License
/** * Export specific rows from an SSTable and write the resulting JSON to a * PrintStream./*from w w w. ja v a2 s . com*/ * * @param desc * the descriptor of the sstable table to read from * @param outs * PrintStream to write the output to * @param toExport * the keys corresponding to the rows to export * @param excludes * keys to exclude from export * @throws IOException * on failure to read/write input/output */ public static void export(Descriptor desc, PrintStream outs, Collection<String> toExport, String[] excludes) throws IOException { SSTableReader reader = SSTableReader.open(desc); SSTableScanner scanner = reader.getDirectScanner(); IPartitioner<?> partitioner = reader.partitioner; if (excludes != null) toExport.removeAll(Arrays.asList(excludes)); int i = 0; // last key to compare order DecoratedKey lastKey = null; for (String key : toExport) { DecoratedKey decoratedKey = partitioner.decorateKey(ByteBufferUtil.hexToBytes(key)); if (lastKey != null && lastKey.compareTo(decoratedKey) > 0) throw new IOException("Key out of order! " + lastKey + " > " + decoratedKey); lastKey = decoratedKey; scanner.seekTo(decoratedKey); if (!scanner.hasNext()) continue; SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next(); if (!row.getKey().equals(decoratedKey)) continue; serializeRow(row, decoratedKey, outs); if (i != 0) outs.println(","); i++; } outs.println("\n"); outs.flush(); scanner.close(); }