You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2015/07/17 15:40:55 UTC
[5/6] cassandra git commit: Don't wrap byte arrays in SequentialWriter
Don't wrap byte arrays in SequentialWriter
patch by slebresne; reviewed by snazy & benedict for CASSANDRA-9797
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f60e4ad4
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f60e4ad4
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f60e4ad4
Branch: refs/heads/trunk
Commit: f60e4ad4298725dac57c36da8427d992be19eb8a
Parents: 22c97bc
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Fri Jul 17 15:39:32 2015 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Fri Jul 17 15:39:32 2015 +0200
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../cassandra/io/util/SequentialWriter.java | 22 ++++++++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f60e4ad4/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9a262dc..47d1db5 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.2.0-rc3
+ * Don't wrap byte arrays in SequentialWriter (CASSANDRA-9797)
* sum() and avg() functions missing for smallint and tinyint types (CASSANDRA-9671)
* Revert CASSANDRA-9542 (allow native functions in UDA) (CASSANDRA-9771)
Merged from 2.1:
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f60e4ad4/src/java/org/apache/cassandra/io/util/SequentialWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/util/SequentialWriter.java b/src/java/org/apache/cassandra/io/util/SequentialWriter.java
index f3268a2..915133f 100644
--- a/src/java/org/apache/cassandra/io/util/SequentialWriter.java
+++ b/src/java/org/apache/cassandra/io/util/SequentialWriter.java
@@ -185,12 +185,30 @@ public class SequentialWriter extends OutputStream implements WritableByteChanne
public void write(byte[] buffer) throws IOException
{
- write(ByteBuffer.wrap(buffer, 0, buffer.length));
+ write(buffer, 0, buffer.length);
}
public void write(byte[] data, int offset, int length) throws IOException
{
- write(ByteBuffer.wrap(data, offset, length));
+ if (buffer == null)
+ throw new ClosedChannelException();
+
+ int position = offset;
+ int remaining = length;
+ while (remaining > 0)
+ {
+ if (!buffer.hasRemaining())
+ reBuffer();
+
+ int toCopy = Math.min(remaining, buffer.remaining());
+ buffer.put(data, position, toCopy);
+
+ remaining -= toCopy;
+ position += toCopy;
+
+ isDirty = true;
+ syncNeeded = true;
+ }
}
public int write(ByteBuffer src) throws IOException