Modified: cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java Wed Jan 19 17:14:06 2011 @@ -18,13 +18,17 @@ */ package org.apache.cassandra.utils; +import java.io.DataInput; import java.io.DataOutput; +import java.io.EOFException; import java.io.IOException; +import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.Arrays; +import org.apache.cassandra.io.util.FileDataInput; import org.apache.commons.lang.ArrayUtils; /** @@ -267,4 +271,132 @@ public class ByteBufferUtil throw new RuntimeException(e); } } + + public static ByteBuffer readWithLength(DataInput in) throws IOException + { + int length = in.readInt(); + if (length < 0) + { + throw new IOException("Corrupt (negative) value length encountered"); + } + + return ByteBufferUtil.read(in, length); + } + + /* @return An unsigned short in an integer. */ + private static int readShortLength(DataInput in) throws IOException + { + int length = (in.readByte() & 0xFF) << 8; + return length | (in.readByte() & 0xFF); + } + + /** + * @param in data input + * @return An unsigned short in an integer. + * @throws IOException if an I/O error occurs. + */ + public static ByteBuffer readWithShortLength(DataInput in) throws IOException + { + return ByteBufferUtil.read(in, readShortLength(in)); + } + + /** + * @param in data input + * @return null + * @throws IOException if an I/O error occurs. + */ + public static ByteBuffer skipShortLength(DataInput in) throws IOException + { + int skip = readShortLength(in); + while (skip > 0) + { + int skipped = in.skipBytes(skip); + if (skipped == 0) throw new EOFException(); + skip -= skipped; + } + return null; + } + + private static ByteBuffer read(DataInput in, int length) throws IOException + { + ByteBuffer array; + + if (in instanceof FileDataInput) + { + array = ((FileDataInput) in).readBytes(length); + } + else + { + byte[] buff = new byte[length]; + in.readFully(buff); + array = ByteBuffer.wrap(buff); + } + + return array; + } + + /** + * Convert a byte buffer to an integer. + * Does not change the byte buffer position. + * + * @param bytes byte buffer to convert to integer + * @return int representation of the byte buffer + */ + public static int toInt(ByteBuffer bytes) + { + return bytes.getInt(bytes.position()); + } + + public static ByteBuffer bytes(int i) + { + return ByteBuffer.allocate(4).putInt(0, i); + } + + public static ByteBuffer bytes(long n) + { + return ByteBuffer.allocate(8).putLong(0, n); + } + + public static InputStream inputStream(ByteBuffer bytes) + { + final ByteBuffer copy = bytes.duplicate(); + + return new InputStream() + { + public int read() throws IOException + { + if (!copy.hasRemaining()) + return -1; + + return copy.get(); + } + + public int read(byte[] bytes, int off, int len) throws IOException + { + len = Math.min(len, copy.remaining()); + copy.get(bytes, off, len); + + return len; + } + }; + } + + public static String bytesToHex(ByteBuffer bytes) + { + StringBuilder sb = new StringBuilder(); + for (int i = bytes.position(); i < bytes.limit(); i++) + { + int bint = bytes.get(i) & 0xff; + if (bint <= 0xF) + // toHexString does not 0 pad its results. + sb.append("0"); + sb.append(Integer.toHexString(bint)); + } + return sb.toString(); + } + + public static ByteBuffer hexToBytes(String str) + { + return ByteBuffer.wrap(FBUtilities.hexToBytes(str)); + } }
Modified: cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java Wed Jan 19 17:14:06 2011 @@ -36,7 +36,6 @@ import java.util.concurrent.atomic.Atomi import com.google.common.base.Charsets; import com.google.common.base.Joiner; -import org.apache.cassandra.io.util.FileDataInput; import org.apache.commons.collections.iterators.CollatingIterator; import org.apache.commons.lang.ArrayUtils; import org.slf4j.Logger; @@ -194,38 +193,6 @@ public class FBUtilities } /** - * Convert a byte buffer to an integer. - * Does not change the byte buffer position. - * - * @param bytes byte buffer to convert to integer - * @return int representation of the byte buffer - */ - public static int byteBufferToInt(ByteBuffer bytes) - { - if (bytes.remaining() < 4) - { - throw new IllegalArgumentException("An integer must be 4 bytes in size."); - } - int n = 0; - for (int i = 0; i < 4; ++i) - { - n <<= 8; - n |= bytes.get(bytes.position() + i) & 0xFF; - } - return n; - } - - public static ByteBuffer toByteBuffer(int i) - { - byte[] bytes = new byte[4]; - bytes[0] = (byte)( ( i >>> 24 ) & 0xFF); - bytes[1] = (byte)( ( i >>> 16 ) & 0xFF); - bytes[2] = (byte)( ( i >>> 8 ) & 0xFF); - bytes[3] = (byte)( i & 0xFF ); - return ByteBuffer.wrap(bytes); - } - - /** * Copy bytes from long into bytes starting from offset. * @param bytes Target array * @param offset Offset into the array @@ -253,7 +220,7 @@ public class FBUtilities copyIntoBytes(bytes, 0, l); return bytes; } - + /** * @param bytes A byte array containing a serialized long. * @return The long value contained in the byte array. @@ -284,13 +251,6 @@ public class FBUtilities return n; } - public static ByteBuffer toByteBuffer(long n) - { - byte[] bytes = new byte[8]; - ByteBuffer bb = ByteBuffer.wrap(bytes).putLong(0, n); - return bb; - } - public static int compareUnsigned(byte[] bytes1, byte[] bytes2, int offset1, int offset2, int len1, int len2) { if (bytes1 == null) @@ -394,51 +354,6 @@ public class FBUtilities return result; } - public static ByteBuffer readByteArray(DataInput in) throws IOException - { - int length = in.readInt(); - if (length < 0) - { - throw new IOException("Corrupt (negative) value length encountered"); - } - - return readDataBytes(in, length); - } - - /* @return An unsigned short in an integer. */ - private static int readShortLength(DataInput in) throws IOException - { - int length = (in.readByte() & 0xFF) << 8; - return length | (in.readByte() & 0xFF); - } - - /** - * @param in data input - * @return An unsigned short in an integer. - * @throws IOException if an I/O error occurs. - */ - public static ByteBuffer readShortByteArray(DataInput in) throws IOException - { - return readDataBytes(in, readShortLength(in)); - } - - /** - * @param in data input - * @return null - * @throws IOException if an I/O error occurs. - */ - public static byte[] skipShortByteArray(DataInput in) throws IOException - { - int skip = readShortLength(in); - while (skip > 0) - { - int skipped = in.skipBytes(skip); - if (skipped == 0) throw new EOFException(); - skip -= skipped; - } - return null; - } - public static byte[] hexToBytes(String str) { if (str.length() % 2 == 1) @@ -465,20 +380,6 @@ public class FBUtilities return sb.toString(); } - public static String bytesToHex(ByteBuffer bytes) - { - StringBuilder sb = new StringBuilder(); - for (int i = bytes.position(); i < bytes.limit(); i++) - { - int bint = bytes.get(i) & 0xff; - if (bint <= 0xF) - // toHexString does not 0 pad its results. - sb.append("0"); - sb.append(Integer.toHexString(bint)); - } - return sb.toString(); - } - public static void renameWithConfirm(String tmpFilename, String filename) throws IOException { if (!new File(tmpFilename).renameTo(new File(filename))) @@ -791,46 +692,4 @@ public class FBUtilities return field; } - - private static ByteBuffer readDataBytes(DataInput in, int length) throws IOException - { - ByteBuffer array; - - if (in instanceof FileDataInput) - { - array = ((FileDataInput) in).readBytes(length); - } - else - { - byte[] buff = new byte[length]; - in.readFully(buff); - array = ByteBuffer.wrap(buff); - } - - return array; - } - - public static InputStream inputStream(ByteBuffer bytes) - { - final ByteBuffer copy = ByteBufferUtil.clone(bytes); - - return new InputStream() - { - public int read() throws IOException - { - if (!copy.hasRemaining()) - return -1; - - return copy.get(); - } - - public int read(byte[] bytes, int off, int len) throws IOException - { - len = Math.min(len, copy.remaining()); - copy.get(bytes, off, len); - - return len; - } - }; - } } Modified: cassandra/trunk/src/java/org/apache/cassandra/utils/GuidGenerator.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/utils/GuidGenerator.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/utils/GuidGenerator.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/utils/GuidGenerator.java Wed Jan 19 17:14:06 2011 @@ -34,7 +34,21 @@ public class GuidGenerator { private static Random myRand; private static SecureRandom mySecureRand; private static String s_id; - private static SafeMessageDigest md5 = null; + private static final ThreadLocal<MessageDigest> localMessageDigest = new ThreadLocal<MessageDigest>() + { + @Override + protected MessageDigest initialValue() + { + try + { + return MessageDigest.getInstance("MD5"); + } + catch (NoSuchAlgorithmException e) + { + throw new AssertionError(e); + } + } + }; static { if (System.getProperty("java.security.egd") == null) { @@ -49,17 +63,8 @@ public class GuidGenerator { catch (UnknownHostException e) { throw new AssertionError(e); } - - try { - MessageDigest myMd5 = MessageDigest.getInstance("MD5"); - md5 = new SafeMessageDigest(myMd5); - } - catch (NoSuchAlgorithmException e) { - throw new AssertionError(e); - } } - public static String guid() { ByteBuffer array = guidAsBytes(); @@ -99,7 +104,8 @@ public class GuidGenerator { .append(Long.toString(rand)); String valueBeforeMD5 = sbValueBeforeMD5.toString(); - return ByteBuffer.wrap(md5.digest(valueBeforeMD5.getBytes())); + localMessageDigest.get().reset(); + return ByteBuffer.wrap(localMessageDigest.get().digest(valueBeforeMD5.getBytes())); } /* Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java (original) +++ cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java Wed Jan 19 17:14:06 2011 @@ -49,7 +49,6 @@ import org.apache.cassandra.thrift.Index import org.apache.cassandra.thrift.IndexExpression; import org.apache.cassandra.thrift.IndexOperator; import org.apache.cassandra.thrift.IndexType; -import org.apache.cassandra.utils.FBUtilities; import org.apache.cassandra.utils.WrappedRunnable; import static junit.framework.Assert.assertEquals; @@ -140,27 +139,27 @@ public class ColumnFamilyStoreTest exten RowMutation rm; rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("k1")); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("notbirthdate")), FBUtilities.toByteBuffer(1L), 0); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 0); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("notbirthdate")), ByteBufferUtil.bytes(1L), 0); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 0); rm.apply(); rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("k2")); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("notbirthdate")), FBUtilities.toByteBuffer(2L), 0); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(2L), 0); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("notbirthdate")), ByteBufferUtil.bytes(2L), 0); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(2L), 0); rm.apply(); rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("k3")); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("notbirthdate")), FBUtilities.toByteBuffer(2L), 0); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 0); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("notbirthdate")), ByteBufferUtil.bytes(2L), 0); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 0); rm.apply(); rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("k4aaaa")); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("notbirthdate")), FBUtilities.toByteBuffer(2L), 0); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(3L), 0); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("notbirthdate")), ByteBufferUtil.bytes(2L), 0); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(3L), 0); rm.apply(); // basic single-expression query - IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, FBUtilities.toByteBuffer(1L)); + IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, ByteBufferUtil.bytes(1L)); IndexClause clause = new IndexClause(Arrays.asList(expr), ByteBufferUtil.EMPTY_BYTE_BUFFER, 100); IFilter filter = new IdentityQueryFilter(); IPartitioner p = StorageService.getPartitioner(); @@ -176,11 +175,11 @@ public class ColumnFamilyStoreTest exten key = new String(rows.get(1).key.key.array(),rows.get(1).key.key.position(),rows.get(1).key.key.remaining()); assert "k3".equals(key); - assert FBUtilities.toByteBuffer(1L).equals( rows.get(0).cf.getColumn(ByteBufferUtil.bytes("birthdate")).value()); - assert FBUtilities.toByteBuffer(1L).equals( rows.get(1).cf.getColumn(ByteBufferUtil.bytes("birthdate")).value()); + assert ByteBufferUtil.bytes(1L).equals( rows.get(0).cf.getColumn(ByteBufferUtil.bytes("birthdate")).value()); + assert ByteBufferUtil.bytes(1L).equals( rows.get(1).cf.getColumn(ByteBufferUtil.bytes("birthdate")).value()); // add a second expression - IndexExpression expr2 = new IndexExpression(ByteBufferUtil.bytes("notbirthdate"), IndexOperator.GTE, FBUtilities.toByteBuffer(2L)); + IndexExpression expr2 = new IndexExpression(ByteBufferUtil.bytes("notbirthdate"), IndexOperator.GTE, ByteBufferUtil.bytes(2L)); clause = new IndexClause(Arrays.asList(expr, expr2), ByteBufferUtil.EMPTY_BYTE_BUFFER, 100); rows = Table.open("Keyspace1").getColumnFamilyStore("Indexed1").scan(clause, range, filter); @@ -209,7 +208,7 @@ public class ColumnFamilyStoreTest exten // query with index hit but rejected by secondary clause, with a small enough count that just checking count // doesn't tell the scan loop that it's done - IndexExpression expr3 = new IndexExpression(ByteBufferUtil.bytes("notbirthdate"), IndexOperator.EQ, FBUtilities.toByteBuffer(-1L)); + IndexExpression expr3 = new IndexExpression(ByteBufferUtil.bytes("notbirthdate"), IndexOperator.EQ, ByteBufferUtil.bytes(-1L)); clause = new IndexClause(Arrays.asList(expr, expr3), ByteBufferUtil.EMPTY_BYTE_BUFFER, 1); rows = Table.open("Keyspace1").getColumnFamilyStore("Indexed1").scan(clause, range, filter); @@ -223,10 +222,10 @@ public class ColumnFamilyStoreTest exten RowMutation rm; rm = new RowMutation("Keyspace3", ByteBufferUtil.bytes("k1")); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 0); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 0); rm.apply(); - IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, FBUtilities.toByteBuffer(1L)); + IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, ByteBufferUtil.bytes(1L)); IndexClause clause = new IndexClause(Arrays.asList(expr), ByteBufferUtil.EMPTY_BYTE_BUFFER, 100); IFilter filter = new IdentityQueryFilter(); IPartitioner p = StorageService.getPartitioner(); @@ -245,7 +244,7 @@ public class ColumnFamilyStoreTest exten // verify that it's not being indexed under the deletion column value either IColumn deletion = rm.getColumnFamilies().iterator().next().iterator().next(); - ByteBuffer deletionLong = FBUtilities.toByteBuffer((long) FBUtilities.byteBufferToInt(deletion.value())); + ByteBuffer deletionLong = ByteBufferUtil.bytes((long) ByteBufferUtil.toInt(deletion.value())); IndexExpression expr0 = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, deletionLong); IndexClause clause0 = new IndexClause(Arrays.asList(expr0), ByteBufferUtil.EMPTY_BYTE_BUFFER, 100); rows = cfs.scan(clause0, range, filter); @@ -253,7 +252,7 @@ public class ColumnFamilyStoreTest exten // resurrect w/ a newer timestamp rm = new RowMutation("Keyspace3", ByteBufferUtil.bytes("k1")); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 2); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 2); rm.apply(); rows = cfs.scan(clause, range, filter); assert rows.size() == 1 : StringUtils.join(rows, ","); @@ -276,13 +275,13 @@ public class ColumnFamilyStoreTest exten // create a row and update the birthdate value, test that the index query fetches the new version RowMutation rm; rm = new RowMutation("Keyspace2", ByteBufferUtil.bytes("k1")); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 1); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 1); rm.apply(); rm = new RowMutation("Keyspace2", ByteBufferUtil.bytes("k1")); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(2L), 2); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(2L), 2); rm.apply(); - IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, FBUtilities.toByteBuffer(1L)); + IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, ByteBufferUtil.bytes(1L)); IndexClause clause = new IndexClause(Arrays.asList(expr), ByteBufferUtil.EMPTY_BYTE_BUFFER, 100); IFilter filter = new IdentityQueryFilter(); IPartitioner p = StorageService.getPartitioner(); @@ -290,7 +289,7 @@ public class ColumnFamilyStoreTest exten List<Row> rows = table.getColumnFamilyStore("Indexed1").scan(clause, range, filter); assert rows.size() == 0; - expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, FBUtilities.toByteBuffer(2L)); + expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, ByteBufferUtil.bytes(2L)); clause = new IndexClause(Arrays.asList(expr), ByteBufferUtil.EMPTY_BYTE_BUFFER, 100); rows = table.getColumnFamilyStore("Indexed1").scan(clause, range, filter); String key = new String(rows.get(0).key.key.array(),rows.get(0).key.key.position(),rows.get(0).key.key.remaining()); @@ -298,7 +297,7 @@ public class ColumnFamilyStoreTest exten // update the birthdate value with an OLDER timestamp, and test that the index ignores this rm = new RowMutation("Keyspace2", ByteBufferUtil.bytes("k1")); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(3L), 0); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(3L), 0); rm.apply(); rows = table.getColumnFamilyStore("Indexed1").scan(clause, range, filter); @@ -315,7 +314,7 @@ public class ColumnFamilyStoreTest exten // create a row and update the birthdate value, test that the index query fetches the new version RowMutation rm; rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("k1")); - rm.add(new QueryPath("Indexed2", null, ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 1); + rm.add(new QueryPath("Indexed2", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 1); rm.apply(); ColumnFamilyStore cfs = table.getColumnFamilyStore("Indexed2"); @@ -325,7 +324,7 @@ public class ColumnFamilyStoreTest exten while (!SystemTable.isIndexBuilt("Keyspace1", cfs.getIndexedColumnFamilyStore(ByteBufferUtil.bytes("birthdate")).columnFamily)) TimeUnit.MILLISECONDS.sleep(100); - IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, FBUtilities.toByteBuffer(1L)); + IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, ByteBufferUtil.bytes(1L)); IndexClause clause = new IndexClause(Arrays.asList(expr), ByteBufferUtil.EMPTY_BYTE_BUFFER, 100); IFilter filter = new IdentityQueryFilter(); IPartitioner p = StorageService.getPartitioner(); Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/CounterColumnTest.java URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/CounterColumnTest.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/test/unit/org/apache/cassandra/db/CounterColumnTest.java (original) +++ cassandra/trunk/test/unit/org/apache/cassandra/db/CounterColumnTest.java Wed Jan 19 17:14:06 2011 @@ -63,7 +63,7 @@ public class CounterColumnTest { AbstractCommutativeType type = CounterColumnType.instance; long delta = 3L; - CounterColumn column = (CounterColumn)type.createColumn(ByteBufferUtil.bytes("x"), FBUtilities.toByteBuffer(delta), 1L); + CounterColumn column = (CounterColumn)type.createColumn(ByteBufferUtil.bytes("x"), ByteBufferUtil.bytes(delta), 1L); assert delta == column.value().getLong(column.value().arrayOffset()); assert 0 == column.partitionedCounter().length; @@ -78,12 +78,12 @@ public class CounterColumnTest @Test public void testUpdate() throws UnknownHostException { - CounterColumn c = new CounterColumn(ByteBufferUtil.bytes("x"), FBUtilities.toByteBuffer(0L), 0L); + CounterColumn c = new CounterColumn(ByteBufferUtil.bytes("x"), ByteBufferUtil.bytes(0L), 0L); assert 0L == c.value().getLong(c.value().arrayOffset()); assert c.partitionedCounter().length == 0 : "badly formatted initial context"; - c.value = FBUtilities.toByteBuffer(1L); + c.value = ByteBufferUtil.bytes(1L); c.update(InetAddress.getByAddress(FBUtilities.toByteArray(1))); assert 1L == c.value().getLong(c.value().arrayOffset()); @@ -93,13 +93,13 @@ public class CounterColumnTest assert 1L == FBUtilities.byteArrayToLong(c.partitionedCounter(), 0*stepLength + idLength); assert 1L == FBUtilities.byteArrayToLong(c.partitionedCounter(), 0*stepLength + idLength + clockLength); - c.value = FBUtilities.toByteBuffer(3L); + c.value = ByteBufferUtil.bytes(3L); c.update(InetAddress.getByAddress(FBUtilities.toByteArray(2))); - c.value = FBUtilities.toByteBuffer(2L); + c.value = ByteBufferUtil.bytes(2L); c.update(InetAddress.getByAddress(FBUtilities.toByteArray(2))); - c.value = FBUtilities.toByteBuffer(9L); + c.value = ByteBufferUtil.bytes(9L); c.update(InetAddress.getByAddress(FBUtilities.toByteArray(2))); assert 15L == c.value().getLong(c.value().arrayOffset()); @@ -128,28 +128,28 @@ public class CounterColumnTest assert left.reconcile(right).timestamp() == right.timestamp(); assert right.reconcile(left).timestamp() == right.timestamp(); - + // tombstone > live left = new DeletedColumn(ByteBufferUtil.bytes("x"), 1, 2L); - right = new CounterColumn(ByteBufferUtil.bytes("x"), FBUtilities.toByteBuffer(0L), 1L); + right = new CounterColumn(ByteBufferUtil.bytes("x"), ByteBufferUtil.bytes(0L), 1L); assert left.reconcile(right) == left; // tombstone < live last delete left = new DeletedColumn(ByteBufferUtil.bytes("x"), 1, 1L); - right = new CounterColumn(ByteBufferUtil.bytes("x"), FBUtilities.toByteBuffer(0L), 4L, new byte[0], 2L); + right = new CounterColumn(ByteBufferUtil.bytes("x"), ByteBufferUtil.bytes(0L), 4L, new byte[0], 2L); assert left.reconcile(right) == right; // tombstone == live last delete left = new DeletedColumn(ByteBufferUtil.bytes("x"), 1, 2L); - right = new CounterColumn(ByteBufferUtil.bytes("x"), FBUtilities.toByteBuffer(0L), 4L, new byte[0], 2L); + right = new CounterColumn(ByteBufferUtil.bytes("x"), ByteBufferUtil.bytes(0L), 4L, new byte[0], 2L); assert left.reconcile(right) == right; // tombstone > live last delete left = new DeletedColumn(ByteBufferUtil.bytes("x"), 1, 4L); - right = new CounterColumn(ByteBufferUtil.bytes("x"), FBUtilities.toByteBuffer(0L), 9L, new byte[0], 1L); + right = new CounterColumn(ByteBufferUtil.bytes("x"), ByteBufferUtil.bytes(0L), 9L, new byte[0], 1L); reconciled = left.reconcile(right); assert reconciled.name() == right.name(); @@ -159,25 +159,25 @@ public class CounterColumnTest assert ((CounterColumn)reconciled).timestampOfLastDelete() == left.timestamp(); // live < tombstone - left = new CounterColumn(ByteBufferUtil.bytes("x"), FBUtilities.toByteBuffer(0L), 1L); + left = new CounterColumn(ByteBufferUtil.bytes("x"), ByteBufferUtil.bytes(0L), 1L); right = new DeletedColumn(ByteBufferUtil.bytes("x"), 1, 2L); assert left.reconcile(right) == right; // live last delete > tombstone - left = new CounterColumn(ByteBufferUtil.bytes("x"), FBUtilities.toByteBuffer(0L), 4L, new byte[0], 2L); + left = new CounterColumn(ByteBufferUtil.bytes("x"), ByteBufferUtil.bytes(0L), 4L, new byte[0], 2L); right = new DeletedColumn(ByteBufferUtil.bytes("x"), 1, 1L); assert left.reconcile(right) == left; // live last delete == tombstone - left = new CounterColumn(ByteBufferUtil.bytes("x"), FBUtilities.toByteBuffer(0L), 4L, new byte[0], 2L); + left = new CounterColumn(ByteBufferUtil.bytes("x"), ByteBufferUtil.bytes(0L), 4L, new byte[0], 2L); right = new DeletedColumn(ByteBufferUtil.bytes("x"), 1, 2L); assert left.reconcile(right) == left; // live last delete < tombstone - left = new CounterColumn(ByteBufferUtil.bytes("x"), FBUtilities.toByteBuffer(0L), 9L, new byte[0], 1L); + left = new CounterColumn(ByteBufferUtil.bytes("x"), ByteBufferUtil.bytes(0L), 9L, new byte[0], 1L); right = new DeletedColumn(ByteBufferUtil.bytes("x"), 1, 4L); reconciled = left.reconcile(right); Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java (original) +++ cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java Wed Jan 19 17:14:06 2011 @@ -42,7 +42,6 @@ import org.apache.cassandra.db.marshal.L import org.apache.cassandra.io.sstable.IndexHelper; import org.apache.cassandra.io.sstable.SSTableReader; import org.apache.cassandra.io.util.BufferedRandomAccessFile; -import org.apache.cassandra.utils.FBUtilities; import org.apache.cassandra.utils.ByteBufferUtil; @@ -238,7 +237,7 @@ public class TableTest extends CleanupHe { RowMutation rm = new RowMutation("Keyspace1", ROW.key); ColumnFamily cf = ColumnFamily.create("Keyspace1", "StandardLong1"); - cf.addColumn(new Column(FBUtilities.toByteBuffer((long)i), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0)); + cf.addColumn(new Column(ByteBufferUtil.bytes((long)i), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0)); rm.add(cf); rm.apply(); } @@ -249,7 +248,7 @@ public class TableTest extends CleanupHe { RowMutation rm = new RowMutation("Keyspace1", ROW.key); ColumnFamily cf = ColumnFamily.create("Keyspace1", "StandardLong1"); - cf.addColumn(new Column(FBUtilities.toByteBuffer((long)i), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0)); + cf.addColumn(new Column(ByteBufferUtil.bytes((long)i), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0)); rm.add(cf); rm.apply(); @@ -405,7 +404,7 @@ public class TableTest extends CleanupHe long position = sstable.getPosition(key, SSTableReader.Operator.EQ); BufferedRandomAccessFile file = new BufferedRandomAccessFile(sstable.getFilename(), "r"); file.seek(position); - assert FBUtilities.readShortByteArray(file).equals(key.key); + assert ByteBufferUtil.readWithShortLength(file).equals(key.key); SSTableReader.readRowSize(file, sstable.descriptor); IndexHelper.skipBloomFilter(file); ArrayList<IndexHelper.IndexInfo> indexes = IndexHelper.deserializeIndex(file); Modified: cassandra/trunk/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java (original) +++ cassandra/trunk/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java Wed Jan 19 17:14:06 2011 @@ -26,7 +26,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.cassandra.thrift.SlicePredicate; -import org.apache.cassandra.utils.FBUtilities; +import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.hadoop.conf.Configuration; import org.junit.Test; @@ -36,7 +36,7 @@ public class ColumnFamilyInputFormatTest public void testSlicePredicate() { long columnValue = 1271253600000l; - ByteBuffer columnBytes = FBUtilities.toByteBuffer(columnValue); + ByteBuffer columnBytes = ByteBufferUtil.bytes(columnValue); List<ByteBuffer> columnNames = new ArrayList<ByteBuffer>(); columnNames.add(columnBytes); Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java (original) +++ cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java Wed Jan 19 17:14:06 2011 @@ -39,7 +39,6 @@ import org.apache.cassandra.io.util.File import org.apache.cassandra.io.util.MmappedSegmentedFile; import org.apache.cassandra.service.StorageService; import org.apache.cassandra.utils.ByteBufferUtil; -import org.apache.cassandra.utils.FBUtilities; import org.apache.cassandra.utils.Pair; import org.apache.cassandra.Util; @@ -120,7 +119,7 @@ public class SSTableReaderTest extends C FileDataInput file = sstable.getFileDataInput(dk, DatabaseDescriptor.getIndexedReadBufferSizeInKB() * 1024); DecoratedKey keyInDisk = SSTableReader.decodeKey(sstable.partitioner, sstable.descriptor, - FBUtilities.readShortByteArray(file)); + ByteBufferUtil.readWithShortLength(file)); assert keyInDisk.equals(dk) : String.format("%s != %s in %s", keyInDisk, dk, file.getPath()); } Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java (original) +++ cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java Wed Jan 19 17:14:06 2011 @@ -27,7 +27,7 @@ import org.junit.Test; import org.apache.cassandra.CleanupHelper; import org.apache.cassandra.io.util.BufferedRandomAccessFile; -import org.apache.cassandra.utils.FBUtilities; +import org.apache.cassandra.utils.ByteBufferUtil; public class SSTableTest extends CleanupHelper { @@ -52,7 +52,7 @@ public class SSTableTest extends Cleanup { BufferedRandomAccessFile file = new BufferedRandomAccessFile(sstable.getFilename(), "r"); file.seek(sstable.getPosition(sstable.partitioner.decorateKey(key), SSTableReader.Operator.EQ)); - assert key.equals(FBUtilities.readShortByteArray(file)); + assert key.equals(ByteBufferUtil.readWithShortLength(file)); int size = (int)SSTableReader.readRowSize(file, sstable.descriptor); byte[] bytes2 = new byte[size]; file.readFully(bytes2); @@ -84,7 +84,7 @@ public class SSTableTest extends Cleanup for (ByteBuffer key : keys) { file.seek(sstable.getPosition(sstable.partitioner.decorateKey(key), SSTableReader.Operator.EQ)); - assert key.equals( FBUtilities.readShortByteArray(file)); + assert key.equals( ByteBufferUtil.readWithShortLength(file)); int size = (int)SSTableReader.readRowSize(file, sstable.descriptor); byte[] bytes2 = new byte[size]; file.readFully(bytes2); Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java (original) +++ cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java Wed Jan 19 17:14:06 2011 @@ -45,7 +45,6 @@ import org.apache.cassandra.streaming.Op import org.apache.cassandra.thrift.IndexClause; import org.apache.cassandra.thrift.IndexExpression; import org.apache.cassandra.thrift.IndexOperator; -import org.apache.cassandra.utils.FBUtilities; import org.junit.Test; import org.apache.cassandra.utils.ByteBufferUtil; @@ -57,12 +56,12 @@ public class SSTableWriterTest extends C RowMutation rm; rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("k1")); - rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 0); + rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 0); rm.apply(); ColumnFamily cf = ColumnFamily.create("Keyspace1", "Indexed1"); - cf.addColumn(new Column(ByteBufferUtil.bytes("birthdate"), FBUtilities.toByteBuffer(1L), 0)); - cf.addColumn(new Column(ByteBufferUtil.bytes("anydate"), FBUtilities.toByteBuffer(1L), 0)); + cf.addColumn(new Column(ByteBufferUtil.bytes("birthdate"), ByteBufferUtil.bytes(1L), 0)); + cf.addColumn(new Column(ByteBufferUtil.bytes("anydate"), ByteBufferUtil.bytes(1L), 0)); Map<ByteBuffer, ByteBuffer> entries = new HashMap<ByteBuffer, ByteBuffer>(); @@ -71,7 +70,7 @@ public class SSTableWriterTest extends C entries.put(ByteBufferUtil.bytes("k2"), ByteBuffer.wrap(Arrays.copyOf(buffer.getData(), buffer.getLength()))); cf.clear(); - cf.addColumn(new Column(ByteBufferUtil.bytes("anydate"), FBUtilities.toByteBuffer(1L), 0)); + cf.addColumn(new Column(ByteBufferUtil.bytes("anydate"), ByteBufferUtil.bytes(1L), 0)); buffer = new DataOutputBuffer(); ColumnFamily.serializer().serializeWithIndexes(cf, buffer); entries.put(ByteBufferUtil.bytes("k3"), ByteBuffer.wrap(Arrays.copyOf(buffer.getData(), buffer.getLength()))); @@ -87,7 +86,7 @@ public class SSTableWriterTest extends C cfs.addSSTable(sstr); cfs.buildSecondaryIndexes(cfs.getSSTables(), cfs.getIndexedColumns()); - IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, FBUtilities.toByteBuffer(1L)); + IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, ByteBufferUtil.bytes(1L)); IndexClause clause = new IndexClause(Arrays.asList(expr), ByteBufferUtil.EMPTY_BYTE_BUFFER, 100); IFilter filter = new IdentityQueryFilter(); IPartitioner p = StorageService.getPartitioner(); Modified: cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java (original) +++ cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java Wed Jan 19 17:14:06 2011 @@ -70,7 +70,7 @@ public class StreamingTransferTest exten RowMutation rm = new RowMutation("Keyspace1", ByteBuffer.wrap(key.getBytes())); ColumnFamily cf = ColumnFamily.create(table.name, cfs.columnFamily); cf.addColumn(column(key, "v", 0)); - cf.addColumn(new Column(ByteBufferUtil.bytes("birthdate"), FBUtilities.toByteBuffer((long) i), 0)); + cf.addColumn(new Column(ByteBufferUtil.bytes("birthdate"), ByteBufferUtil.bytes((long) i), 0)); rm.add(cf); rm.apply(); } @@ -102,7 +102,7 @@ public class StreamingTransferTest exten assert null != cfs.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("key3"), new QueryPath(cfs.columnFamily))); // and that the secondary index works - IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, FBUtilities.toByteBuffer(3L)); + IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, ByteBufferUtil.bytes(3L)); IndexClause clause = new IndexClause(Arrays.asList(expr), ByteBufferUtil.EMPTY_BYTE_BUFFER, 100); IFilter filter = new IdentityQueryFilter(); Range range = new Range(p.getMinimumToken(), p.getMinimumToken()); Modified: cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java (original) +++ cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java Wed Jan 19 17:14:06 2011 @@ -35,10 +35,11 @@ import org.apache.cassandra.dht.IPartiti import org.apache.cassandra.io.sstable.Descriptor; import org.apache.cassandra.io.sstable.SSTableReader; import org.apache.cassandra.io.sstable.SSTableWriter; +import org.apache.cassandra.utils.ByteBufferUtil; import static org.apache.cassandra.io.sstable.SSTableUtils.tempSSTableFile; -import static org.apache.cassandra.utils.FBUtilities.bytesToHex; -import static org.apache.cassandra.utils.FBUtilities.hexToBytes; +import static org.apache.cassandra.utils.ByteBufferUtil.bytesToHex; +import static org.apache.cassandra.utils.ByteBufferUtil.hexToBytes; import static org.junit.Assert.assertTrue; import org.apache.cassandra.Util; @@ -48,13 +49,12 @@ import org.json.simple.JSONObject; import org.json.simple.JSONValue; import org.json.simple.parser.ParseException; import org.junit.Test; -import org.apache.cassandra.utils.ByteBufferUtil; public class SSTableExportTest extends SchemaLoader { public String asHex(String str) { - return bytesToHex(str.getBytes()); + return bytesToHex(ByteBuffer.wrap(str.getBytes())); } @Test @@ -124,7 +124,7 @@ public class SSTableExportTest extends S JSONArray rowA = (JSONArray)json.get(asHex("rowA")); JSONArray colA = (JSONArray)rowA.get(0); - assert Arrays.equals(hexToBytes((String)colA.get(1)), "valA".getBytes()); + assert hexToBytes((String)colA.get(1)).equals(ByteBufferUtil.bytes("valA")); JSONArray colExp = (JSONArray)rowA.get(1); assert ((Long)colExp.get(4)) == 42; @@ -173,7 +173,7 @@ public class SSTableExportTest extends S JSONArray subColumns = (JSONArray)superA.get("subColumns"); JSONArray colA = (JSONArray)subColumns.get(0); JSONObject rowExclude = (JSONObject)json.get(asHex("rowExclude")); - assert Arrays.equals(hexToBytes((String)colA.get(1)), "valA".getBytes()); + assert hexToBytes((String)colA.get(1)).equals(ByteBufferUtil.bytes("valA")); assert !(Boolean)colA.get(3); assert rowExclude == null; } @@ -209,7 +209,7 @@ public class SSTableExportTest extends S QueryFilter qf = QueryFilter.getNamesFilter(Util.dk("rowA"), new QueryPath("Standard1", null, null), ByteBufferUtil.bytes("name")); ColumnFamily cf = qf.getSSTableColumnIterator(reader).getColumnFamily(); assertTrue(cf != null); - assertTrue(cf.getColumn(ByteBufferUtil.bytes("name")).value().equals(ByteBuffer.wrap(hexToBytes("76616c")))); + assertTrue(cf.getColumn(ByteBufferUtil.bytes("name")).value().equals(hexToBytes("76616c"))); qf = QueryFilter.getNamesFilter(Util.dk("rowExclude"), new QueryPath("Standard1", null, null), ByteBufferUtil.bytes("name")); cf = qf.getSSTableColumnIterator(reader).getColumnFamily(); Modified: cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java (original) +++ cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java Wed Jan 19 17:14:06 2011 @@ -34,7 +34,8 @@ import org.apache.cassandra.db.columnite import org.apache.cassandra.dht.IPartitioner; import org.apache.cassandra.io.sstable.Descriptor; import org.apache.cassandra.io.sstable.SSTableReader; -import static org.apache.cassandra.utils.FBUtilities.hexToBytes; +import org.apache.cassandra.utils.ByteBufferUtil; +import static org.apache.cassandra.utils.ByteBufferUtil.hexToBytes; import static org.apache.cassandra.io.sstable.SSTableUtils.tempSSTableFile; import static org.junit.Assert.assertEquals; @@ -42,7 +43,6 @@ import org.apache.cassandra.Util; import org.json.simple.parser.ParseException; import org.junit.Test; -import org.apache.cassandra.utils.ByteBufferUtil; public class SSTableImportTest extends SchemaLoader { @@ -60,10 +60,10 @@ public class SSTableImportTest extends S IColumnIterator iter = qf.getSSTableColumnIterator(reader); ColumnFamily cf = iter.getColumnFamily(); while (iter.hasNext()) cf.addColumn(iter.next()); - assert cf.getColumn(ByteBufferUtil.bytes("colAA")).value().equals(ByteBuffer.wrap(hexToBytes("76616c4141"))); + assert cf.getColumn(ByteBufferUtil.bytes("colAA")).value().equals(hexToBytes("76616c4141")); assert !(cf.getColumn(ByteBufferUtil.bytes("colAA")) instanceof DeletedColumn); IColumn expCol = cf.getColumn(ByteBufferUtil.bytes("colAC")); - assert expCol.value().equals(ByteBuffer.wrap(hexToBytes("76616c4143"))); + assert expCol.value().equals(hexToBytes("76616c4143")); assert expCol instanceof ExpiringColumn; assert ((ExpiringColumn)expCol).getTimeToLive() == 42 && expCol.getLocalDeletionTime() == 2000000000; } @@ -83,7 +83,7 @@ public class SSTableImportTest extends S assert superCol != null; assert superCol.getSubColumns().size() > 0; IColumn subColumn = superCol.getSubColumn(ByteBufferUtil.bytes("colAA")); - assert subColumn.value().equals(ByteBuffer.wrap(hexToBytes("76616c75654141"))); + assert subColumn.value().equals(hexToBytes("76616c75654141")); } @Test Modified: cassandra/trunk/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java?rev=1060870&r1=1060869&r2=1060870&view=diff ============================================================================== --- cassandra/trunk/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java (original) +++ cassandra/trunk/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java Wed Jan 19 17:14:06 2011 @@ -80,8 +80,8 @@ public class FBUtilitiesTest }; for (int i : ints) { - ByteBuffer ba = FBUtilities.toByteBuffer(i); - int actual = FBUtilities.byteBufferToInt(ba); + ByteBuffer ba = ByteBufferUtil.bytes(i); + int actual = ByteBufferUtil.toInt(ba); assertEquals(i, actual); } }
