Java Code Examples for org.apache.cassandra.utils.ByteBufferUtil#getArray()
The following examples show how to use
org.apache.cassandra.utils.ByteBufferUtil#getArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RowKeyUtilsTest.java From emodb with Apache License 2.0 | 5 votes |
@Test public void testRowKeyRawMin() { ByteBuffer rowKey = RowKeyUtils.getRowKeyRaw(0, 0, ""); assertRowKeyLayout(rowKey, 0, 0, ""); byte[] bytes = ByteBufferUtil.getArray(rowKey); assertEquals(bytes.length, 9); for (byte b : bytes) { assertEquals(b & 0xff, 0); } }
Example 2
Source File: RowKeyUtilsTest.java From emodb with Apache License 2.0 | 5 votes |
@Test public void testRowKeyRawMax() { ByteBuffer rowKey = RowKeyUtils.getRowKeyRaw(0xff, -1L, ""); assertRowKeyLayout(rowKey, 0xff, -1L, ""); byte[] bytes = ByteBufferUtil.getArray(rowKey); assertEquals(bytes.length, 9); for (byte b : bytes) { assertEquals(b & 0xff, 0xff); } }
Example 3
Source File: RowKeyUtilsTest.java From emodb with Apache License 2.0 | 5 votes |
private void assertRowKeyLayout(ByteBuffer actual, int shardId, long tableUuid, String contentKey) { byte[] bytes = ByteBufferUtil.getArray(actual); int idx = 0; // shard id first assertEquals(bytes[idx++] & 0xff, shardId); // table id next, big-endian for (int i = 56; i >= 0; i -= 8) { assertEquals(bytes[idx++] & 0xff, (tableUuid >>> i) & 0xff); } // content key next, UTF-8 assertEquals(new String(bytes, idx, bytes.length - idx, Charsets.UTF_8), contentKey); }
Example 4
Source File: DataOutputTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@Test public void testDataOutputDirectByteBuffer() throws IOException { ByteBuffer buf = wrap(new byte[345], true); DataOutputByteBuffer write = new DataOutputByteBuffer(buf.duplicate()); DataInput canon = testWrite(write); DataInput test = new DataInputStream(new ByteArrayInputStream(ByteBufferUtil.getArray(buf))); testRead(test, canon); }
Example 5
Source File: DataOutputTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@Test public void testDataOutputHeapByteBuffer() throws IOException { ByteBuffer buf = wrap(new byte[345], false); DataOutputByteBuffer write = new DataOutputByteBuffer(buf.duplicate()); DataInput canon = testWrite(write); DataInput test = new DataInputStream(new ByteArrayInputStream(ByteBufferUtil.getArray(buf))); testRead(test, canon); }
Example 6
Source File: CassandraRowId.java From cassandra-jdbc-wrapper with Apache License 2.0 | 4 votes |
public byte[] getBytes() { return ByteBufferUtil.getArray(bytes); }
Example 7
Source File: BytesToken.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public BytesToken(ByteBuffer token) { this(ByteBufferUtil.getArray(token)); }
Example 8
Source File: RandomPartitioner.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public Token fromByteArray(ByteBuffer bytes) { return new BigIntegerToken(new BigInteger(ByteBufferUtil.getArray(bytes))); }
Example 9
Source File: IntegerSerializer.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public BigInteger deserialize(ByteBuffer bytes) { return bytes.hasRemaining() ? new BigInteger(ByteBufferUtil.getArray(bytes)) : null; }
Example 10
Source File: CassandraHiveRecordReader.java From Hive-Cassandra with Apache License 2.0 | 4 votes |
private BytesWritable convertByteBuffer(ByteBuffer val) { return new BytesWritable(ByteBufferUtil.getArray(val)); }