cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1084660 [1/2] - in /cassandra/branches/cassandra-0.7: ./ contrib/bmt_example/ contrib/client_only/src/ contrib/stress/src/org/apache/cassandra/contrib/stress/ contrib/stress/src/org/apache/cassandra/contrib/stress/operations/ contrib/stres...
Date Wed, 23 Mar 2011 18:13:44 GMT
Author: jbellis
Date: Wed Mar 23 18:13:42 2011
New Revision: 1084660

URL: http://svn.apache.org/viewvc?rev=1084660&view=rev
Log:
fix encoding bugs in HintedHandoffManager, SystemTable when default charset is not UTF8
patch by slebresne; reviewed by jbellis for CASSANDRA-2367

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/contrib/bmt_example/CassandraBulkLoader.java
    cassandra/branches/cassandra-0.7/contrib/client_only/src/ClientOnlyExample.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/Session.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/IndexedRangeSlicer.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Inserter.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/MultiGetter.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/RangeSlicer.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Reader.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/Operation.java
    cassandra/branches/cassandra-0.7/contrib/word_count/src/WordCount.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/DefsTable.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/HintedHandOffManager.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/RowMutationVerbHandler.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SystemTable.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/AsciiType.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/UTF8Type.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/Migration.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/CollatingOrderPreservingPartitioner.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/RandomPartitioner.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
    cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/MovementTest.java
    cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/MutationTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/Util.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/client/TestRingCache.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CleanupTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CompactionsPurgeTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CompactionsTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/DefsTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/NameSortTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RowIterationTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/SerializationsTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/TimeSortTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/SerializationsTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/ByteBufferUtilTest.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/KeyGenerator.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Wed Mar 23 18:13:42 2011
@@ -15,6 +15,8 @@
  * fix race when iterating CFs during add/drop (CASSANDRA-2350)
  * add ConsistencyLevel command to CLI (CASSANDRA-2354)
  * fix potential infinite loop in ByteBufferUtil.inputStream (CASSANDRA-2365)
+ * fix encoding bugs in HintedHandoffManager, SystemTable when default
+   charset is not UTF8 (CASSANDRA-2367)
 
 
 0.7.4

Modified: cassandra/branches/cassandra-0.7/contrib/bmt_example/CassandraBulkLoader.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/bmt_example/CassandraBulkLoader.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/bmt_example/CassandraBulkLoader.java (original)
+++ cassandra/branches/cassandra-0.7/contrib/bmt_example/CassandraBulkLoader.java Wed Mar 23 18:13:42 2011
@@ -75,6 +75,7 @@ import org.apache.cassandra.net.Message;
 import org.apache.cassandra.net.MessagingService;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.hadoop.filecache.DistributedCache;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
@@ -175,9 +176,9 @@ public class CassandraBulkLoader {
                 String ColumnValue = fields[3];
                 int timestamp = 0;
                 columnFamily.addColumn(new QueryPath(cfName,
-                                                     ByteBuffer.wrap(SuperColumnName.getBytes(Charsets.UTF_8)),
-                                                     ByteBuffer.wrap(ColumnName.getBytes(Charsets.UTF_8))), 
-                                       ByteBuffer.wrap(ColumnValue.getBytes()),
+                                                     ByteBufferUtil.bytes(SuperColumnName),
+                                                     ByteBufferUtil.bytes(ColumnName)),
+                                       ByteBufferUtil.bytes(ColumnValue),
                                        timestamp);
             }
 
@@ -186,7 +187,7 @@ public class CassandraBulkLoader {
             /* Get serialized message to send to cluster */
             message = createMessage(keyspace, key.getBytes(), cfName, columnFamilies);
             List<IAsyncResult> results = new ArrayList<IAsyncResult>();
-            for (InetAddress endpoint: StorageService.instance.getNaturalEndpoints(keyspace, ByteBuffer.wrap(key.getBytes())))
+            for (InetAddress endpoint: StorageService.instance.getNaturalEndpoints(keyspace, ByteBufferUtil.bytes(key)))
             {
                 /* Send message to end point */
                 results.add(MessagingService.instance().sendRR(message, endpoint));

Modified: cassandra/branches/cassandra-0.7/contrib/client_only/src/ClientOnlyExample.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/client_only/src/ClientOnlyExample.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/client_only/src/ClientOnlyExample.java (original)
+++ cassandra/branches/cassandra-0.7/contrib/client_only/src/ClientOnlyExample.java Wed Mar 23 18:13:42 2011
@@ -63,9 +63,9 @@ public class ClientOnlyExample
         // do some writing.
         for (int i = 0; i < 100; i++)
         {
-            RowMutation change = new RowMutation(KEYSPACE, ByteBuffer.wrap(("key" + i).getBytes()));
+            RowMutation change = new RowMutation(KEYSPACE, ByteBufferUtil.bytes(("key" + i)));
             ColumnPath cp = new ColumnPath(COLUMN_FAMILY).setColumn(("colb").getBytes());
-            change.add(new QueryPath(cp), ByteBuffer.wrap(("value" + i).getBytes()), 0);
+            change.add(new QueryPath(cp), ByteBufferUtil.bytes(("value" + i)), 0);
 
             // don't call change.apply().  The reason is that is makes a static call into Table, which will perform
             // local storage initialization, which creates local directories.
@@ -87,7 +87,7 @@ public class ClientOnlyExample
         for (int i = 0; i < 100; i++)
         {
             List<ReadCommand> commands = new ArrayList<ReadCommand>();
-            SliceByNamesReadCommand readCommand = new SliceByNamesReadCommand(KEYSPACE, ByteBuffer.wrap(("key" + i).getBytes()),
+            SliceByNamesReadCommand readCommand = new SliceByNamesReadCommand(KEYSPACE, ByteBufferUtil.bytes(("key" + i)),
                                                                               new QueryPath(COLUMN_FAMILY, null, null), cols);
             readCommand.setDigestQuery(false);
             commands.add(readCommand);

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/Session.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/Session.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/Session.java (original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/Session.java Wed Mar 23 18:13:42 2011
@@ -28,6 +28,8 @@ import org.apache.commons.cli.*;
 import org.apache.cassandra.db.ColumnFamilyType;
 import org.apache.cassandra.thrift.*;
 import org.apache.commons.lang.StringUtils;
+
+import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.thrift.protocol.TBinaryProtocol;
 import org.apache.thrift.transport.TFramedTransport;
 import org.apache.thrift.transport.TSocket;
@@ -372,7 +374,7 @@ public class Session
         standardCfDef.setComparator_type("AsciiType").setDefault_validation_class("BytesType");
         if (indexType != null)
         {
-            ColumnDef standardColumn = new ColumnDef(ByteBuffer.wrap("C1".getBytes()), "BytesType");
+            ColumnDef standardColumn = new ColumnDef(ByteBufferUtil.bytes("C1"), "BytesType");
             standardColumn.setIndex_type(indexType).setIndex_name("Idx1");
             standardCfDef.setColumn_metadata(Arrays.asList(standardColumn));
         }

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/IndexedRangeSlicer.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/IndexedRangeSlicer.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/IndexedRangeSlicer.java (original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/IndexedRangeSlicer.java Wed Mar 23 18:13:42 2011
@@ -36,15 +36,15 @@ public class IndexedRangeSlicer extends 
     public void run(Cassandra.Client client) throws IOException
     {
         String format = "%0" + session.getTotalKeysLength() + "d";
-        SlicePredicate predicate = new SlicePredicate().setSlice_range(new SliceRange(ByteBuffer.wrap(new byte[]{}),
-                                                                                      ByteBuffer.wrap(new byte[] {}),
+        SlicePredicate predicate = new SlicePredicate().setSlice_range(new SliceRange(ByteBufferUtil.EMPTY_BYTE_BUFFER,
+                                                                                      ByteBufferUtil.EMPTY_BYTE_BUFFER,
                                                                                       false, session.getColumnsPerKey()));
 
         List<ByteBuffer> values = super.generateValues();
         ColumnParent parent = new ColumnParent("Standard1");
         int expectedPerValue = session.getNumKeys() / values.size();
 
-        ByteBuffer columnName = ByteBuffer.wrap("C1".getBytes());
+        ByteBuffer columnName = ByteBufferUtil.bytes("C1");
 
         int received = 0;
 
@@ -56,7 +56,7 @@ public class IndexedRangeSlicer extends 
         while (received < expectedPerValue)
         {
             IndexClause clause = new IndexClause(Arrays.asList(expression),
-                                                 ByteBuffer.wrap(startOffset.getBytes()),
+                                                 ByteBufferUtil.bytes(startOffset),
                                                  session.getKeysPerCall());
 
             List<KeySlice> results = null;

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Inserter.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Inserter.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Inserter.java (original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Inserter.java Wed Mar 23 18:13:42 2011
@@ -59,7 +59,7 @@ public class Inserter extends Operation
             for (int i = 0; i < session.getSuperColumns(); i++)
             {
                 String superColumnName = "S" + Integer.toString(i);
-                superColumns.add(new SuperColumn(ByteBuffer.wrap(superColumnName.getBytes()), columns));
+                superColumns.add(new SuperColumn(ByteBufferUtil.bytes(superColumnName), columns));
             }
         }
 

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/MultiGetter.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/MultiGetter.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/MultiGetter.java (original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/MultiGetter.java Wed Mar 23 18:13:42 2011
@@ -20,6 +20,7 @@ package org.apache.cassandra.contrib.str
 import org.apache.cassandra.contrib.stress.util.Operation;
 import org.apache.cassandra.db.ColumnFamilyType;
 import org.apache.cassandra.thrift.*;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
@@ -27,6 +28,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
+
 public class MultiGetter extends Operation
 {
     public MultiGetter(int index)
@@ -36,8 +38,8 @@ public class MultiGetter extends Operati
 
     public void run(Cassandra.Client client) throws IOException
     {
-        SlicePredicate predicate = new SlicePredicate().setSlice_range(new SliceRange(ByteBuffer.wrap(new byte[]{}),
-                                                                                      ByteBuffer.wrap(new byte[] {}),
+        SlicePredicate predicate = new SlicePredicate().setSlice_range(new SliceRange(ByteBufferUtil.EMPTY_BYTE_BUFFER,
+                                                                                      ByteBufferUtil.EMPTY_BYTE_BUFFER,
                                                                                       false, session.getColumnsPerKey()));
 
         int offset = index * session.getKeysPerThread();
@@ -49,7 +51,7 @@ public class MultiGetter extends Operati
 
             for (int j = 0; j < session.getSuperColumns(); j++)
             {
-                ColumnParent parent = new ColumnParent("Super1").setSuper_column(("S" + j).getBytes());
+                ColumnParent parent = new ColumnParent("Super1").setSuper_column(ByteBufferUtil.bytes("S" + j));
 
                 long start = System.currentTimeMillis();
 

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/RangeSlicer.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/RangeSlicer.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/RangeSlicer.java (original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/RangeSlicer.java Wed Mar 23 18:13:42 2011
@@ -42,14 +42,14 @@ public class RangeSlicer extends Operati
         // initial values
         int count = session.getColumnsPerKey();
 
-        SlicePredicate predicate = new SlicePredicate().setSlice_range(new SliceRange(ByteBuffer.wrap(new byte[] {}),
-                                                                                      ByteBuffer.wrap(new byte[] {}),
+        SlicePredicate predicate = new SlicePredicate().setSlice_range(new SliceRange(ByteBufferUtil.EMPTY_BYTE_BUFFER,
+                                                                                      ByteBufferUtil.EMPTY_BYTE_BUFFER,
                                                                                       false,
                                                                                       count));
 
         if (session.getColumnFamilyType() == ColumnFamilyType.Super)
         {
-            byte[] start = String.format(format, index).getBytes();
+            ByteBuffer start = ByteBufferUtil.bytes(String.format(format, index));
 
             List<KeySlice> slices = new ArrayList<KeySlice>();
             KeyRange range = new KeyRange(count).setStart_key(start).setEnd_key(ByteBufferUtil.EMPTY_BYTE_BUFFER);
@@ -57,7 +57,7 @@ public class RangeSlicer extends Operati
             for (int i = 0; i < session.getSuperColumns(); i++)
             {
                 String superColumnName = "S" + Integer.toString(i);
-                ColumnParent parent = new ColumnParent("Super1").setSuper_column(ByteBuffer.wrap(superColumnName.getBytes()));
+                ColumnParent parent = new ColumnParent("Super1").setSuper_column(ByteBufferUtil.bytes(superColumnName));
 
                 long startTime = System.currentTimeMillis();
 
@@ -83,7 +83,7 @@ public class RangeSlicer extends Operati
                     error(String.format("Operation [%d] retried %d times - error on calling get_range_slices for range offset %s %s%n",
                                         index,
                                         session.getRetryTimes(),
-                                        new String(start),
+                                        ByteBufferUtil.string(start),
                                         (exceptionMessage == null) ? "" : "(" + exceptionMessage + ")"));
                 }
 
@@ -97,7 +97,7 @@ public class RangeSlicer extends Operati
         {
             ColumnParent parent = new ColumnParent("Standard1");
 
-            byte[] start = String.format(format, index).getBytes();
+            ByteBuffer start = ByteBufferUtil.bytes(String.format(format, index));
 
             List<KeySlice> slices = new ArrayList<KeySlice>();
             KeyRange range = new KeyRange(count).setStart_key(start).setEnd_key(ByteBufferUtil.EMPTY_BYTE_BUFFER);
@@ -129,7 +129,7 @@ public class RangeSlicer extends Operati
                 error(String.format("Operation [%d] retried %d times - error on calling get_indexed_slices for range offset %s %s%n",
                                     index,
                                     session.getRetryTimes(),
-                                    new String(start),
+                                    ByteBufferUtil.string(start),
                                     (exceptionMessage == null) ? "" : "(" + exceptionMessage + ")"));
             }
 

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Reader.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Reader.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Reader.java (original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/operations/Reader.java Wed Mar 23 18:13:42 2011
@@ -25,6 +25,8 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.List;
 
+import static com.google.common.base.Charsets.UTF_8;
+
 public class Reader extends Operation
 {
     public Reader(int index)
@@ -63,7 +65,7 @@ public class Reader extends Operation
         for (int j = 0; j < session.getSuperColumns(); j++)
         {
             String superColumn = 'S' + Integer.toString(j);
-            ColumnParent parent = new ColumnParent("Super1").setSuper_column(superColumn.getBytes());
+            ColumnParent parent = new ColumnParent("Super1").setSuper_column(superColumn.getBytes(UTF_8));
 
             long start = System.currentTimeMillis();
 

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/Operation.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/Operation.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/Operation.java (original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/Operation.java Wed Mar 23 18:13:42 2011
@@ -21,16 +21,16 @@ import java.io.IOException;
 import java.math.BigInteger;
 import java.nio.ByteBuffer;
 import java.security.MessageDigest;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
 
+import static com.google.common.base.Charsets.UTF_8;
+
 import org.apache.cassandra.contrib.stress.Session;
 import org.apache.cassandra.contrib.stress.Stress;
 import org.apache.cassandra.thrift.Cassandra;
 import org.apache.cassandra.thrift.InvalidRequestException;
-import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 
 public abstract class Operation
@@ -91,7 +91,7 @@ public abstract class Operation
     private static byte[] generateRandomKey()
     {
         String format = "%0" + Stress.session.getTotalKeysLength() + "d";
-        return String.format(format, Stress.randomizer.nextInt(Stress.session.getNumKeys() - 1)).getBytes();
+        return String.format(format, Stress.randomizer.nextInt(Stress.session.getNumKeys() - 1)).getBytes(UTF_8);
     }
 
     /**
@@ -109,7 +109,7 @@ public abstract class Operation
 
             if (0 <= token && token < session.getNumKeys())
             {
-                return String.format(format, (int) token).getBytes();
+                return String.format(format, (int) token).getBytes(UTF_8);
             }
         }
     }
@@ -148,7 +148,7 @@ public abstract class Operation
     private String getMD5(String input)
     {
         MessageDigest md = FBUtilities.threadLocalMD5Digest();
-        byte[] messageDigest = md.digest(input.getBytes());
+        byte[] messageDigest = md.digest(input.getBytes(UTF_8));
         StringBuilder hash = new StringBuilder(new BigInteger(1, messageDigest).toString(16));
 
         while (hash.length() < 32)

Modified: cassandra/branches/cassandra-0.7/contrib/word_count/src/WordCount.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/word_count/src/WordCount.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/word_count/src/WordCount.java (original)
+++ cassandra/branches/cassandra-0.7/contrib/word_count/src/WordCount.java Wed Mar 23 18:13:42 2011
@@ -27,6 +27,8 @@ import org.apache.cassandra.hadoop.Colum
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Charsets.UTF_8;
+
 import org.apache.cassandra.db.IColumn;
 import org.apache.cassandra.hadoop.ColumnFamilyInputFormat;
 import org.apache.cassandra.hadoop.ConfigHelper;
@@ -82,7 +84,7 @@ public class WordCount extends Configure
         protected void setup(org.apache.hadoop.mapreduce.Mapper.Context context)
         throws IOException, InterruptedException
         {
-            sourceColumn = ByteBuffer.wrap(context.getConfiguration().get(CONF_COLUMN_NAME).getBytes());
+            sourceColumn = ByteBufferUtil.bytes(context.getConfiguration().get(CONF_COLUMN_NAME));
         }
 
         public void map(ByteBuffer key, SortedMap<ByteBuffer, IColumn> columns, Context context) throws IOException, InterruptedException
@@ -120,7 +122,7 @@ public class WordCount extends Configure
         protected void setup(org.apache.hadoop.mapreduce.Reducer.Context context)
         throws IOException, InterruptedException
         {
-            outputKey = ByteBuffer.wrap(context.getConfiguration().get(CONF_COLUMN_NAME).getBytes());
+            outputKey = ByteBufferUtil.bytes(context.getConfiguration().get(CONF_COLUMN_NAME));
         }
 
         public void reduce(Text word, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException
@@ -135,7 +137,7 @@ public class WordCount extends Configure
         {
             Column c = new Column();
             c.name = ByteBuffer.wrap(Arrays.copyOf(word.getBytes(), word.getLength()));
-            c.value = ByteBuffer.wrap(String.valueOf(sum).getBytes());
+            c.value = ByteBufferUtil.bytes(String.valueOf(sum));
             c.timestamp = System.currentTimeMillis() * 1000;
 
             Mutation m = new Mutation();
@@ -194,7 +196,7 @@ public class WordCount extends Configure
             ConfigHelper.setInitialAddress(job.getConfiguration(), "localhost");
             ConfigHelper.setPartitioner(job.getConfiguration(), "org.apache.cassandra.dht.RandomPartitioner");
             ConfigHelper.setInputColumnFamily(job.getConfiguration(), KEYSPACE, COLUMN_FAMILY);
-            SlicePredicate predicate = new SlicePredicate().setColumn_names(Arrays.asList(ByteBuffer.wrap(columnName.getBytes())));
+            SlicePredicate predicate = new SlicePredicate().setColumn_names(Arrays.asList(ByteBufferUtil.bytes(columnName)));
             ConfigHelper.setInputSlicePredicate(job.getConfiguration(), predicate);
 
             job.waitForCompletion(true);

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java Wed Mar 23 18:13:42 2011
@@ -252,7 +252,7 @@ public class CliClient extends CliUserHe
         SliceRange range = new SliceRange(ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, Integer.MAX_VALUE);
         SlicePredicate predicate = new SlicePredicate().setColumn_names(null).setSlice_range(range);
 
-        int count = thriftClient.get_count(ByteBuffer.wrap(key.getBytes(Charsets.UTF_8)), colParent, predicate, consistencyLevel);
+        int count = thriftClient.get_count(ByteBufferUtil.bytes(key), colParent, predicate, consistencyLevel);
         sessionState.out.printf("%d columns%n", count);
     }
     
@@ -301,7 +301,7 @@ public class CliClient extends CliUserHe
         if (columnName != null)
             path.setColumn(columnName);
 
-        thriftClient.remove(ByteBuffer.wrap(key.getBytes(Charsets.UTF_8)), path,
+        thriftClient.remove(ByteBufferUtil.bytes(key), path,
                              FBUtilities.timestampMicros(), consistencyLevel);
         sessionState.out.println(String.format("%s removed.", (columnSpecCnt == 0) ? "row" : "column"));
     }
@@ -1770,7 +1770,7 @@ public class CliClient extends CliUserHe
         }
 
         // if no validation were set returning simple .getBytes()
-        return ByteBuffer.wrap(columnValue.getBytes());
+        return ByteBufferUtil.bytes(columnValue);
     }
 
     /**
@@ -1993,7 +1993,7 @@ public class CliClient extends CliUserHe
 
         for (KeySlice ks : slices)
         {
-            String keyName = (keyComparator == null) ? ByteBufferUtil.string(ks.key, Charsets.UTF_8) : keyComparator.getString(ks.key);
+            String keyName = (keyComparator == null) ? ByteBufferUtil.string(ks.key) : keyComparator.getString(ks.key);
 
             sessionState.out.printf("-------------------%n");
             sessionState.out.printf("RowKey: %s%n", keyName);

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java Wed Mar 23 18:13:42 2011
@@ -45,6 +45,7 @@ import org.apache.cassandra.io.util.File
 import org.apache.cassandra.locator.*;
 import org.apache.cassandra.scheduler.IRequestScheduler;
 import org.apache.cassandra.scheduler.NoScheduler;
+import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.Pair;
 import org.yaml.snakeyaml.Loader;
@@ -613,7 +614,7 @@ public class    DatabaseDescriptor
                         throw new ConfigurationException("index_name cannot be set if index_type is not also set");
                     }
 
-                    ByteBuffer columnName = ByteBuffer.wrap(rcd.name.getBytes(Charsets.UTF_8));
+                    ByteBuffer columnName = ByteBufferUtil.bytes(rcd.name);
                     metadata.put(columnName, new ColumnDefinition(columnName, rcd.validator_class, rcd.index_type, rcd.index_name));
                 }
 

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/DefsTable.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/DefsTable.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/DefsTable.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/DefsTable.java Wed Mar 23 18:13:42 2011
@@ -35,8 +35,6 @@ import org.apache.cassandra.service.Stor
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.UUIDGen;
 
-import static com.google.common.base.Charsets.UTF_8;
-
 public class DefsTable
 {
     // column name for the schema storing serialized keyspace definitions
@@ -57,13 +55,13 @@ public class DefsTable
         for (String ksname : ksnames)
         {
             KSMetaData ksm = DatabaseDescriptor.getTableDefinition(ksname);
-            rm.add(new QueryPath(Migration.SCHEMA_CF, null, ByteBuffer.wrap(ksm.name.getBytes(UTF_8))), SerDeUtils.serialize(ksm.deflate()), now);
+            rm.add(new QueryPath(Migration.SCHEMA_CF, null, ByteBufferUtil.bytes(ksm.name)), SerDeUtils.serialize(ksm.deflate()), now);
         }
         // add the schema
         rm.add(new QueryPath(Migration.SCHEMA_CF,
                              null,
                              DEFINITION_SCHEMA_COLUMN_NAME),
-                             ByteBuffer.wrap(org.apache.cassandra.avro.KsDef.SCHEMA$.toString().getBytes(UTF_8)),
+                             ByteBufferUtil.bytes(org.apache.cassandra.avro.KsDef.SCHEMA$.toString()),
                              now);
         rm.apply();
 

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/HintedHandOffManager.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/HintedHandOffManager.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/HintedHandOffManager.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/HintedHandOffManager.java Wed Mar 23 18:13:42 2011
@@ -197,7 +197,7 @@ public class HintedHandOffManager implem
     {
         final String ipaddr = endpoint.getHostAddress();
         final ColumnFamilyStore hintStore = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(HINTS_CF);
-        final RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, ByteBuffer.wrap(ipaddr.getBytes()));
+        final RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, ByteBufferUtil.bytes(ipaddr));
         rm.delete(new QueryPath(HINTS_CF), System.currentTimeMillis());
 
         // execute asynchronously to avoid blocking caller (which may be processing gossip)
@@ -230,13 +230,13 @@ public class HintedHandOffManager implem
 
     public static ByteBuffer makeCombinedName(String tableName, String columnFamily)
     {
-        byte[] withsep = ArrayUtils.addAll(tableName.getBytes(UTF_8), SEPARATOR.getBytes());
+        byte[] withsep = ArrayUtils.addAll(tableName.getBytes(UTF_8), SEPARATOR.getBytes(UTF_8));
         return ByteBuffer.wrap(ArrayUtils.addAll(withsep, columnFamily.getBytes(UTF_8)));
     }
 
     private static String[] getTableAndCFNames(ByteBuffer joined)
     {
-        int index = ByteBufferUtil.lastIndexOf(joined, SEPARATOR.getBytes()[0], joined.limit());
+        int index = ByteBufferUtil.lastIndexOf(joined, SEPARATOR.getBytes(UTF_8)[0], joined.limit());
 
         if (index == -1 || index < (joined.position() + 1))
             throw new RuntimeException("Corrupted hint name " + ByteBufferUtil.bytesToHex(joined));
@@ -308,7 +308,7 @@ public class HintedHandOffManager implem
         // 3. Delete the subcolumn if the write was successful
         // 4. Force a flush
         // 5. Do major compaction to clean up all deletes etc.
-        ByteBuffer endpointAsUTF8 = ByteBuffer.wrap(endpoint.getHostAddress().getBytes(UTF_8)); // keys have to be UTF8 to make OPP happy
+        ByteBuffer endpointAsUTF8 = ByteBufferUtil.bytes(endpoint.getHostAddress()); // keys have to be UTF8 to make OPP happy
         DecoratedKey epkey =  StorageService.getPartitioner().decorateKey(endpointAsUTF8);
         int rowsReplayed = 0;
         ColumnFamilyStore hintStore = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(HINTS_CF);
@@ -364,7 +364,7 @@ public class HintedHandOffManager implem
     /** called when a keyspace is dropped or rename. newTable==null in the case of a drop. */
     public static void renameHints(String oldTable, String newTable) throws IOException
     {
-        DecoratedKey oldTableKey = StorageService.getPartitioner().decorateKey(ByteBuffer.wrap(oldTable.getBytes(UTF_8)));
+        DecoratedKey oldTableKey = StorageService.getPartitioner().decorateKey(ByteBufferUtil.bytes(oldTable));
         // we're basically going to fetch, drop and add the scf for the old and new table. we need to do it piecemeal 
         // though since there could be GB of data.
         ColumnFamilyStore hintStore = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(HINTS_CF);
@@ -378,7 +378,7 @@ public class HintedHandOffManager implem
                 break;
             if (newTable != null)
             {
-                RowMutation insert = new RowMutation(Table.SYSTEM_TABLE, ByteBuffer.wrap(newTable.getBytes(UTF_8)));
+                RowMutation insert = new RowMutation(Table.SYSTEM_TABLE, ByteBufferUtil.bytes(newTable));
                 insert.add(cf);
                 insert.apply();
             }

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/RowMutationVerbHandler.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/RowMutationVerbHandler.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/RowMutationVerbHandler.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/RowMutationVerbHandler.java Wed Mar 23 18:13:42 2011
@@ -25,7 +25,6 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 
-import com.google.common.base.Charsets;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -61,7 +60,7 @@ public class RowMutationVerbHandler impl
                 {
                     ByteBuffer addressBytes = ByteBufferUtil.readWithShortLength(dis);
                     if (logger_.isDebugEnabled())
-                        logger_.debug("Adding hint for " + InetAddress.getByName(ByteBufferUtil.string(addressBytes, Charsets.UTF_8)));
+                        logger_.debug("Adding hint for " + InetAddress.getByName(ByteBufferUtil.string(addressBytes)));
                     RowMutation hintedMutation = new RowMutation(Table.SYSTEM_TABLE, addressBytes);
                     hintedMutation.addHints(rm);
                     hintedMutation.apply();

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SystemTable.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SystemTable.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SystemTable.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SystemTable.java Wed Mar 23 18:13:42 2011
@@ -44,8 +44,6 @@ import org.apache.cassandra.service.Stor
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 
-import static com.google.common.base.Charsets.UTF_8;
-
 public class SystemTable
 {
     private static Logger logger = LoggerFactory.getLogger(SystemTable.class);
@@ -239,8 +237,8 @@ public class SystemTable
             // no system files.  this is a new node.
             RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, LOCATION_KEY);
             cf = ColumnFamily.create(Table.SYSTEM_TABLE, SystemTable.STATUS_CF);
-            cf.addColumn(new Column(PARTITIONER, ByteBuffer.wrap(DatabaseDescriptor.getPartitioner().getClass().getName().getBytes(UTF_8)), FBUtilities.timestampMicros()));
-            cf.addColumn(new Column(CLUSTERNAME, ByteBuffer.wrap(DatabaseDescriptor.getClusterName().getBytes()), FBUtilities.timestampMicros()));
+            cf.addColumn(new Column(PARTITIONER, ByteBufferUtil.bytes(DatabaseDescriptor.getPartitioner().getClass().getName()), FBUtilities.timestampMicros()));
+            cf.addColumn(new Column(CLUSTERNAME, ByteBufferUtil.bytes(DatabaseDescriptor.getClusterName()), FBUtilities.timestampMicros()));
             rm.add(cf);
             rm.apply();
 
@@ -252,9 +250,9 @@ public class SystemTable
         IColumn clusterCol = cf.getColumn(CLUSTERNAME);
         assert partitionerCol != null;
         assert clusterCol != null;
-        if (!DatabaseDescriptor.getPartitioner().getClass().getName().equals(ByteBufferUtil.string(partitionerCol.value(), UTF_8)))
+        if (!DatabaseDescriptor.getPartitioner().getClass().getName().equals(ByteBufferUtil.string(partitionerCol.value())))
             throw new ConfigurationException("Detected partitioner mismatch! Did you change the partitioner?");
-        String savedClusterName = ByteBufferUtil.string(clusterCol.value(), UTF_8);
+        String savedClusterName = ByteBufferUtil.string(clusterCol.value());
         if (!DatabaseDescriptor.getClusterName().equals(savedClusterName))
             throw new ConfigurationException("Saved cluster name " + savedClusterName + " != configured name " + DatabaseDescriptor.getClusterName());
     }
@@ -331,17 +329,17 @@ public class SystemTable
     public static boolean isIndexBuilt(String table, String indexName)
     {
         ColumnFamilyStore cfs = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(INDEX_CF);
-        QueryFilter filter = QueryFilter.getNamesFilter(decorate(ByteBuffer.wrap(table.getBytes(UTF_8))),
+        QueryFilter filter = QueryFilter.getNamesFilter(decorate(ByteBufferUtil.bytes(table)),
                                                         new QueryPath(INDEX_CF),
-                                                        ByteBuffer.wrap(indexName.getBytes(UTF_8)));
+                                                        ByteBufferUtil.bytes(indexName));
         return cfs.getColumnFamily(filter) != null;
     }
 
     public static void setIndexBuilt(String table, String indexName)
     {
         ColumnFamily cf = ColumnFamily.create(Table.SYSTEM_TABLE, INDEX_CF);
-        cf.addColumn(new Column(ByteBuffer.wrap(indexName.getBytes(UTF_8)), ByteBufferUtil.EMPTY_BYTE_BUFFER, System.currentTimeMillis()));
-        RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, ByteBuffer.wrap(table.getBytes(UTF_8)));
+        cf.addColumn(new Column(ByteBufferUtil.bytes(indexName), ByteBufferUtil.EMPTY_BYTE_BUFFER, System.currentTimeMillis()));
+        RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, ByteBufferUtil.bytes(table));
         rm.add(cf);
         try
         {
@@ -357,8 +355,8 @@ public class SystemTable
 
     public static void setIndexRemoved(String table, String indexName)
     {
-        RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, ByteBuffer.wrap(table.getBytes(UTF_8)));
-        rm.delete(new QueryPath(INDEX_CF, null, ByteBuffer.wrap(indexName.getBytes(UTF_8))), System.currentTimeMillis());
+        RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, ByteBufferUtil.bytes(table));
+        rm.delete(new QueryPath(INDEX_CF, null, ByteBufferUtil.bytes(indexName)), System.currentTimeMillis());
         try
         {
             rm.apply();

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/AsciiType.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/AsciiType.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/AsciiType.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/AsciiType.java Wed Mar 23 18:13:42 2011
@@ -49,7 +49,7 @@ public class AsciiType extends BytesType
 
     public ByteBuffer fromString(String source)
     {
-        return ByteBuffer.wrap(source.getBytes(Charsets.US_ASCII));
+        return ByteBufferUtil.bytes(source, Charsets.US_ASCII);
     }
 
     public void validate(ByteBuffer bytes) throws MarshalException

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/UTF8Type.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/UTF8Type.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/UTF8Type.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/UTF8Type.java Wed Mar 23 18:13:42 2011
@@ -23,8 +23,6 @@ package org.apache.cassandra.db.marshal;
 import java.nio.ByteBuffer;
 import java.nio.charset.CharacterCodingException;
 
-import com.google.common.base.Charsets;
-
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 public class UTF8Type extends BytesType
@@ -37,7 +35,7 @@ public class UTF8Type extends BytesType
     {
         try
         {
-            return ByteBufferUtil.string(bytes, Charsets.UTF_8);
+            return ByteBufferUtil.string(bytes);
         }
         catch (CharacterCodingException e)
         {
@@ -47,7 +45,7 @@ public class UTF8Type extends BytesType
 
     public ByteBuffer fromString(String source)
     {
-        return ByteBuffer.wrap(source.getBytes(Charsets.UTF_8));
+        return ByteBufferUtil.bytes(source);
     }
     
     public void validate(ByteBuffer bytes) throws MarshalException

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/Migration.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/Migration.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/Migration.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/Migration.java Wed Mar 23 18:13:42 2011
@@ -45,8 +45,6 @@ import org.apache.cassandra.service.Stor
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.UUIDGen;
 
-import static com.google.common.base.Charsets.UTF_8;
-
 /**
  * A migration represents a single metadata mutation (cf dropped, added, etc.).  Migrations can be applied locally, or
  * serialized and sent to another machine where it can be applied there. Each migration has a version represented by
@@ -237,12 +235,12 @@ public abstract class Migration
         long now = System.currentTimeMillis();
         // add a column for each keyspace
         for (KSMetaData ksm : ksms)
-            rm.add(new QueryPath(SCHEMA_CF, null, ByteBuffer.wrap(ksm.name.getBytes(UTF_8))), SerDeUtils.serialize(ksm.deflate()), now);
+            rm.add(new QueryPath(SCHEMA_CF, null, ByteBufferUtil.bytes(ksm.name)), SerDeUtils.serialize(ksm.deflate()), now);
         // add the schema
         rm.add(new QueryPath(SCHEMA_CF,
                              null,
                              DefsTable.DEFINITION_SCHEMA_COLUMN_NAME),
-                             ByteBuffer.wrap(org.apache.cassandra.avro.KsDef.SCHEMA$.toString().getBytes(UTF_8)),
+                             ByteBufferUtil.bytes(org.apache.cassandra.avro.KsDef.SCHEMA$.toString()),
                              now);
         return rm;
     }
@@ -323,7 +321,7 @@ public abstract class Migration
     
     public static ByteBuffer toUTF8Bytes(UUID version)
     {
-        return ByteBuffer.wrap(version.toString().getBytes(UTF_8));
+        return ByteBufferUtil.bytes(version.toString());
     }
     
     public static boolean isLegalName(String s)

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/CollatingOrderPreservingPartitioner.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/CollatingOrderPreservingPartitioner.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/CollatingOrderPreservingPartitioner.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/CollatingOrderPreservingPartitioner.java Wed Mar 23 18:13:42 2011
@@ -25,8 +25,6 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
-import com.google.common.base.Charsets;
-
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 public class CollatingOrderPreservingPartitioner extends AbstractByteOrderedPartitioner
@@ -41,7 +39,7 @@ public class CollatingOrderPreservingPar
         String skey;
         try
         {
-            skey = ByteBufferUtil.string(key, Charsets.UTF_8);
+            skey = ByteBufferUtil.string(key);
         }
         catch (CharacterCodingException e)
         {

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java Wed Mar 23 18:13:42 2011
@@ -23,8 +23,6 @@ import java.nio.ByteBuffer;
 import java.nio.charset.CharacterCodingException;
 import java.util.*;
 
-import com.google.common.base.Charsets;
-
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.DecoratedKey;
@@ -118,14 +116,14 @@ public class OrderPreservingPartitioner 
     {
         public ByteBuffer toByteArray(Token<String> stringToken)
         {
-            return ByteBuffer.wrap(stringToken.token.getBytes(Charsets.UTF_8));
+            return ByteBufferUtil.bytes(stringToken.token);
         }
 
         public Token<String> fromByteArray(ByteBuffer bytes)
         {
             try
             {
-                return new StringToken(ByteBufferUtil.string(bytes, Charsets.UTF_8));
+                return new StringToken(ByteBufferUtil.string(bytes));
             }
             catch (CharacterCodingException e)
             {
@@ -159,7 +157,7 @@ public class OrderPreservingPartitioner 
         String skey;
         try
         {
-            skey = ByteBufferUtil.string(key, Charsets.UTF_8);
+            skey = ByteBufferUtil.string(key);
         }
         catch (CharacterCodingException e)
         {

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/RandomPartitioner.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/RandomPartitioner.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/RandomPartitioner.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/RandomPartitioner.java Wed Mar 23 18:13:42 2011
@@ -30,8 +30,6 @@ import org.apache.cassandra.utils.FBUtil
 import org.apache.cassandra.utils.GuidGenerator;
 import org.apache.cassandra.utils.Pair;
 
-import static com.google.common.base.Charsets.UTF_8;
-
 /**
  * This class generates a BigIntegerToken using MD5 hash.
  */
@@ -65,7 +63,7 @@ public class RandomPartitioner implement
         String token = null;
         try
         {
-            token = ByteBufferUtil.string(fromdisk, fromdisk.position(), splitPoint - fromdisk.position(), UTF_8);
+            token = ByteBufferUtil.string(fromdisk, fromdisk.position(), splitPoint - fromdisk.position());
         }
         catch (CharacterCodingException e)
         {

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java Wed Mar 23 18:13:42 2011
@@ -52,8 +52,6 @@ import org.apache.cassandra.net.Messagin
 import org.apache.cassandra.thrift.*;
 import org.apache.cassandra.utils.*;
 
-import static com.google.common.base.Charsets.UTF_8;
-
 public class StorageProxy implements StorageProxyMBean
 {
     private static final Logger logger = LoggerFactory.getLogger(StorageProxy.class);
@@ -258,7 +256,7 @@ public class StorageProxy implements Sto
         {
             dos.write(previousHints);
         }
-        ByteBufferUtil.writeWithShortLength(ByteBuffer.wrap(target.getHostAddress().getBytes(UTF_8)), dos);
+        ByteBufferUtil.writeWithShortLength(ByteBufferUtil.bytes(target.getHostAddress()), dos);
         message.setHeader(RowMutation.HINT, bos.toByteArray());
     }
 

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java Wed Mar 23 18:13:42 2011
@@ -2078,7 +2078,7 @@ public class StorageService implements I
                     RawColumnDefinition rcd = new RawColumnDefinition();
                     rcd.index_name = cd.getIndexName();
                     rcd.index_type = cd.getIndexType();
-                    rcd.name = ByteBufferUtil.string(cd.name, Charsets.UTF_8);
+                    rcd.name = ByteBufferUtil.string(cd.name);
                     rcd.validator_class = cd.validator.getClass().getName();
                     rcf.column_metadata[j++] = rcd;
                 }

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java Wed Mar 23 18:13:42 2011
@@ -23,12 +23,13 @@ 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.CharacterCodingException;
 import java.nio.charset.Charset;
 import java.util.Arrays;
 
+import static com.google.common.base.Charsets.UTF_8;
+
 import org.apache.cassandra.io.util.FileDataInput;
 import org.apache.commons.lang.ArrayUtils;
 
@@ -101,16 +102,41 @@ public class ByteBufferUtil
         return compareUnsigned(o1, ByteBuffer.wrap(o2));
     }
 
+    /**
+     * Decode a String representation.
+     * This method assumes that the encoding charset is UTF_8.
+     *
+     * @param buffer a byte buffer holding the string representation
+     * @return the decoded string
+     */
     public static String string(ByteBuffer buffer) throws CharacterCodingException
     {
-        return string(buffer, Charset.defaultCharset());
+        return string(buffer, UTF_8);
     }
 
+    /**
+     * Decode a String representation.
+     * This method assumes that the encoding charset is UTF_8.
+     *
+     * @param buffer a byte buffer holding the string representation
+     * @param position the starting position in {@code buffer} to start decoding from
+     * @param length the number of bytes from {@code buffer} to use
+     * @return the decoded string
+     */
     public static String string(ByteBuffer buffer, int position, int length) throws CharacterCodingException
     {
-        return string(buffer, position, length, Charset.defaultCharset());
+        return string(buffer, position, length, UTF_8);
     }
 
+    /**
+     * Decode a String representation.
+     *
+     * @param buffer a byte buffer holding the string representation
+     * @param position the starting position in {@code buffer} to start decoding from
+     * @param length the number of bytes from {@code buffer} to use
+     * @param charset the String encoding charset
+     * @return the decoded string
+     */
     public static String string(ByteBuffer buffer, int position, int length, Charset charset) throws CharacterCodingException
     {
         ByteBuffer copy = buffer.duplicate();
@@ -119,6 +145,13 @@ public class ByteBufferUtil
         return string(copy, charset);
     }
 
+    /**
+     * Decode a String representation.
+     *
+     * @param buffer a byte buffer holding the string representation
+     * @param charset the String encoding charset
+     * @return the decoded string
+     */
     public static String string(ByteBuffer buffer, Charset charset) throws CharacterCodingException
     {
         return charset.newDecoder().decode(buffer.duplicate()).toString();
@@ -177,16 +210,27 @@ public class ByteBufferUtil
         return -1;
     }
 
-    public static ByteBuffer bytes(String s) 
-    { 
-        try
-        {
-            return ByteBuffer.wrap(s.getBytes("UTF-8"));
-        }
-        catch (UnsupportedEncodingException e)
-        {
-           throw new RuntimeException(e);
-        } 
+    /**
+     * Encode a String in a ByteBuffer using UTF_8.
+     *
+     * @param s the string to encode
+     * @return the encoded string
+     */
+    public static ByteBuffer bytes(String s)
+    {
+        return ByteBuffer.wrap(s.getBytes(UTF_8));
+    }
+
+    /**
+     * Encode a String in a ByteBuffer using the provided charset.
+     *
+     * @param s the string to encode
+     * @param charset the String encoding charset to use
+     * @return the encoded string
+     */
+    public static ByteBuffer bytes(String s, Charset charset)
+    {
+        return ByteBuffer.wrap(s.getBytes(charset));
     }
 
     /**

Modified: cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/MovementTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/MovementTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/MovementTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/MovementTest.java Wed Mar 23 18:13:42 2011
@@ -50,13 +50,13 @@ public class MovementTest extends TestBa
     {
         final int N = 1000;
         Column col1 = new Column(
-            ByteBuffer.wrap("c1".getBytes()),
-            ByteBuffer.wrap("v1".getBytes()),
+            ByteBufferUtil.bytes("c1"),
+            ByteBufferUtil.bytes("v1"),
             0
             );
         Column col2 = new Column(
-            ByteBuffer.wrap("c2".getBytes()),
-            ByteBuffer.wrap("v2".getBytes()),
+            ByteBufferUtil.bytes("c2"),
+            ByteBufferUtil.bytes("v2"),
             0
             );
 
@@ -66,7 +66,7 @@ public class MovementTest extends TestBa
         for (int i = 0; i < N; i++)
         {
             String rawKey = String.format("test.key.%d", i);
-            ByteBuffer key = ByteBuffer.wrap(rawKey.getBytes());
+            ByteBuffer key = ByteBufferUtil.bytes(rawKey);
             Mutation m1 = (new Mutation()).setColumn_or_supercolumn((new ColumnOrSuperColumn()).setColumn(col1));
             Mutation m2 = (new Mutation()).setColumn_or_supercolumn((new ColumnOrSuperColumn()).setColumn(col2));
             rows.put(key, Arrays.asList(m1.getColumn_or_supercolumn(),

Modified: cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/MutationTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/MutationTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/MutationTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/MutationTest.java Wed Mar 23 18:13:42 2011
@@ -189,8 +189,8 @@ public class MutationTest extends TestBa
         throws InvalidRequestException, UnavailableException, TimedOutException, TException
     {
         Column col = new Column(
-             ByteBuffer.wrap(name.getBytes()),
-             ByteBuffer.wrap(value.getBytes()),
+             ByteBufferUtil.bytes(name),
+             ByteBufferUtil.bytes(value),
              timestamp
              );
         client.insert(key, new ColumnParent(cf), col, cl);
@@ -337,8 +337,8 @@ public class MutationTest extends TestBa
 
     protected void assertColumnEqual(String name, String value, long timestamp, Column col)
     {
-        assertEquals(ByteBuffer.wrap(name.getBytes()), col.name);
-        assertEquals(ByteBuffer.wrap(value.getBytes()), col.value);
+        assertEquals(ByteBufferUtil.bytes(name), col.name);
+        assertEquals(ByteBufferUtil.bytes(value), col.value);
         assertEquals(timestamp, col.timestamp);
     }
 
@@ -371,6 +371,6 @@ public class MutationTest extends TestBa
 
     protected ByteBuffer newKey()
     {
-        return ByteBuffer.wrap(String.format("test.key.%d", System.currentTimeMillis()).getBytes());
+        return ByteBufferUtil.bytes(String.format("test.key.%d", System.currentTimeMillis()));
     }
 }

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/Util.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/Util.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/Util.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/Util.java Wed Mar 23 18:13:42 2011
@@ -25,13 +25,8 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
 import java.util.concurrent.ExecutionException;
 
-import static org.junit.Assert.*;
-
-import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
 import org.apache.cassandra.db.filter.QueryFilter;
@@ -39,26 +34,26 @@ import org.apache.cassandra.db.filter.Qu
 import org.apache.cassandra.dht.*;
 import org.apache.cassandra.gms.ApplicationState;
 import org.apache.cassandra.gms.VersionedValue;
-import org.apache.cassandra.locator.AbstractReplicationStrategy;
 import org.apache.cassandra.service.StorageService;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
-import static com.google.common.base.Charsets.UTF_8;
+import static org.junit.Assert.assertTrue;
 
 public class Util
 {
     public static DecoratedKey dk(String key)
     {
-        return StorageService.getPartitioner().decorateKey(ByteBuffer.wrap(key.getBytes(UTF_8)));
+        return StorageService.getPartitioner().decorateKey(ByteBufferUtil.bytes(key));
     }
 
     public static Column column(String name, String value, long timestamp)
     {
-        return new Column(ByteBuffer.wrap(name.getBytes()), ByteBuffer.wrap(value.getBytes()), timestamp);
+        return new Column(ByteBufferUtil.bytes(name), ByteBufferUtil.bytes(value), timestamp);
     }
 
     public static Token token(String key)
     {
-        return StorageService.getPartitioner().getToken(ByteBuffer.wrap(key.getBytes()));
+        return StorageService.getPartitioner().getToken(ByteBufferUtil.bytes(key));
     }
 
     public static Range range(String left, String right)
@@ -68,7 +63,7 @@ public class Util
 
     public static Range range(IPartitioner p, String left, String right)
     {
-        return new Range(p.getToken(ByteBuffer.wrap(left.getBytes())), p.getToken(ByteBuffer.wrap(right.getBytes())));
+        return new Range(p.getToken(ByteBufferUtil.bytes(left)), p.getToken(ByteBufferUtil.bytes(right)));
     }
 
     public static Bounds bounds(String left, String right)
@@ -78,7 +73,7 @@ public class Util
 
     public static void addMutation(RowMutation rm, String columnFamilyName, String superColumnName, long columnName, String value, long timestamp)
     {
-        rm.add(new QueryPath(columnFamilyName, ByteBuffer.wrap(superColumnName.getBytes()), getBytes(columnName)), ByteBuffer.wrap(value.getBytes()), timestamp);
+        rm.add(new QueryPath(columnFamilyName, ByteBufferUtil.bytes(superColumnName), getBytes(columnName)), ByteBufferUtil.bytes(value), timestamp);
     }
 
     public static ByteBuffer getBytes(long v)

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/client/TestRingCache.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/client/TestRingCache.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/client/TestRingCache.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/client/TestRingCache.java Wed Mar 23 18:13:42 2011
@@ -91,7 +91,7 @@ public class TestRingCache
 
         for (int nRows = minRow; nRows < maxRow; nRows++)
         {
-            ByteBuffer row = ByteBuffer.wrap((rowPrefix + nRows).getBytes());
+            ByteBuffer row = ByteBufferUtil.bytes((rowPrefix + nRows));
             ColumnPath col = new ColumnPath("Standard1").setSuper_column((ByteBuffer)null).setColumn("col1".getBytes());
             ColumnParent parent = new ColumnParent("Standard1").setSuper_column((ByteBuffer)null);
 

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CleanupTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CleanupTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CleanupTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CleanupTest.java Wed Mar 23 18:13:42 2011
@@ -51,7 +51,7 @@ public class CleanupTest extends Cleanup
     public static final String TABLE1 = "Keyspace1";
     public static final String CF1 = "Indexed1";
     public static final String CF2 = "Standard1";
-    public static final ByteBuffer COLUMN = ByteBuffer.wrap("birthdate".getBytes());
+    public static final ByteBuffer COLUMN = ByteBufferUtil.bytes("birthdate");
     public static final ByteBuffer VALUE = ByteBuffer.allocate(8);
     static
     {

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java Wed Mar 23 18:13:42 2011
@@ -80,7 +80,7 @@ public class ColumnFamilyTest extends Sc
         cf = ColumnFamily.serializer().deserialize(new DataInputStream(bufIn));
         for (String cName : map.navigableKeySet())
         {
-            ByteBuffer val = cf.getColumn(ByteBuffer.wrap(cName.getBytes())).value();
+            ByteBuffer val = cf.getColumn(ByteBufferUtil.bytes(cName)).value();
             assert new String(val.array(),val.position(),val.remaining()).equals(map.get(cName));
         }
         assert cf.getColumnNames().size() == map.size();

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CompactionsPurgeTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CompactionsPurgeTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CompactionsPurgeTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CompactionsPurgeTest.java Wed Mar 23 18:13:42 2011
@@ -57,7 +57,7 @@ public class CompactionsPurgeTest extend
         rm = new RowMutation(TABLE1, key.key);
         for (int i = 0; i < 10; i++)
         {
-            rm.add(new QueryPath(cfName, null, ByteBuffer.wrap(String.valueOf(i).getBytes())), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
+            rm.add(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(i))), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
         }
         rm.apply();
         cfs.forceBlockingFlush();
@@ -66,14 +66,14 @@ public class CompactionsPurgeTest extend
         for (int i = 0; i < 10; i++)
         {
             rm = new RowMutation(TABLE1, key.key);
-            rm.delete(new QueryPath(cfName, null, ByteBuffer.wrap(String.valueOf(i).getBytes())), 1);
+            rm.delete(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(i))), 1);
             rm.apply();
         }
         cfs.forceBlockingFlush();
 
         // resurrect one column
         rm = new RowMutation(TABLE1, key.key);
-        rm.add(new QueryPath(cfName, null, ByteBuffer.wrap(String.valueOf(5).getBytes())), ByteBufferUtil.EMPTY_BYTE_BUFFER, 2);
+        rm.add(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(5))), ByteBufferUtil.EMPTY_BYTE_BUFFER, 2);
         rm.apply();
         cfs.forceBlockingFlush();
 
@@ -82,7 +82,7 @@ public class CompactionsPurgeTest extend
         cfs.invalidateCachedRow(key);
         ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, new QueryPath(cfName)));
         assertColumns(cf, "5");
-        assert cf.getColumn(ByteBuffer.wrap(String.valueOf(5).getBytes())) != null;
+        assert cf.getColumn(ByteBufferUtil.bytes(String.valueOf(5))) != null;
     }
 
     @Test
@@ -102,7 +102,7 @@ public class CompactionsPurgeTest extend
             rm = new RowMutation(TABLE2, key.key);
             for (int i = 0; i < 10; i++)
             {
-                rm.add(new QueryPath(cfName, null, ByteBuffer.wrap(String.valueOf(i).getBytes())), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
+                rm.add(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(i))), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
             }
             rm.apply();
             cfs.forceBlockingFlush();
@@ -111,7 +111,7 @@ public class CompactionsPurgeTest extend
             for (int i = 0; i < 10; i++)
             {
                 rm = new RowMutation(TABLE2, key.key);
-                rm.delete(new QueryPath(cfName, null, ByteBuffer.wrap(String.valueOf(i).getBytes())), 1);
+                rm.delete(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(i))), 1);
                 rm.apply();
             }
             cfs.forceBlockingFlush();
@@ -125,7 +125,7 @@ public class CompactionsPurgeTest extend
         cfs.forceBlockingFlush();
         Collection<SSTableReader> sstablesIncomplete = cfs.getSSTables();
         rm = new RowMutation(TABLE2, key1.key);
-        rm.add(new QueryPath(cfName, null, ByteBuffer.wrap(String.valueOf(5).getBytes())), ByteBufferUtil.EMPTY_BYTE_BUFFER, 2);
+        rm.add(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(5))), ByteBufferUtil.EMPTY_BYTE_BUFFER, 2);
         rm.apply();
         cfs.forceBlockingFlush();
         CompactionManager.instance.doCompaction(cfs, sstablesIncomplete, Integer.MAX_VALUE);
@@ -157,7 +157,7 @@ public class CompactionsPurgeTest extend
         rm = new RowMutation(TABLE1, key.key);
         for (int i = 0; i < 5; i++)
         {
-            rm.add(new QueryPath(cfName, null, ByteBuffer.wrap(String.valueOf(i).getBytes())), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
+            rm.add(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(i))), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
         }
         rm.apply();
 
@@ -165,7 +165,7 @@ public class CompactionsPurgeTest extend
         for (int i = 0; i < 5; i++)
         {
             rm = new RowMutation(TABLE1, key.key);
-            rm.delete(new QueryPath(cfName, null, ByteBuffer.wrap(String.valueOf(i).getBytes())), 1);
+            rm.delete(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(i))), 1);
             rm.apply();
         }
         store.forceBlockingFlush();
@@ -196,7 +196,7 @@ public class CompactionsPurgeTest extend
         rm = new RowMutation(tableName, key.key);
         for (int i = 0; i < 10; i++)
         {
-            rm.add(new QueryPath(cfName, null, ByteBuffer.wrap(String.valueOf(i).getBytes())), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
+            rm.add(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(i))), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
         }
         rm.apply();
 
@@ -217,7 +217,7 @@ public class CompactionsPurgeTest extend
         rm = new RowMutation(tableName, key.key);
         for (int i = 0; i < 10; i++)
         {
-            rm.add(new QueryPath(cfName, null, ByteBuffer.wrap(String.valueOf(i).getBytes())), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
+            rm.add(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(i))), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
         }
         rm.apply();
 

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CompactionsTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CompactionsTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CompactionsTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/CompactionsTest.java Wed Mar 23 18:13:42 2011
@@ -61,7 +61,7 @@ public class CompactionsTest extends Cle
             for (int i = 0; i < ROWS_PER_SSTABLE; i++) {
                 DecoratedKey key = Util.dk(String.valueOf(i % 2));
                 RowMutation rm = new RowMutation(TABLE1, key.key);
-                rm.add(new QueryPath("Standard1", null, ByteBuffer.wrap(String.valueOf(i / 2).getBytes())), ByteBufferUtil.EMPTY_BYTE_BUFFER, j * ROWS_PER_SSTABLE + i);
+                rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes(String.valueOf(i / 2))), ByteBufferUtil.EMPTY_BYTE_BUFFER, j * ROWS_PER_SSTABLE + i);
                 rm.apply();
                 inserted.add(key);
             }

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/DefsTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/DefsTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/DefsTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/DefsTest.java Wed Mar 23 18:13:42 2011
@@ -295,7 +295,7 @@ public class DefsTest extends CleanupHel
         // write some data, force a flush, then verify that files exist on disk.
         RowMutation rm = new RowMutation(ks.name, dk.key);
         for (int i = 0; i < 100; i++)
-            rm.add(new QueryPath(cfm.cfName, null, ByteBuffer.wrap(("col" + i).getBytes())), ByteBufferUtil.bytes("anyvalue"), 1L);
+            rm.add(new QueryPath(cfm.cfName, null, ByteBufferUtil.bytes(("col" + i))), ByteBufferUtil.bytes("anyvalue"), 1L);
         rm.apply();
         ColumnFamilyStore store = Table.open(cfm.tableName).getColumnFamilyStore(cfm.cfName);
         assert store != null;
@@ -341,7 +341,7 @@ public class DefsTest extends CleanupHel
         // write some data, force a flush, then verify that files exist on disk.
         RowMutation rm = new RowMutation(ks.name, dk.key);
         for (int i = 0; i < 100; i++)
-            rm.add(new QueryPath(oldCfm.cfName, null, ByteBuffer.wrap(("col" + i).getBytes())), ByteBufferUtil.bytes("anyvalue"), 1L);
+            rm.add(new QueryPath(oldCfm.cfName, null, ByteBufferUtil.bytes(("col" + i))), ByteBufferUtil.bytes("anyvalue"), 1L);
         rm.apply();
         ColumnFamilyStore store = Table.open(oldCfm.tableName).getColumnFamilyStore(oldCfm.cfName);
         assert store != null;
@@ -415,7 +415,7 @@ public class DefsTest extends CleanupHel
         // write some data, force a flush, then verify that files exist on disk.
         RowMutation rm = new RowMutation(ks.name, dk.key);
         for (int i = 0; i < 100; i++)
-            rm.add(new QueryPath(cfm.cfName, null, ByteBuffer.wrap(("col" + i).getBytes())), ByteBufferUtil.bytes("anyvalue"), 1L);
+            rm.add(new QueryPath(cfm.cfName, null, ByteBufferUtil.bytes(("col" + i))), ByteBufferUtil.bytes("anyvalue"), 1L);
         rm.apply();
         ColumnFamilyStore store = Table.open(cfm.tableName).getColumnFamilyStore(cfm.cfName);
         assert store != null;
@@ -465,7 +465,7 @@ public class DefsTest extends CleanupHel
         // write some data that we hope to read back later.
         RowMutation rm = new RowMutation(oldKs.name, dk.key);
         for (int i = 0; i < 10; i++)
-            rm.add(new QueryPath(cfName, null, ByteBuffer.wrap(("col" + i).getBytes())), ByteBufferUtil.bytes("value"), 1L);
+            rm.add(new QueryPath(cfName, null, ByteBufferUtil.bytes(("col" + i))), ByteBufferUtil.bytes("value"), 1L);
         rm.apply();
         ColumnFamilyStore store = Table.open(oldKs.name).getColumnFamilyStore(cfName);
         assert store != null;

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/NameSortTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/NameSortTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/NameSortTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/NameSortTest.java Wed Mar 23 18:13:42 2011
@@ -64,15 +64,15 @@ public class NameSortTest extends Cleanu
 
         for (int i = 0; i < N; ++i)
         {
-            ByteBuffer key = ByteBuffer.wrap(Integer.toString(i).getBytes());
+            ByteBuffer key = ByteBufferUtil.bytes(Integer.toString(i));
             RowMutation rm;
 
             // standard
             for (int j = 0; j < 8; ++j)
             {
-                ByteBuffer bytes = ByteBuffer.wrap(j % 2 == 0 ? "a".getBytes() : "b".getBytes());
+                ByteBuffer bytes = j % 2 == 0 ? ByteBufferUtil.bytes("a") : ByteBufferUtil.bytes("b");
                 rm = new RowMutation("Keyspace1", key);
-                rm.add(new QueryPath("Standard1", null, ByteBuffer.wrap(("Column-" + j).getBytes())), bytes, j);
+                rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes(("Column-" + j))), bytes, j);
                 rm.applyUnsafe();
             }
 

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java Wed Mar 23 18:13:42 2011
@@ -33,6 +33,7 @@ import static org.apache.cassandra.Util.
 import org.apache.cassandra.CleanupHelper;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.db.commitlog.CommitLog;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
 public class RecoveryManager2Test extends CleanupHelper
 {
@@ -73,7 +74,7 @@ public class RecoveryManager2Test extend
 
     private void insertRow(String cfname, String key) throws IOException
     {
-        RowMutation rm = new RowMutation("Keyspace1", ByteBuffer.wrap(key.getBytes()));
+        RowMutation rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes(key));
         ColumnFamily cf = ColumnFamily.create("Keyspace1", cfname);
         cf.addColumn(column("col1", "val1", 1L));
         rm.add(cf);

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java Wed Mar 23 18:13:42 2011
@@ -89,11 +89,11 @@ public class RecoveryManagerTruncateTest
 			return null;
 		}
 		cf = cfStore.getColumnFamily(QueryFilter.getNamesFilter(
-		        Util.dk(keyName), new QueryPath(cfName), ByteBuffer.wrap(columnName.getBytes())));
+		        Util.dk(keyName), new QueryPath(cfName), ByteBufferUtil.bytes(columnName)));
 		if (cf == null)
 		{
 			return null;
 		}
-		return cf.getColumn(ByteBuffer.wrap(columnName.getBytes()));
+		return cf.getColumn(ByteBufferUtil.bytes(columnName));
 	}
 }

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RowIterationTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RowIterationTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RowIterationTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/RowIterationTest.java Wed Mar 23 18:13:42 2011
@@ -55,7 +55,7 @@ public class RowIterationTest extends Cl
         for (int i = 0; i < ROWS_PER_SSTABLE; i++) {
             DecoratedKey key = Util.dk(String.valueOf(i));
             RowMutation rm = new RowMutation(TABLE1, key.key);
-            rm.add(new QueryPath("Super3", ByteBufferUtil.bytes("sc"), ByteBuffer.wrap(String.valueOf(i).getBytes())), ByteBuffer.wrap(new byte[ROWS_PER_SSTABLE * 10 - i * 2]), i);
+            rm.add(new QueryPath("Super3", ByteBufferUtil.bytes("sc"), ByteBufferUtil.bytes(String.valueOf(i))), ByteBuffer.wrap(new byte[ROWS_PER_SSTABLE * 10 - i * 2]), i);
             rm.apply();
             inserted.add(key);
         }

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/SerializationsTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/SerializationsTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/SerializationsTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/SerializationsTest.java Wed Mar 23 18:13:42 2011
@@ -32,6 +32,8 @@ import org.apache.cassandra.net.Message;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.thrift.SlicePredicate;
 import org.apache.cassandra.thrift.SliceRange;
+import org.apache.cassandra.utils.ByteBufferUtil;
+
 import org.junit.Test;
 
 import java.io.DataInputStream;
@@ -47,9 +49,9 @@ public class SerializationsTest extends 
 {
     private void testRangeSliceCommandWrite() throws IOException
     {
-        ByteBuffer startCol = ByteBuffer.wrap("Start".getBytes());
-        ByteBuffer stopCol = ByteBuffer.wrap("Stop".getBytes());
-        ByteBuffer emptyCol = ByteBuffer.wrap("".getBytes());
+        ByteBuffer startCol = ByteBufferUtil.bytes("Start");
+        ByteBuffer stopCol = ByteBufferUtil.bytes("Stop");
+        ByteBuffer emptyCol = ByteBufferUtil.bytes("");
         SlicePredicate namesPred = new SlicePredicate();
         namesPred.column_names = Statics.NamedCols;
         SliceRange emptySliceRange = new SliceRange(emptyCol, emptyCol, false, 100); 
@@ -284,24 +286,24 @@ public class SerializationsTest extends 
     }
     
     private static ByteBuffer bb(String s) {
-        return ByteBuffer.wrap(s.getBytes());
+        return ByteBufferUtil.bytes(s);
     }
     
     private static class Statics 
     {
         private static final String KS = "Keyspace1";
-        private static final ByteBuffer Key = ByteBuffer.wrap("Key01".getBytes());
+        private static final ByteBuffer Key = ByteBufferUtil.bytes("Key01");
         private static final List<ByteBuffer> NamedCols = new ArrayList<ByteBuffer>() 
         {{
-            add(ByteBuffer.wrap("AAA".getBytes()));     
-            add(ByteBuffer.wrap("BBB".getBytes()));     
-            add(ByteBuffer.wrap("CCC".getBytes()));     
+            add(ByteBufferUtil.bytes("AAA"));
+            add(ByteBufferUtil.bytes("BBB"));
+            add(ByteBufferUtil.bytes("CCC"));
         }};
-        private static final ByteBuffer SC = ByteBuffer.wrap("SCName".getBytes());
+        private static final ByteBuffer SC = ByteBufferUtil.bytes("SCName");
         private static final QueryPath StandardPath = new QueryPath("Standard1");
         private static final QueryPath SuperPath = new QueryPath("Super1", SC);
-        private static final ByteBuffer Start = ByteBuffer.wrap("Start".getBytes());
-        private static final ByteBuffer Stop = ByteBuffer.wrap("Stop".getBytes());
+        private static final ByteBuffer Start = ByteBufferUtil.bytes("Start");
+        private static final ByteBuffer Stop = ByteBufferUtil.bytes("Stop");
         
         private static final ColumnFamily StandardCf = ColumnFamily.create(Statics.KS, "Standard1");
         private static final ColumnFamily SuperCf = ColumnFamily.create(Statics.KS, "Super1");



Mime
View raw message