cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1084660 [2/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
Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/TimeSortTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/TimeSortTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/TimeSortTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/TimeSortTest.java Wed
Mar 23 18:13:42 2011
@@ -68,7 +68,7 @@ public class TimeSortTest extends Cleanu
 
         for (int i = 900; i < 1000; ++i)
         {
-            RowMutation rm = new RowMutation("Keyspace1", ByteBuffer.wrap(Integer.toString(i).getBytes()));
+            RowMutation rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes(Integer.toString(i)));
             for (int j = 0; j < 8; ++j)
             {
                 rm.add(new QueryPath("StandardLong1", null, getBytes(j * 2)), ByteBufferUtil.bytes("a"),
j * 2);

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java
Wed Mar 23 18:13:42 2011
@@ -150,7 +150,7 @@ public class LazilyCompactedRowTest exte
         Table table = Table.open("Keyspace1");
         ColumnFamilyStore cfs = table.getColumnFamilyStore("Standard1");
 
-        ByteBuffer key =ByteBuffer.wrap( "k".getBytes() );
+        ByteBuffer key = ByteBufferUtil.bytes("k");
         RowMutation rm = new RowMutation("Keyspace1", key);
         rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("c")), ByteBufferUtil.EMPTY_BYTE_BUFFER,
0);
         rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("d")), ByteBufferUtil.EMPTY_BYTE_BUFFER,
0);
@@ -212,9 +212,9 @@ public class LazilyCompactedRowTest exte
         final int ROWS_PER_SSTABLE = 10;
         for (int j = 0; j < (DatabaseDescriptor.getIndexInterval() * 3) / ROWS_PER_SSTABLE;
j++) {
             for (int i = 0; i < ROWS_PER_SSTABLE; i++) {
-                ByteBuffer key = ByteBuffer.wrap(String.valueOf(i % 2).getBytes());
+                ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(i % 2));
                 RowMutation rm = new RowMutation("Keyspace1", 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();
             }
             cfs.forceBlockingFlush();

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java
Wed Mar 23 18:13:42 2011
@@ -28,6 +28,7 @@ import org.apache.cassandra.CleanupHelpe
 import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.db.columniterator.SSTableNamesIterator;
 import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.ByteBufferUtil;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -99,7 +100,7 @@ public class LegacySSTableTest extends C
             SSTableReader reader = SSTableReader.open(getDescriptor(version));
             for (String keystring : TEST_DATA)
             {
-                ByteBuffer key = ByteBuffer.wrap(keystring.getBytes());
+                ByteBuffer key = ByteBufferUtil.bytes(keystring);
                 // confirm that the bloom filter does not reject any keys/names
                 DecoratedKey dk = reader.partitioner.decorateKey(key);
                 SSTableNamesIterator iter = new SSTableNamesIterator(reader, dk, FBUtilities.singleton(key));

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
Wed Mar 23 18:13:42 2011
@@ -49,7 +49,7 @@ public class SSTableReaderTest extends C
 {
     static Token t(int i)
     {
-        return StorageService.getPartitioner().getToken(ByteBuffer.wrap(String.valueOf(i).getBytes()));
+        return StorageService.getPartitioner().getToken(ByteBufferUtil.bytes(String.valueOf(i)));
     }
 
     @Test
@@ -62,7 +62,7 @@ public class SSTableReaderTest extends C
         CompactionManager.instance.disableAutoCompaction();
         for (int j = 0; j < 10; j++)
         {
-            ByteBuffer key = ByteBuffer.wrap(String.valueOf(j).getBytes());
+            ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(j));
             RowMutation rm = new RowMutation("Keyspace1", key);
             rm.add(new QueryPath("Standard2", null, ByteBufferUtil.bytes("0")), ByteBufferUtil.EMPTY_BYTE_BUFFER,
j);
             rm.apply();
@@ -103,7 +103,7 @@ public class SSTableReaderTest extends C
         CompactionManager.instance.disableAutoCompaction();
         for (int j = 0; j < 100; j += 2)
         {
-            ByteBuffer key = ByteBuffer.wrap(String.valueOf(j).getBytes());
+            ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(j));
             RowMutation rm = new RowMutation("Keyspace1", key);
             rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("0")), ByteBufferUtil.EMPTY_BYTE_BUFFER,
j);
             rm.apply();
@@ -140,7 +140,7 @@ public class SSTableReaderTest extends C
 
         for (int j = 0; j < 100; j += 2)
         {
-            ByteBuffer key = ByteBuffer.wrap(String.valueOf(j).getBytes());
+            ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(j));
             RowMutation rm = new RowMutation("Keyspace1", key);
             rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("0")), ByteBufferUtil.EMPTY_BYTE_BUFFER,
j);
             rm.apply();

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java
Wed Mar 23 18:13:42 2011
@@ -34,7 +34,7 @@ public class SSTableTest extends Cleanup
     @Test
     public void testSingleWrite() throws IOException {
         // write test data
-        ByteBuffer key = ByteBuffer.wrap(Integer.toString(1).getBytes());
+        ByteBuffer key = ByteBufferUtil.bytes(Integer.toString(1));
         ByteBuffer bytes = ByteBuffer.wrap(new byte[1024]);
         new Random().nextBytes(bytes.array());
 
@@ -64,7 +64,7 @@ public class SSTableTest extends Cleanup
         Map<ByteBuffer, ByteBuffer> map = new HashMap<ByteBuffer,ByteBuffer>();
         for (int i = 100; i < 1000; ++i)
         {
-            map.put(ByteBuffer.wrap(Integer.toString(i).getBytes()), ByteBuffer.wrap(("Avinash
Lakshman is a good man: " + i).getBytes()));
+            map.put(ByteBufferUtil.bytes(Integer.toString(i)), ByteBufferUtil.bytes(("Avinash
Lakshman is a good man: " + i)));
         }
 
         // write

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java
Wed Mar 23 18:13:42 2011
@@ -29,6 +29,7 @@ import org.apache.cassandra.db.ColumnFam
 import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.db.IColumn;
 import org.apache.cassandra.io.util.DataOutputBuffer;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
 public class SSTableUtils
 {
@@ -122,7 +123,7 @@ public class SSTableUtils
             for (String key : keys)
             {
                 ColumnFamily cf = ColumnFamily.create(ksname, cfname);
-                cf.addColumn(new Column(ByteBuffer.wrap(key.getBytes()), ByteBuffer.wrap(key.getBytes()),
0));
+                cf.addColumn(new Column(ByteBufferUtil.bytes(key), ByteBufferUtil.bytes(key),
0));
                 map.put(key, cf);
             }
             return write(map);
@@ -135,8 +136,7 @@ public class SSTableUtils
             {
                 DataOutputBuffer buffer = new DataOutputBuffer();
                 ColumnFamily.serializer().serializeWithIndexes(entry.getValue(), buffer);
-                map.put(ByteBuffer.wrap(entry.getKey().getBytes()),
-                        ByteBuffer.wrap(buffer.asByteArray()));
+                map.put(ByteBufferUtil.bytes(entry.getKey()), ByteBuffer.wrap(buffer.asByteArray()));
             }
             return writeRaw(map);
         }

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java
Wed Mar 23 18:13:42 2011
@@ -36,6 +36,7 @@ import org.apache.cassandra.db.Table;
 import org.apache.cassandra.dht.*;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.service.StorageServiceAccessor;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
 import static org.junit.Assert.*;
 
@@ -68,7 +69,7 @@ public class SimpleStrategyTest extends 
         List<Token> keyTokens = new ArrayList<Token>();
         for (int i = 0; i < 5; i++) {
             endpointTokens.add(new StringToken(String.valueOf((char)('a' + i * 2))));
-            keyTokens.add(partitioner.getToken(ByteBuffer.wrap(String.valueOf((char)('a'
+ i * 2 + 1)).getBytes())));
+            keyTokens.add(partitioner.getToken(ByteBufferUtil.bytes(String.valueOf((char)('a'
+ i * 2 + 1)))));
         }
         verifyGetNaturalEndpoints(endpointTokens.toArray(new Token[0]), keyTokens.toArray(new
Token[0]));
     }

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java
Wed Mar 23 18:13:42 2011
@@ -20,6 +20,7 @@ package org.apache.cassandra.service;
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.nio.charset.CharacterCodingException;
 
 import com.google.common.base.Charsets;
 import org.junit.BeforeClass;
@@ -69,8 +70,8 @@ public class EmbeddedCassandraServiceTes
     }
 
     @Test
-    public void testEmbeddedCassandraService() throws AuthenticationException, AuthorizationException,
-    InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException
+    public void testEmbeddedCassandraService()
+    throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException,
TimedOutException, TException, NotFoundException, CharacterCodingException
     {
         Cassandra.Client client = getClient();
         client.set_keyspace("Keyspace1");
@@ -84,14 +85,14 @@ public class EmbeddedCassandraServiceTes
 
         // insert
         client.insert(key_user_id, par, new Column(ByteBufferUtil.bytes("name"),
-                ByteBuffer.wrap( "Ran".getBytes(Charsets.UTF_8)), timestamp), ConsistencyLevel.ONE);
+                      ByteBufferUtil.bytes("Ran"), timestamp), ConsistencyLevel.ONE);
 
         // read
         ColumnOrSuperColumn got = client.get(key_user_id, cp, ConsistencyLevel.ONE);
 
         // assert
         assertNotNull("Got a null ColumnOrSuperColumn", got);
-        assertEquals("Ran", new String(got.getColumn().getValue(), Charsets.UTF_8));
+        assertEquals("Ran", ByteBufferUtil.string(got.getColumn().value));
     }
 
     /**

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/SerializationsTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/SerializationsTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/SerializationsTest.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/SerializationsTest.java
Wed Mar 23 18:13:42 2011
@@ -31,6 +31,7 @@ import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.io.sstable.SSTable;
 import org.apache.cassandra.net.Message;
+import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.Pair;
 import org.junit.Test;
@@ -144,7 +145,7 @@ public class SerializationsTest extends 
     {
         Collection<Range> ranges = new ArrayList<Range>();
         for (int i = 0; i < 5; i++)
-            ranges.add(new Range(new BytesToken(ByteBuffer.wrap(Integer.toString(10*i).getBytes())),
new BytesToken(ByteBuffer.wrap(Integer.toString(10*i+5).getBytes()))));
+            ranges.add(new Range(new BytesToken(ByteBufferUtil.bytes(Integer.toString(10*i))),
new BytesToken(ByteBufferUtil.bytes(Integer.toString(10*i+5)))));
         StreamRequestMessage msg0 = new StreamRequestMessage(FBUtilities.getLocalAddress(),
ranges, "Keyspace1", 123L);
         StreamRequestMessage msg1 = new StreamRequestMessage(FBUtilities.getLocalAddress(),
makePendingFile(true, "aa", 100), 124L);
         StreamRequestMessage msg2 = new StreamRequestMessage(FBUtilities.getLocalAddress(),
makePendingFile(false, "aa", 100), 124L);
@@ -180,8 +181,8 @@ public class SerializationsTest extends 
         Table t = Table.open("Keyspace1");
         for (int i = 0; i < 100; i++)
         {
-            RowMutation rm = new RowMutation(t.name, ByteBuffer.wrap(Long.toString(System.nanoTime()).getBytes()));
-            rm.add(new QueryPath("Standard1", null, ByteBuffer.wrap("cola".getBytes())),
ByteBuffer.wrap("value".getBytes()), 0);
+            RowMutation rm = new RowMutation(t.name, ByteBufferUtil.bytes(Long.toString(System.nanoTime())));
+            rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("cola")), ByteBufferUtil.bytes("value"),
0);
             try
             {
                 rm.apply();

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
Wed Mar 23 18:13:42 2011
@@ -68,7 +68,7 @@ public class StreamingTransferTest exten
         for (int i = 1; i <= 3; i++)
         {
             String key = "key" + i;
-            RowMutation rm = new RowMutation("Keyspace1", ByteBuffer.wrap(key.getBytes()));
+            RowMutation rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes(key));
             ColumnFamily cf = ColumnFamily.create(table.name, cfs.columnFamily);
             cf.addColumn(column(key, "v", 0));
             cf.addColumn(new Column(ByteBufferUtil.bytes("birthdate"), ByteBufferUtil.bytes((long)
i), 0));
@@ -143,8 +143,8 @@ public class StreamingTransferTest exten
         ColumnFamilyStore cfstore = Table.open(tablename).getColumnFamilyStore(cfname);
         List<Row> rows = Util.getRangeSlice(cfstore);
         assertEquals(6, rows.size());
-        assert rows.get(0).key.key.equals( ByteBufferUtil.bytes("test"));
-        assert rows.get(3).key.key.equals(ByteBuffer.wrap( "transfer1".getBytes() ));
+        assert rows.get(0).key.key.equals(ByteBufferUtil.bytes("test"));
+        assert rows.get(3).key.key.equals(ByteBufferUtil.bytes("transfer1"));
         assert rows.get(0).cf.getColumnsMap().size() == 1;
         assert rows.get(3).cf.getColumnsMap().size() == 1;
 

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/tools/SSTableExportTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
Wed Mar 23 18:13:42 2011
@@ -54,7 +54,7 @@ public class SSTableExportTest extends S
 {
     public String asHex(String str)
     {
-        return bytesToHex(ByteBuffer.wrap(str.getBytes()));
+        return bytesToHex(ByteBufferUtil.bytes(str));
     }
 
     @Test

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/ByteBufferUtilTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/ByteBufferUtilTest.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/ByteBufferUtilTest.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/ByteBufferUtilTest.java
Wed Mar 23 18:13:42 2011
@@ -218,7 +218,7 @@ public class ByteBufferUtilTest
     public void testDecode() throws IOException
     {
         ByteBuffer bytes = ByteBuffer.wrap(new byte[]{(byte)0xff, (byte)0xfe});
-        ByteBufferUtil.string(bytes, Charsets.UTF_8);
+        ByteBufferUtil.string(bytes);
     }
 
     @Test

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/KeyGenerator.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/KeyGenerator.java?rev=1084660&r1=1084659&r2=1084660&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/KeyGenerator.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/KeyGenerator.java
Wed Mar 23 18:13:42 2011
@@ -92,7 +92,7 @@ public class KeyGenerator {
         }
 
         public ByteBuffer next() {
-            return ByteBuffer.wrap(Integer.toString(i++).getBytes());
+            return ByteBufferUtil.bytes(Integer.toString(i++));
         }
 
         public void remove() {



Mime
View raw message