cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1059355 - in /cassandra/trunk/src/java/org/apache/cassandra: db/ColumnSerializer.java db/CounterColumn.java utils/FBUtilities.java
Date Sat, 15 Jan 2011 15:19:31 GMT
Author: jbellis
Date: Sat Jan 15 15:19:30 2011
New Revision: 1059355

URL: http://svn.apache.org/viewvc?rev=1059355&view=rev
Log:
fix use of direct buffers from CASSANDRA-1714
patch by Pavel Yaskevich; reviewed by jbellis for CASSANDRA-1989

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnSerializer.java
    cassandra/trunk/src/java/org/apache/cassandra/db/CounterColumn.java
    cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnSerializer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnSerializer.java?rev=1059355&r1=1059354&r2=1059355&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnSerializer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnSerializer.java Sat Jan 15 15:19:30
2011
@@ -84,7 +84,7 @@ public class ColumnSerializer implements
         {
             long timestampOfLastDelete = dis.readLong();
             ByteBuffer pc = FBUtilities.readShortByteArray(dis);
-            byte[] partitionedCounter = Arrays.copyOfRange(pc.array(), pc.position() + pc.arrayOffset(),
pc.limit());
+            byte[] partitionedCounter = ByteBufferUtil.getArray(pc);
             long timestamp = dis.readLong();
             ByteBuffer value = FBUtilities.readByteArray(dis);
             return new CounterColumn(name, value, timestamp, partitionedCounter, timestampOfLastDelete);

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/CounterColumn.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/CounterColumn.java?rev=1059355&r1=1059354&r2=1059355&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/CounterColumn.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/CounterColumn.java Sat Jan 15 15:19:30
2011
@@ -110,8 +110,8 @@ public class CounterColumn extends Colum
     @Override
     public void updateDigest(MessageDigest digest)
     {
-        digest.update(name.array(),name.position()+name.arrayOffset(),name.remaining());
-        digest.update(value.array(),value.position()+name.arrayOffset(),value.remaining());
+        digest.update(name.duplicate());
+        digest.update(value.duplicate());
         digest.update(FBUtilities.toByteArray(timestamp));
         digest.update(partitionedCounter);
         digest.update(FBUtilities.toByteArray(timestampOfLastDelete));

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=1059355&r1=1059354&r2=1059355&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java Sat Jan 15 15:19:30
2011
@@ -198,6 +198,9 @@ public class FBUtilities
     /**
      * Convert a byte buffer to an integer.
      * Does not change the byte buffer position.
+     *
+     * @param bytes byte buffer to convert to integer
+     * @return int representation of the byte buffer
      */
     public static int byteBufferToInt(ByteBuffer bytes)
     {
@@ -209,7 +212,7 @@ public class FBUtilities
         for (int i = 0; i < 4; ++i)
         {
             n <<= 8;
-            n |= bytes.array()[bytes.position() + bytes.arrayOffset() + i] & 0xFF;
+            n |= bytes.get(bytes.position() + i) & 0xFF;
         }
         return n;
     }



Mime
View raw message