You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by el...@apache.org on 2012/08/13 18:39:58 UTC
svn commit: r1372499 -
/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
Author: elecharny
Date: Mon Aug 13 16:39:58 2012
New Revision: 1372499
URL: http://svn.apache.org/viewvc?rev=1372499&view=rev
Log:
Fixed a bug in the flush method : we were incorrectly writing data in teh buffer when this buffer gets full
Modified:
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
Modified: labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
URL: http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java?rev=1372499&r1=1372498&r2=1372499&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java (original)
+++ labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java Mon Aug 13 16:39:58 2012
@@ -729,6 +729,7 @@ public class BTree<K, V>
private void writeBuffer( FileChannel channel, ByteBuffer bb, byte[] buffer ) throws IOException
{
int size = buffer.length;
+ int pos = 0;
// Loop until we have written all the data
do
@@ -736,15 +737,16 @@ public class BTree<K, V>
if ( bb.remaining() >= size )
{
// No flush, as the ByteBuffer is big enough
- bb.put( buffer );
+ bb.put( buffer, pos, size );
size = 0;
}
else
{
// Flush the data on disk, reinitialize the ByteBuffer
- int len = bb.limit() - bb.position();
+ int len = bb.remaining();
size -= len;
- bb.put( buffer, bb.position(), len );
+ bb.put( buffer, pos, len );
+ pos += len;
bb.flip();
channel.write( bb );
@@ -783,11 +785,17 @@ public class BTree<K, V>
{
Tuple<K, V> tuple = cursor.next();
+ if ( bb.remaining() == 0 )
+ {
+
+ }
+
byte[] keyBuffer = serializer.serializeKey( tuple.getKey() );
writeBuffer( ch, bb, keyBuffer );
byte[] valueBuffer = serializer.serializeValue( tuple.getValue() );
+
writeBuffer( ch, bb, valueBuffer );
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org