cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1026201 - in /cassandra/trunk: ./ contrib/bmt_example/ lib/ lib/licenses/ src/java/org/apache/cassandra/auth/ src/java/org/apache/cassandra/cli/ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/db/filter/ src/java/org/apache...
Date Fri, 22 Oct 2010 03:23:52 GMT
Author: jbellis
Date: Fri Oct 22 03:23:51 2010
New Revision: 1026201

URL: http://svn.apache.org/viewvc?rev=1026201&view=rev
Log:
upgrade to Thrift 0.5
patch by Jake Luciani; reviewed by jbellis for CASSANDRA-1367

Added:
    cassandra/trunk/lib/libthrift-0.5.jar
    cassandra/trunk/lib/licenses/libthrift-0.5.txt
      - copied, changed from r1026200, cassandra/trunk/libthrift-r959516.txt
Removed:
    cassandra/trunk/lib/libthrift-r959516.jar
    cassandra/trunk/libthrift-r959516.txt
Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/contrib/bmt_example/CassandraBulkLoader.java
    cassandra/trunk/src/java/org/apache/cassandra/auth/Resources.java
    cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/trunk/src/java/org/apache/cassandra/db/DeletedColumn.java
    cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
    cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java
    cassandra/trunk/src/java/org/apache/cassandra/db/marshal/BytesType.java
    cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java
    cassandra/trunk/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java
    cassandra/trunk/src/java/org/apache/cassandra/dht/BytesToken.java
    cassandra/trunk/src/java/org/apache/cassandra/dht/LocalToken.java
    cassandra/trunk/src/java/org/apache/cassandra/dht/Range.java
    cassandra/trunk/src/java/org/apache/cassandra/hadoop/ConfigHelper.java
    cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
    cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java
    cassandra/trunk/src/java/org/apache/cassandra/utils/MerkleTree.java
    cassandra/trunk/src/java/org/apache/cassandra/utils/MurmurHash.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Fri Oct 22 03:23:51 2010
@@ -56,6 +56,7 @@ dev
  * move endpoint cache from snitch to strategy (CASSANDRA-1643)
  * fix commitlog recovery deleting the newly-created segment as well as
    the old ones (CASSANDRA-1644)
+ * upgrade to Thrift 0.5 (CASSANDRA-1367)
 
 
 0.7-beta2

Modified: cassandra/trunk/contrib/bmt_example/CassandraBulkLoader.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/contrib/bmt_example/CassandraBulkLoader.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/contrib/bmt_example/CassandraBulkLoader.java (original)
+++ cassandra/trunk/contrib/bmt_example/CassandraBulkLoader.java Fri Oct 22 03:23:51 2010
@@ -259,7 +259,7 @@ public class CassandraBulkLoader {
             byte[] data = new byte[bufOut.getLength()];
             System.arraycopy(bufOut.getData(), 0, data, 0, bufOut.getLength());
 
-            column = new Column(FBUtilities.toByteArray(cf.id()), data, 0);
+            column = new Column(FBUtilities.toByteBuffer(cf.id()), data, 0);
             baseColumnFamily.addColumn(column);
         }
         rm = new RowMutation(Keyspace, Key);

Added: cassandra/trunk/lib/libthrift-0.5.jar
URL: http://svn.apache.org/viewvc/cassandra/trunk/lib/libthrift-0.5.jar?rev=1026201&view=auto
==============================================================================
Files cassandra/trunk/lib/libthrift-0.5.jar (added) and cassandra/trunk/lib/libthrift-0.5.jar Fri Oct 22 03:23:51 2010 differ

Copied: cassandra/trunk/lib/licenses/libthrift-0.5.txt (from r1026200, cassandra/trunk/libthrift-r959516.txt)
URL: http://svn.apache.org/viewvc/cassandra/trunk/lib/licenses/libthrift-0.5.txt?p2=cassandra/trunk/lib/licenses/libthrift-0.5.txt&p1=cassandra/trunk/libthrift-r959516.txt&r1=1026200&r2=1026201&rev=1026201&view=diff
==============================================================================
    (empty)

Modified: cassandra/trunk/src/java/org/apache/cassandra/auth/Resources.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/auth/Resources.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/auth/Resources.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/auth/Resources.java Fri Oct 22 03:23:51 2010
@@ -43,7 +43,7 @@ public final class Resources
         {
             buff.append("/");
             if (component instanceof byte[])
-                buff.append(FBUtilities.bytesToHex(ByteBuffer.wrap((byte[])component)));
+                buff.append(FBUtilities.bytesToHex((byte[])component));
             else
                 buff.append(component.toString());
         }

Modified: cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java Fri Oct 22 03:23:51 2010
@@ -20,58 +20,17 @@ package org.apache.cassandra.cli;
 import java.io.UnsupportedEncodingException;
 import java.math.BigInteger;
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
+import java.util.*;
 
 import org.antlr.runtime.tree.CommonTree;
 import org.antlr.runtime.tree.Tree;
 import org.apache.cassandra.auth.SimpleAuthenticator;
 import org.apache.cassandra.config.ConfigurationException;
-import org.apache.cassandra.db.marshal.AbstractType;
-import org.apache.cassandra.db.marshal.AsciiType;
-import org.apache.cassandra.db.marshal.BytesType;
-import org.apache.cassandra.db.marshal.IntegerType;
-import org.apache.cassandra.db.marshal.LexicalUUIDType;
-import org.apache.cassandra.db.marshal.LongType;
-import org.apache.cassandra.db.marshal.TimeUUIDType;
-import org.apache.cassandra.db.marshal.UTF8Type;
-import org.apache.cassandra.thrift.AuthenticationException;
-import org.apache.cassandra.thrift.AuthenticationRequest;
-import org.apache.cassandra.thrift.AuthorizationException;
-import org.apache.cassandra.thrift.Cassandra;
-import org.apache.cassandra.thrift.CfDef;
-import org.apache.cassandra.thrift.Column;
-import org.apache.cassandra.thrift.ColumnDef;
-import org.apache.cassandra.thrift.ColumnOrSuperColumn;
-import org.apache.cassandra.thrift.ColumnParent;
-import org.apache.cassandra.thrift.ColumnPath;
-import org.apache.cassandra.thrift.ConsistencyLevel;
-import org.apache.cassandra.thrift.IndexClause;
-import org.apache.cassandra.thrift.IndexExpression;
-import org.apache.cassandra.thrift.IndexOperator;
-import org.apache.cassandra.thrift.IndexType;
-import org.apache.cassandra.thrift.InvalidRequestException;
-import org.apache.cassandra.thrift.KeyRange;
-import org.apache.cassandra.thrift.KeySlice;
-import org.apache.cassandra.thrift.KsDef;
-import org.apache.cassandra.thrift.NotFoundException;
-import org.apache.cassandra.thrift.SlicePredicate;
-import org.apache.cassandra.thrift.SliceRange;
-import org.apache.cassandra.thrift.SuperColumn;
-import org.apache.cassandra.thrift.TimedOutException;
-import org.apache.cassandra.thrift.UnavailableException;
+import org.apache.cassandra.db.marshal.*;
+import org.apache.cassandra.thrift.*;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.UUIDGen;
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.thrift.TException;
 
 // Cli Client Side Library
@@ -674,7 +633,7 @@ public class CliClient 
                 Column column = cosc.column;
                 validator = getValidatorForValue(cfDef, column.getName());
                 css_.out.printf("=> (column=%s, value=%s, timestamp=%d)\n", formatColumnName(keyspace, columnFamily, column),
-                               validator.getString(column.value), column.timestamp);
+                                validator.getString(column.value), column.timestamp);
             }
         }
         
@@ -771,7 +730,7 @@ public class CliClient 
             return;
         }
 
-        ByteBuffer columnNameInBytes = columnNameAsByteArray(columnName, columnFamily);
+        ByteBuffer columnNameInBytes = columnNameAsBytes(columnName, columnFamily);
         AbstractType validator = getValidatorForValue(columnFamilyDef, columnNameInBytes.array());
         
         // Perform a get()
@@ -848,7 +807,7 @@ public class CliClient 
             try
             {
                 ByteBuffer value;
-                ByteBuffer columnName = columnNameAsByteArray(columnNameString, columnFamily);
+                ByteBuffer columnName = columnNameAsBytes(columnNameString, columnFamily);
 
                 if (valueTree.getType() == CliParser.FUNCTION_CALL)
                 {
@@ -857,7 +816,7 @@ public class CliClient 
                 else
                 {
                     String valueString = CliUtils.unescapeSQLString(valueTree.getText());
-                    value = columnValueAsByteArray(columnName, columnFamily, valueString);
+                    value = columnValueAsBytes(columnName, columnFamily, valueString);
                 }
 
                 // index operator from string
@@ -946,7 +905,7 @@ public class CliClient 
         }
 
 
-        ByteBuffer columnNameInBytes = columnNameAsByteArray(columnName, columnFamily);
+        ByteBuffer columnNameInBytes = columnNameAsBytes(columnName, columnFamily);
         ByteBuffer columnValueInBytes;
 
         switch (valueTree.getType())
@@ -955,7 +914,7 @@ public class CliClient 
             columnValueInBytes = convertValueByFunction(valueTree, getCfDef(columnFamily), columnNameInBytes, true);
             break;
         default:
-            columnValueInBytes = columnValueAsByteArray(columnNameInBytes, columnFamily, value);
+            columnValueInBytes = columnValueAsBytes(columnNameInBytes, columnFamily, value);
         }
 
         ColumnParent parent = new ColumnParent(columnFamily);
@@ -1727,7 +1686,7 @@ public class CliClient 
                 throw new RuntimeException("'" + object + "' could not be translated into a LongType.");
             }
 
-            return FBUtilities.toByteArray(longType);
+            return FBUtilities.toByteBuffer(longType);
         }
         else if (comparator instanceof LexicalUUIDType || comparator instanceof TimeUUIDType)
         {
@@ -1773,7 +1732,7 @@ public class CliClient 
      * @throws IllegalAccessException - raised from getFormatTypeForColumn call
      * @throws UnsupportedEncodingException - raised from getBytes() calls
      */
-    private ByteBuffer columnNameAsByteArray(String column, String columnFamily) throws NoSuchFieldException, InstantiationException, IllegalAccessException, UnsupportedEncodingException
+    private ByteBuffer columnNameAsBytes(String column, String columnFamily) throws NoSuchFieldException, InstantiationException, IllegalAccessException, UnsupportedEncodingException
     {
         CfDef columnFamilyDef   = getCfDef(columnFamily);
         String comparatorClass  = columnFamilyDef.comparator_type;
@@ -1788,7 +1747,7 @@ public class CliClient 
      * @param columnValue - actual column value
      * @return byte[] - value in byte array representation
      */
-    private ByteBuffer columnValueAsByteArray(ByteBuffer columnName, String columnFamilyName, String columnValue)
+    private ByteBuffer columnValueAsBytes(ByteBuffer columnName, String columnFamilyName, String columnValue)
     {
         CfDef columnFamilyDef = getCfDef(columnFamilyName);
         

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Fri Oct 22 03:23:51 2010
@@ -97,14 +97,12 @@ import org.apache.cassandra.service.Stor
 import org.apache.cassandra.thrift.IndexClause;
 import org.apache.cassandra.thrift.IndexExpression;
 import org.apache.cassandra.thrift.IndexOperator;
-import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.EstimatedHistogram;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.LatencyTracker;
 import org.apache.cassandra.utils.Pair;
 import org.apache.cassandra.utils.WrappedRunnable;
 import org.apache.commons.collections.IteratorUtils;
-import org.apache.commons.lang.ArrayUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -329,7 +327,7 @@ public class ColumnFamilyStore implement
             {
                 throw new AssertionError(e);
             }
-            buildSecondaryIndexes(getSSTables(), FBUtilities.getSingleColumnSet(info.name));
+            buildSecondaryIndexes(getSSTables(), FBUtilities.singleton(info.name));
             logger.info("Index {} complete", indexedCfMetadata.cfName);
             SystemTable.setIndexBuilt(table.name, indexedCfMetadata.cfName);
         }
@@ -1429,7 +1427,7 @@ public class ColumnFamilyStore implement
                 if (rows.size() == clause.count)
                     break outer;
             }
-            if (n < clause.count || ByteBufferUtil.equals(startKey, dataKey))
+            if (n < clause.count || startKey.equals(dataKey))
                 break;
             startKey = dataKey;
         }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/DeletedColumn.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/DeletedColumn.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/DeletedColumn.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/DeletedColumn.java Fri Oct 22 03:23:51 2010
@@ -20,7 +20,6 @@ package org.apache.cassandra.db;
 
 import java.nio.ByteBuffer;
 
-import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -31,7 +30,7 @@ public class DeletedColumn extends Colum
     
     public DeletedColumn(ByteBuffer name, int localDeletionTime, long timestamp)
     {
-        this(name, FBUtilities.toByteArray(localDeletionTime), timestamp);
+        this(name, FBUtilities.toByteBuffer(localDeletionTime), timestamp);
     }
 
     public DeletedColumn(ByteBuffer name, ByteBuffer value, long timestamp)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java Fri Oct 22 03:23:51 2010
@@ -41,7 +41,7 @@ import org.apache.cassandra.dht.IPartiti
 import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.FBUtilities;
-import org.apache.commons.lang.ArrayUtils;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -284,13 +284,13 @@ public class SystemTable
         }
         else
         {
-            generation = Math.max(FBUtilities.byteArrayToInt(cf.getColumn(GENERATION).value()) + 1,
+            generation = Math.max(FBUtilities.byteBufferToInt(cf.getColumn(GENERATION).value()) + 1,
                                   (int) (System.currentTimeMillis() / 1000));
         }
 
         RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, LOCATION_KEY);
         cf = ColumnFamily.create(Table.SYSTEM_TABLE, SystemTable.STATUS_CF);
-        cf.addColumn(new Column(GENERATION, FBUtilities.toByteArray(generation), FBUtilities.timestampMicros()));
+        cf.addColumn(new Column(GENERATION, FBUtilities.toByteBuffer(generation), FBUtilities.timestampMicros()));
         rm.add(cf);
         rm.apply();
         forceBlockingFlush(STATUS_CF);

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Fri Oct 22 03:23:51 2010
@@ -23,7 +23,6 @@ import java.io.IOError;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -50,7 +49,6 @@ import org.apache.cassandra.io.sstable.S
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.FBUtilities;
-import org.apache.commons.lang.ArrayUtils;
 import org.cliffc.high_scale_lib.NonBlockingHashMap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -609,7 +607,7 @@ public class Table
             Collection<IColumn> columns = columnFamily.getSortedColumns();
             for (IColumn column : columns)
             {
-                ColumnFamilyStore cfStore = columnFamilyStores.get(FBUtilities.byteArrayToInt(column.name()));
+                ColumnFamilyStore cfStore = columnFamilyStores.get(FBUtilities.byteBufferToInt(column.name()));
                 cfStore.applyBinary(key, column.value());
             }
         }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java Fri Oct 22 03:23:51 2010
@@ -51,7 +51,7 @@ public class NamesQueryFilter implements
 
     public NamesQueryFilter(ByteBuffer column)
     {
-        this(FBUtilities.getSingleColumnSet(column));
+        this(FBUtilities.singleton(column));
     }
 
     public IColumnIterator getMemtableColumnIterator(ColumnFamily cf, DecoratedKey key, AbstractType comparator)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java Fri Oct 22 03:23:51 2010
@@ -22,7 +22,6 @@ package org.apache.cassandra.db.filter;
 
 
 import java.nio.ByteBuffer;
-import java.util.Arrays;
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.SortedSet;
@@ -41,7 +40,6 @@ import org.apache.cassandra.io.sstable.S
 import org.apache.cassandra.io.util.FileDataInput;
 import org.apache.cassandra.thrift.SlicePredicate;
 import org.apache.cassandra.thrift.SliceRange;
-import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.ReducingIterator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -116,7 +114,7 @@ public class QueryFilter
 
             protected boolean isEqual(IColumn o1, IColumn o2)
             {
-                return ByteBufferUtil.equals(o1.name(), o2.name());              
+                return o1.name().equals(o2.name());
             }
 
             public void reduce(IColumn current)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/marshal/BytesType.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/marshal/BytesType.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/marshal/BytesType.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/marshal/BytesType.java Fri Oct 22 03:23:51 2010
@@ -39,7 +39,7 @@ public class BytesType extends AbstractT
             else return -1;
         }
               
-        return ByteBufferUtil.compare(o1, o2);
+        return ByteBufferUtil.compareUnsigned(o1, o2);
     }
 
     public String getString(ByteBuffer bytes)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java Fri Oct 22 03:23:51 2010
@@ -47,7 +47,7 @@ public class LongType extends AbstractTy
             return diff;
         
        
-        return ByteBufferUtil.compare(o1, o2);
+        return ByteBufferUtil.compareUnsigned(o1, o2);
     }
 
     public String getString(ByteBuffer bytes)

Modified: cassandra/trunk/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java Fri Oct 22 03:23:51 2010
@@ -85,19 +85,8 @@ public abstract class AbstractByteOrdere
     private BigInteger bigForBytes(ByteBuffer bytes, int sigbytes)
     {
         byte[] b = new byte[sigbytes];
-        
-        // append zeros
-        Arrays.fill(b, (byte) 0);
-        
-        if (bytes.remaining() != sigbytes)
-        {                     
-            System.arraycopy(bytes.array(), bytes.position()+bytes.arrayOffset(), b, 0, bytes.remaining());
-        } 
-        else
-        {
-            System.arraycopy(bytes.array(), bytes.position()+bytes.arrayOffset(), b, 0, sigbytes);
-        }
-        
+        Arrays.fill(b, (byte) 0); // append zeros
+        System.arraycopy(bytes.array(), bytes.position()+bytes.arrayOffset(), b, 0, bytes.remaining());
         return new BigInteger(1, b);
     }
 
@@ -150,7 +139,7 @@ public abstract class AbstractByteOrdere
 
         public String toString(Token<byte[]> bytesToken)
         {
-            return FBUtilities.bytesToHex(ByteBuffer.wrap(bytesToken.token));
+            return FBUtilities.bytesToHex(bytesToken.token);
         }
 
         public Token<byte[]> fromString(String string)

Modified: cassandra/trunk/src/java/org/apache/cassandra/dht/BytesToken.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/dht/BytesToken.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/dht/BytesToken.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/dht/BytesToken.java Fri Oct 22 03:23:51 2010
@@ -21,14 +21,13 @@ package org.apache.cassandra.dht;
 import java.nio.ByteBuffer;
 import java.util.Arrays;
 
-import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 
 public class BytesToken extends Token<byte[]>
 {
 	public BytesToken(ByteBuffer token)
 	{
-		super(convertByteBuffer(token));
+		this(convertByteBuffer(token));
 	}
 	
     public BytesToken(byte[] token)
@@ -38,32 +37,31 @@ public class BytesToken extends Token<by
     
     private static byte[] convertByteBuffer(ByteBuffer token)
     {
-    	if(token.position() == 0 && token.arrayOffset() == 0 && 
-    			   token.limit() == token.capacity())
-    	{
-    		return token.array();
-    	}
-    	else
-    	{
-    		token.mark();
-    		byte[] buf = new byte[token.remaining()];
-    		token.get(buf);
-    		token.reset();
-    				
-    		return buf;
-    	} 	
+        if (token.position() == 0 && token.arrayOffset() == 0 && token.limit() == token.capacity())
+        {
+            return token.array();
+        }
+        else
+        {
+            token.mark();
+            byte[] buf = new byte[token.remaining()];
+            token.get(buf);
+            token.reset();
+
+            return buf;
+        }
     }
     
     @Override
     public String toString()
     {
-        return "Token(bytes[" + FBUtilities.bytesToHex(ByteBuffer.wrap(token)) + "])";
+        return "Token(bytes[" + FBUtilities.bytesToHex(token) + "])";
     }
 
     @Override
     public int compareTo(Token<byte[]> o)
     {   
-        return FBUtilities.compareByteArrays(token, o.token, 0, 0, token.length, o.token.length);
+        return FBUtilities.compareUnsigned(token, o.token, 0, 0, token.length, o.token.length);
     }
     
 

Modified: cassandra/trunk/src/java/org/apache/cassandra/dht/LocalToken.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/dht/LocalToken.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/dht/LocalToken.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/dht/LocalToken.java Fri Oct 22 03:23:51 2010
@@ -19,10 +19,8 @@
 package org.apache.cassandra.dht;
 
 import java.nio.ByteBuffer;
-import java.util.Arrays;
 
 import org.apache.cassandra.db.marshal.AbstractType;
-import org.apache.cassandra.utils.ByteBufferUtil;
 
 public class LocalToken extends Token<ByteBuffer>
 {
@@ -61,7 +59,7 @@ public class LocalToken extends Token<By
         if (!(obj instanceof LocalToken))
             return false;
         LocalToken other = (LocalToken) obj;
-        return ByteBufferUtil.equals(token, other.token);
+        return token.equals(other.token);
     }
 
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/dht/Range.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/dht/Range.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/dht/Range.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/dht/Range.java Fri Oct 22 03:23:51 2010
@@ -250,7 +250,7 @@ public class Range extends AbstractBound
         }
        
             
-        return FBUtilities.compareByteArrays(l, r, lo, ro, ll, rl);
+        return FBUtilities.compareUnsigned(l, r, lo, ro, ll, rl);
     }
     
     public int compareTo(Range rhs)

Modified: cassandra/trunk/src/java/org/apache/cassandra/hadoop/ConfigHelper.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/hadoop/ConfigHelper.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/hadoop/ConfigHelper.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/hadoop/ConfigHelper.java Fri Oct 22 03:23:51 2010
@@ -166,7 +166,7 @@ public class ConfigHelper
         TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
         try
         {
-            return FBUtilities.bytesToHex(ByteBuffer.wrap(serializer.serialize(predicate)));
+            return FBUtilities.bytesToHex(serializer.serialize(predicate));
         }
         catch (TException e)
         {

Modified: cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java Fri Oct 22 03:23:51 2010
@@ -26,22 +26,17 @@ import java.nio.ByteBuffer;
  */
 public class ByteBufferUtil {
 
-    public static int compare(ByteBuffer o1, ByteBuffer o2)
+    public static int compareUnsigned(ByteBuffer o1, ByteBuffer o2)
     {
-        return FBUtilities.compareByteArrays(o1.array(), o2.array(), o1.arrayOffset()+o1.position(), o2.arrayOffset()+o2.position(), o1.limit(), o2.limit());
+        return FBUtilities.compareUnsigned(o1.array(), o2.array(), o1.arrayOffset()+o1.position(), o2.arrayOffset()+o2.position(), o1.limit(), o2.limit());
     }
     
     public static int compare(byte[] o1, ByteBuffer o2)
     {
-        return FBUtilities.compareByteArrays(o1, o2.array(), 0, o2.arrayOffset()+o2.position(), o1.length, o2.limit());
+        return FBUtilities.compareUnsigned(o1, o2.array(), 0, o2.arrayOffset()+o2.position(), o1.length, o2.limit());
     }
     public static int compare(ByteBuffer o1, byte[] o2)
     {
-        return FBUtilities.compareByteArrays(o1.array(), o2, o1.arrayOffset()+o1.position(), 0, o1.limit(), o2.length);
+        return FBUtilities.compareUnsigned(o1.array(), o2, o1.arrayOffset()+o1.position(), 0, o1.limit(), o2.length);
     }
-    
-    public static boolean equals(ByteBuffer o1, ByteBuffer o2)
-    {
-        return compare(o1, o2) == 0;
-    }   
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java Fri Oct 22 03:23:51 2010
@@ -158,7 +158,7 @@ public class FBUtilities
         return new Pair(midpoint, remainder);
     }
 
-    public static ByteBuffer toByteArray(int i)
+    public static ByteBuffer toByteBuffer(int i)
     {
         byte[] bytes = new byte[4];
         bytes[0] = (byte)( ( i >>> 24 ) & 0xFF);
@@ -168,14 +168,9 @@ public class FBUtilities
         return ByteBuffer.wrap(bytes);
     }
 
-    public static int byteArrayToInt(ByteBuffer bytes)
+    public static int byteBufferToInt(ByteBuffer bytes)
     {
-    	return byteArrayToInt(bytes, 0);
-    }
-
-    public static int byteArrayToInt(ByteBuffer bytes, int offset)
-    {
-        if ( bytes.remaining() - offset < 4 )
+        if (bytes.remaining() < 4 )
         {
             throw new IllegalArgumentException("An integer must be 4 bytes in size.");
         }
@@ -183,28 +178,29 @@ public class FBUtilities
         for ( int i = 0; i < 4; ++i )
         {
             n <<= 8;
-            n |= bytes.array()[bytes.position()+bytes.arrayOffset()+ offset + i] & 0xFF;
+            n |= bytes.array()[bytes.position() + bytes.arrayOffset() + i] & 0xFF;
         }
         return n;
     }
-    
-    public static int compareByteArrays(byte[] bytes1, byte[] bytes2, int offset1, int offset2,  int len1, int len2){
-        if(null == bytes1){
-            if(null == bytes2) return 0;
-            else return -1;
+
+    public static int compareUnsigned(byte[] bytes1, byte[] bytes2, int offset1, int offset2, int len1, int len2)
+    {
+        if (bytes1 == null)
+        {
+            return bytes2 == null ? 0 : -1;
         }
-        if(null == bytes2) return 1;
+        if (bytes2 == null) return 1;
 
-        int minLength = Math.min(len1-offset1, len2-offset2);
-        for(int x=0, i = offset1, j=offset2; x < minLength; x++,i++,j++)
+        int minLength = Math.min(len1 - offset1, len2 - offset2);
+        for (int x = 0, i = offset1, j = offset2; x < minLength; x++, i++, j++)
         {
-            if(bytes1[i] == bytes2[j])
+            if (bytes1[i] == bytes2[j])
                 continue;
             // compare non-equal bytes as unsigned
             return (bytes1[i] & 0xFF) < (bytes2[j] & 0xFF) ? -1 : 1;
         }
-        if((len1-offset1) == (len2-offset2)) return 0;
-        else return ((len1-offset1) < (len2-offset2))? -1 : 1;
+        if ((len1 - offset1) == (len2 - offset2)) return 0;
+        else return ((len1 - offset1) < (len2 - offset2)) ? -1 : 1;
     }
 
     /**
@@ -333,6 +329,20 @@ public class FBUtilities
         return bytes;
     }
 
+    public static String bytesToHex(byte... bytes)
+    {
+        StringBuilder sb = new StringBuilder();
+        for (byte b : bytes)
+        {
+            int bint = b & 0xff;
+            if (bint <= 0xF)
+                // toHexString does not 0 pad its results.
+                sb.append("0");
+            sb.append(Integer.toHexString(bint));
+        }
+        return sb.toString();
+    }
+
     public static String bytesToHex(ByteBuffer bytes)
     {
         StringBuilder sb = new StringBuilder();
@@ -491,7 +501,7 @@ public class FBUtilities
         return decoded;
     }
 
-    public static ByteBuffer toByteArray(long n)
+    public static ByteBuffer toByteBuffer(long n)
     {
         byte[] bytes = new byte[8];
         ByteBuffer bb = ByteBuffer.wrap(bytes).putLong(n);
@@ -665,18 +675,9 @@ public class FBUtilities
         }
     }
 
-    public static TreeSet<ByteBuffer> getSingleColumnSet(ByteBuffer column)
+    public static <T extends Comparable> SortedSet<T> singleton(T column)
     {
-        Comparator<ByteBuffer> singleColumnComparator = new Comparator<ByteBuffer>()
-        {
-            public int compare(ByteBuffer o1, ByteBuffer o2)
-            {
-                return ByteBufferUtil.equals(o1, o2) ? 0 : -1;
-            }
-        };
-        TreeSet<ByteBuffer> set = new TreeSet<ByteBuffer>(singleColumnComparator);
-        set.add(column);
-        return set;
+        return new TreeSet<T>(Arrays.asList(column));
     }
 
     public static String toString(Map<?,?> map)

Modified: cassandra/trunk/src/java/org/apache/cassandra/utils/MerkleTree.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/utils/MerkleTree.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/utils/MerkleTree.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/utils/MerkleTree.java Fri Oct 22 03:23:51 2010
@@ -787,7 +787,7 @@ public class MerkleTree implements Seria
         {
             if (hash == null)
                 return "null";
-            return "[" + FBUtilities.bytesToHex(ByteBuffer.wrap(hash)) + "]";
+            return "[" + FBUtilities.bytesToHex(hash) + "]";
         }
     }
 

Modified: cassandra/trunk/src/java/org/apache/cassandra/utils/MurmurHash.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/utils/MurmurHash.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/utils/MurmurHash.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/utils/MurmurHash.java Fri Oct 22 03:23:51 2010
@@ -36,15 +36,15 @@ public class MurmurHash {  
 
     int len_4 = length >> 2;
 
-    for (int i = 0; i < len_4; i++) {
+    for (int i = offset; i < offset + len_4; i++) {
       int i_4 = i << 2;
-      int k = data[offset + i_4 + 3];
+      int k = data[i_4 + 3];
       k = k << 8;
-      k = k | (data[offset + i_4 + 2] & 0xff);
+      k = k | (data[i_4 + 2] & 0xff);
       k = k << 8;
-      k = k | (data[offset + i_4 + 1] & 0xff);
+      k = k | (data[i_4 + 1] & 0xff);
       k = k << 8;
-      k = k | (data[offset + i_4 + 0] & 0xff);
+      k = k | (data[i_4 + 0] & 0xff);
       k *= m;
       k ^= k >>> r;
       k *= m;
@@ -58,13 +58,13 @@ public class MurmurHash {  
 
     if (left != 0) {
       if (left >= 3) {
-        h ^= (int) data[offset+length - 3] << 16;
+        h ^= (int) data[offset + length - 3] << 16;
       }
       if (left >= 2) {
-        h ^= (int) data[offset+length - 2] << 8;
+        h ^= (int) data[offset + length - 2] << 8;
       }
       if (left >= 1) {
-        h ^= (int) data[offset+length - 1];
+        h ^= (int) data[offset + length - 1];
       }
 
       h *= m;

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java Fri Oct 22 03:23:51 2010
@@ -27,7 +27,6 @@ import java.util.Random;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 import org.junit.Test;
 
@@ -133,27 +132,27 @@ public class ColumnFamilyStoreTest exten
         RowMutation rm;
 
         rm = new RowMutation("Keyspace1", ByteBuffer.wrap("k1".getBytes()));
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("notbirthdate".getBytes("UTF8"))), FBUtilities.toByteArray(1L), 0);
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteArray(1L), 0);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("notbirthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(1L), 0);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(1L), 0);
         rm.apply();
 
         rm = new RowMutation("Keyspace1", ByteBuffer.wrap("k2".getBytes()));
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("notbirthdate".getBytes("UTF8"))), FBUtilities.toByteArray(2L), 0);
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteArray(2L), 0);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("notbirthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(2L), 0);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(2L), 0);
         rm.apply();
 
         rm = new RowMutation("Keyspace1", ByteBuffer.wrap("k3".getBytes()));
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("notbirthdate".getBytes("UTF8"))), FBUtilities.toByteArray(2L), 0);
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteArray(1L), 0);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("notbirthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(2L), 0);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(1L), 0);
         rm.apply();
 
         rm = new RowMutation("Keyspace1", ByteBuffer.wrap("k4aaaa".getBytes()));
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("notbirthdate".getBytes("UTF8"))), FBUtilities.toByteArray(2L), 0);
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteArray(3L), 0);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("notbirthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(2L), 0);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(3L), 0);
         rm.apply();
 
         // basic single-expression query
-        IndexExpression expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteArray(1L));
+        IndexExpression expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteBuffer(1L));
         IndexClause clause = new IndexClause(Arrays.asList(expr),FBUtilities.EMPTY_BYTE_BUFFER, 100);
         IFilter filter = new IdentityQueryFilter();
         IPartitioner p = StorageService.getPartitioner();
@@ -164,11 +163,11 @@ public class ColumnFamilyStoreTest exten
         assert rows.size() == 2 : StringUtils.join(rows, ",");
         assert Arrays.equals("k1".getBytes(), rows.get(0).key.key.array());
         assert Arrays.equals("k3".getBytes(), rows.get(1).key.key.array());
-        assert FBUtilities.toByteArray(1L).equals( rows.get(0).cf.getColumn(ByteBuffer.wrap("birthdate".getBytes("UTF8"))).value());
-        assert FBUtilities.toByteArray(1L).equals( rows.get(1).cf.getColumn(ByteBuffer.wrap("birthdate".getBytes("UTF8"))).value());
+        assert FBUtilities.toByteBuffer(1L).equals( rows.get(0).cf.getColumn(ByteBuffer.wrap("birthdate".getBytes("UTF8"))).value());
+        assert FBUtilities.toByteBuffer(1L).equals( rows.get(1).cf.getColumn(ByteBuffer.wrap("birthdate".getBytes("UTF8"))).value());
 
         // add a second expression
-        IndexExpression expr2 = new IndexExpression(ByteBuffer.wrap("notbirthdate".getBytes("UTF8")), IndexOperator.GTE, FBUtilities.toByteArray(2L));
+        IndexExpression expr2 = new IndexExpression(ByteBuffer.wrap("notbirthdate".getBytes("UTF8")), IndexOperator.GTE, FBUtilities.toByteBuffer(2L));
         clause = new IndexClause(Arrays.asList(expr, expr2), FBUtilities.EMPTY_BYTE_BUFFER, 100);
         rows = Table.open("Keyspace1").getColumnFamilyStore("Indexed1").scan(clause, range, filter);
 
@@ -192,7 +191,7 @@ public class ColumnFamilyStoreTest exten
 
         // query with index hit but rejected by secondary clause, with a small enough count that just checking count
         // doesn't tell the scan loop that it's done
-        IndexExpression expr3 = new IndexExpression(ByteBuffer.wrap("notbirthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteArray(-1L));
+        IndexExpression expr3 = new IndexExpression(ByteBuffer.wrap("notbirthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteBuffer(-1L));
         clause = new IndexClause(Arrays.asList(expr, expr3), FBUtilities.EMPTY_BYTE_BUFFER, 1);
         rows = Table.open("Keyspace1").getColumnFamilyStore("Indexed1").scan(clause, range, filter);
 
@@ -206,10 +205,10 @@ public class ColumnFamilyStoreTest exten
         RowMutation rm;
 
         rm = new RowMutation("Keyspace3", ByteBuffer.wrap("k1".getBytes()));
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteArray(1L), 0);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(1L), 0);
         rm.apply();
 
-        IndexExpression expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteArray(1L));
+        IndexExpression expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteBuffer(1L));
         IndexClause clause = new IndexClause(Arrays.asList(expr), FBUtilities.EMPTY_BYTE_BUFFER, 100);
         IFilter filter = new IdentityQueryFilter();
         IPartitioner p = StorageService.getPartitioner();
@@ -234,7 +233,7 @@ public class ColumnFamilyStoreTest exten
 
         // resurrect w/ a newer timestamp
         rm = new RowMutation("Keyspace3", ByteBuffer.wrap("k1".getBytes()));
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteArray(1L), 2);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(1L), 2);
         rm.apply();
         rows = cfs.scan(clause, range, filter);
         assert rows.size() == 1 : StringUtils.join(rows, ",");
@@ -256,13 +255,13 @@ public class ColumnFamilyStoreTest exten
         // create a row and update the birthdate value, test that the index query fetches the new version
         RowMutation rm;
         rm = new RowMutation("Keyspace2", ByteBuffer.wrap("k1".getBytes()));
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteArray(1L), 1);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(1L), 1);
         rm.apply();
         rm = new RowMutation("Keyspace2", ByteBuffer.wrap("k1".getBytes()));
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteArray(2L), 2);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(2L), 2);
         rm.apply();
 
-        IndexExpression expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteArray(1L));
+        IndexExpression expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteBuffer(1L));
         IndexClause clause = new IndexClause(Arrays.asList(expr), FBUtilities.EMPTY_BYTE_BUFFER, 100);
         IFilter filter = new IdentityQueryFilter();
         IPartitioner p = StorageService.getPartitioner();
@@ -270,14 +269,14 @@ public class ColumnFamilyStoreTest exten
         List<Row> rows = table.getColumnFamilyStore("Indexed1").scan(clause, range, filter);
         assert rows.size() == 0;
 
-        expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteArray(2L));
+        expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteBuffer(2L));
         clause = new IndexClause(Arrays.asList(expr), FBUtilities.EMPTY_BYTE_BUFFER, 100);
         rows = table.getColumnFamilyStore("Indexed1").scan(clause, range, filter);
         assert Arrays.equals("k1".getBytes(), rows.get(0).key.key.array());
 
         // update the birthdate value with an OLDER timestamp, and test that the index ignores this
         rm = new RowMutation("Keyspace2", ByteBuffer.wrap("k1".getBytes()));
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteArray(3L), 0);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(3L), 0);
         rm.apply();
 
         rows = table.getColumnFamilyStore("Indexed1").scan(clause, range, filter);
@@ -292,7 +291,7 @@ public class ColumnFamilyStoreTest exten
         // create a row and update the birthdate value, test that the index query fetches the new version
         RowMutation rm;
         rm = new RowMutation("Keyspace1", ByteBuffer.wrap("k1".getBytes()));
-        rm.add(new QueryPath("Indexed2", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteArray(1L), 1);
+        rm.add(new QueryPath("Indexed2", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(1L), 1);
         rm.apply();
 
         ColumnFamilyStore cfs = table.getColumnFamilyStore("Indexed2");
@@ -302,7 +301,7 @@ public class ColumnFamilyStoreTest exten
         while (!SystemTable.isIndexBuilt("Keyspace1", cfs.getIndexedColumnFamilyStore(ByteBuffer.wrap("birthdate".getBytes("UTF8"))).columnFamily))
             TimeUnit.MILLISECONDS.sleep(100);
 
-        IndexExpression expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteArray(1L));
+        IndexExpression expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteBuffer(1L));
         IndexClause clause = new IndexClause(Arrays.asList(expr), FBUtilities.EMPTY_BYTE_BUFFER, 100);
         IFilter filter = new IdentityQueryFilter();
         IPartitioner p = StorageService.getPartitioner();

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java Fri Oct 22 03:23:51 2010
@@ -28,7 +28,6 @@ import java.util.concurrent.ExecutionExc
 import org.apache.cassandra.config.DatabaseDescriptor;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.ArrayUtils;
 import org.junit.Test;
 
 import static junit.framework.Assert.*;
@@ -237,7 +236,7 @@ public class TableTest extends CleanupHe
         {
             RowMutation rm = new RowMutation("Keyspace1", ROW.key);
             ColumnFamily cf = ColumnFamily.create("Keyspace1", "StandardLong1");
-            cf.addColumn(new Column(FBUtilities.toByteArray((long)i), FBUtilities.EMPTY_BYTE_BUFFER, 0));
+            cf.addColumn(new Column(FBUtilities.toByteBuffer((long)i), FBUtilities.EMPTY_BYTE_BUFFER, 0));
             rm.add(cf);
             rm.apply();
         }
@@ -248,7 +247,7 @@ public class TableTest extends CleanupHe
         {
             RowMutation rm = new RowMutation("Keyspace1", ROW.key);
             ColumnFamily cf = ColumnFamily.create("Keyspace1", "StandardLong1");
-            cf.addColumn(new Column(FBUtilities.toByteArray((long)i), FBUtilities.EMPTY_BYTE_BUFFER, 0));
+            cf.addColumn(new Column(FBUtilities.toByteBuffer((long)i), FBUtilities.EMPTY_BYTE_BUFFER, 0));
             rm.add(cf);
             rm.apply();
 

Modified: cassandra/trunk/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java Fri Oct 22 03:23:51 2010
@@ -23,7 +23,6 @@ package org.apache.cassandra.hadoop;
 
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 import org.apache.cassandra.thrift.SlicePredicate;
@@ -37,7 +36,7 @@ public class ColumnFamilyInputFormatTest
     public void testSlicePredicate()
     {
         long columnValue = 1271253600000l;
-        ByteBuffer columnBytes = FBUtilities.toByteArray(columnValue);
+        ByteBuffer columnBytes = FBUtilities.toByteBuffer(columnValue);
 
         List<ByteBuffer> columnNames = new ArrayList<ByteBuffer>();
         columnNames.add(columnBytes);

Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java Fri Oct 22 03:23:51 2010
@@ -55,12 +55,12 @@ public class SSTableWriterTest extends C
         RowMutation rm;
 
         rm = new RowMutation("Keyspace1", ByteBuffer.wrap("k1".getBytes()));
-        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteArray(1L), 0);
+        rm.add(new QueryPath("Indexed1", null, ByteBuffer.wrap("birthdate".getBytes("UTF8"))), FBUtilities.toByteBuffer(1L), 0);
         rm.apply();
         
         ColumnFamily cf = ColumnFamily.create("Keyspace1", "Indexed1");        
-        cf.addColumn(new Column(ByteBuffer.wrap("birthdate".getBytes()), FBUtilities.toByteArray(1L), 0));
-        cf.addColumn(new Column(ByteBuffer.wrap("anydate".getBytes()), FBUtilities.toByteArray(1L), 0));
+        cf.addColumn(new Column(ByteBuffer.wrap("birthdate".getBytes()), FBUtilities.toByteBuffer(1L), 0));
+        cf.addColumn(new Column(ByteBuffer.wrap("anydate".getBytes()), FBUtilities.toByteBuffer(1L), 0));
         
         Map<ByteBuffer, ByteBuffer> entries = new HashMap<ByteBuffer, ByteBuffer>();
         
@@ -69,7 +69,7 @@ public class SSTableWriterTest extends C
         entries.put(ByteBuffer.wrap("k2".getBytes()), ByteBuffer.wrap(Arrays.copyOf(buffer.getData(), buffer.getLength())));        
         cf.clear();
         
-        cf.addColumn(new Column(ByteBuffer.wrap("anydate".getBytes()), FBUtilities.toByteArray(1L), 0));
+        cf.addColumn(new Column(ByteBuffer.wrap("anydate".getBytes()), FBUtilities.toByteBuffer(1L), 0));
         buffer = new DataOutputBuffer();
         ColumnFamily.serializer().serializeWithIndexes(cf, buffer);               
         entries.put(ByteBuffer.wrap("k3".getBytes()), ByteBuffer.wrap(Arrays.copyOf(buffer.getData(), buffer.getLength())));
@@ -84,7 +84,7 @@ public class SSTableWriterTest extends C
         cfs.addSSTable(sstr);
         cfs.buildSecondaryIndexes(cfs.getSSTables(), cfs.getIndexedColumns());
         
-        IndexExpression expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteArray(1L));
+        IndexExpression expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteBuffer(1L));
         IndexClause clause = new IndexClause(Arrays.asList(expr), FBUtilities.EMPTY_BYTE_BUFFER, 100);
         IFilter filter = new IdentityQueryFilter();
         IPartitioner p = StorageService.getPartitioner();

Modified: cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java Fri Oct 22 03:23:51 2010
@@ -26,8 +26,6 @@ import java.net.InetAddress;
 import java.nio.ByteBuffer;
 import java.util.*;
 
-import org.apache.commons.lang.ArrayUtils;
-
 import org.apache.cassandra.CleanupHelper;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.db.*;
@@ -71,7 +69,7 @@ public class StreamingTransferTest exten
             RowMutation rm = new RowMutation("Keyspace1", ByteBuffer.wrap(key.getBytes()));
             ColumnFamily cf = ColumnFamily.create(table.name, cfs.columnFamily);
             cf.addColumn(column(key, "v", 0));
-            cf.addColumn(new Column(ByteBuffer.wrap("birthdate".getBytes("UTF8")), FBUtilities.toByteArray((long) i), 0));
+            cf.addColumn(new Column(ByteBuffer.wrap("birthdate".getBytes("UTF8")), FBUtilities.toByteBuffer((long) i), 0));
             rm.add(cf);
             rm.apply();
         }
@@ -103,7 +101,7 @@ public class StreamingTransferTest exten
         assert null != cfs.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("key3"), new QueryPath(cfs.columnFamily)));
 
         // and that the secondary index works
-        IndexExpression expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteArray(3L));
+        IndexExpression expr = new IndexExpression(ByteBuffer.wrap("birthdate".getBytes("UTF8")), IndexOperator.EQ, FBUtilities.toByteBuffer(3L));
         IndexClause clause = new IndexClause(Arrays.asList(expr), FBUtilities.EMPTY_BYTE_BUFFER, 100);
         IFilter filter = new IdentityQueryFilter();
         Range range = new Range(p.getMinimumToken(), p.getMinimumToken());

Modified: cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java Fri Oct 22 03:23:51 2010
@@ -52,7 +52,7 @@ public class SSTableExportTest extends S
 {
     public String asHex(String str)
     {
-        return bytesToHex(ByteBuffer.wrap(str.getBytes()));
+        return bytesToHex(str.getBytes());
     }
 
     @Test

Modified: cassandra/trunk/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java Fri Oct 22 03:23:51 2010
@@ -36,7 +36,7 @@ public class FBUtilitiesTest 
         for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++)
         {
             byte[] b = new byte[]{ (byte)i };
-            String s = FBUtilities.bytesToHex(ByteBuffer.wrap(b));
+            String s = FBUtilities.bytesToHex(b);
             byte[] c = FBUtilities.hexToBytes(s);
             assertArrayEquals(b, c);
         }
@@ -79,8 +79,8 @@ public class FBUtilitiesTest 
         };
 
         for (int i : ints) {
-            ByteBuffer ba = FBUtilities.toByteArray(i);
-            int actual = FBUtilities.byteArrayToInt(ba);
+            ByteBuffer ba = FBUtilities.toByteBuffer(i);
+            int actual = FBUtilities.byteBufferToInt(ba);
             assertEquals(i, actual);
         }
     }

Modified: cassandra/trunk/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java?rev=1026201&r1=1026200&r2=1026201&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java Fri Oct 22 03:23:51 2010
@@ -84,8 +84,8 @@ public class MerkleTreeTest
 
     public static void assertHashEquals(String message, final byte[] left, final byte[] right)
     {
-        String lstring = left == null ? "null" : FBUtilities.bytesToHex(ByteBuffer.wrap(left));
-        String rstring = right == null ? "null" : FBUtilities.bytesToHex(ByteBuffer.wrap(right));
+        String lstring = left == null ? "null" : FBUtilities.bytesToHex(left);
+        String rstring = right == null ? "null" : FBUtilities.bytesToHex(right);
         assertEquals(message, lstring, rstring);
     }
 



Mime
View raw message