cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1153744 - in /cassandra/trunk/src/java/org/apache/cassandra: db/EchoedRow.java db/compaction/AbstractCompactedRow.java db/compaction/LazilyCompactedRow.java db/compaction/PrecompactedRow.java io/sstable/SSTableWriter.java
Date Thu, 04 Aug 2011 03:59:22 GMT
Author: jbellis
Date: Thu Aug  4 03:59:19 2011
New Revision: 1153744

URL: http://svn.apache.org/viewvc?rev=1153744&view=rev
Log:
add sanity check of row data size
patch by jbellis

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/db/EchoedRow.java
    cassandra/trunk/src/java/org/apache/cassandra/db/compaction/AbstractCompactedRow.java
    cassandra/trunk/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java
    cassandra/trunk/src/java/org/apache/cassandra/db/compaction/PrecompactedRow.java
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/EchoedRow.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/EchoedRow.java?rev=1153744&r1=1153743&r2=1153744&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/EchoedRow.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/EchoedRow.java Thu Aug  4 03:59:19 2011
@@ -47,11 +47,12 @@ public class EchoedRow extends AbstractC
         row.reset();
     }
 
-    public void write(DataOutput out) throws IOException
+    public long write(DataOutput out) throws IOException
     {
         assert row.dataSize > 0;
         out.writeLong(row.dataSize);
         row.echoData(out);
+        return row.dataSize;
     }
 
     public void update(MessageDigest digest)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/compaction/AbstractCompactedRow.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/compaction/AbstractCompactedRow.java?rev=1153744&r1=1153743&r2=1153744&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/compaction/AbstractCompactedRow.java
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/compaction/AbstractCompactedRow.java
Thu Aug  4 03:59:19 2011
@@ -44,7 +44,7 @@ public abstract class AbstractCompactedR
     /**
      * write the row (size + column index + filter + column data, but NOT row key) to @param
out
      */
-    public abstract void write(DataOutput out) throws IOException;
+    public abstract long write(DataOutput out) throws IOException;
 
     /**
      * update @param digest with the data bytes of the row (not including row key or row
size)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java?rev=1153744&r1=1153743&r2=1153744&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java Thu
Aug  4 03:59:19 2011
@@ -89,7 +89,7 @@ public class LazilyCompactedRow extends 
         reducer = null;
     }
 
-    public void write(DataOutput out) throws IOException
+    public long write(DataOutput out) throws IOException
     {
         DataOutputBuffer clockOut = new DataOutputBuffer();
         ColumnFamily.serializer().serializeCFInfo(emptyColumnFamily, clockOut);
@@ -107,6 +107,8 @@ public class LazilyCompactedRow extends 
             IColumn column = iter.next();
             emptyColumnFamily.getColumnSerializer().serialize(column, out);
         }
+
+        return dataSize;
     }
 
     public void update(MessageDigest digest)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/compaction/PrecompactedRow.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/compaction/PrecompactedRow.java?rev=1153744&r1=1153743&r2=1153744&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/compaction/PrecompactedRow.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/compaction/PrecompactedRow.java Thu Aug
 4 03:59:19 2011
@@ -90,7 +90,7 @@ public class PrecompactedRow extends Abs
         }
     }
 
-    public void write(DataOutput out) throws IOException
+    public long write(DataOutput out) throws IOException
     {
         if (compactedCf != null)
         {
@@ -98,10 +98,13 @@ public class PrecompactedRow extends Abs
             DataOutputBuffer headerBuffer = new DataOutputBuffer();
             ColumnIndexer.serialize(compactedCf, headerBuffer);
             ColumnFamily.serializer().serializeForSSTable(compactedCf, buffer);
-            out.writeLong(headerBuffer.getLength() + buffer.getLength());
+            int dataSize = headerBuffer.getLength() + buffer.getLength();
+            out.writeLong(dataSize);
             out.write(headerBuffer.getData(), 0, headerBuffer.getLength());
             out.write(buffer.getData(), 0, buffer.getLength());
+            return dataSize;
         }
+        return 0;
     }
 
     public void update(MessageDigest digest)

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java?rev=1153744&r1=1153743&r2=1153744&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java Thu Aug  4
03:59:19 2011
@@ -146,7 +146,9 @@ public class SSTableWriter extends SSTab
     {
         long currentPosition = beforeAppend(row.key);
         ByteBufferUtil.writeWithShortLength(row.key.key, dataFile.stream);
-        row.write(dataFile.stream);
+        long dataStart = dataFile.getFilePointer();
+        long dataSize = row.write(dataFile.stream);
+        assert dataSize == dataFile.getFilePointer() - (dataStart + 8): "incorrect row size
written to " + dataFile.getPath();
         // max timestamp is not collected here, because we want to avoid deserializing an
EchoedRow
         // instead, it is collected when calling ColumnFamilyStore.createCompactionWriter
         sstableMetadataCollector.addRowSize(dataFile.getFilePointer() - currentPosition);



Mime
View raw message