Merge branch 'cassandra-2.2' into cassandra-3.0

Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e3baf28b
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e3baf28b
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e3baf28b

Branch: refs/heads/trunk
Commit: e3baf28b61d41e34e9b75d4b7adb186fb5f5d38b
Parents: 88b05ef 27bc7a5
Author: Robert Stupp <sn...@snazy.de>
Authored: Thu Aug 27 00:56:48 2015 +0200
Committer: Robert Stupp <sn...@snazy.de>
Committed: Thu Aug 27 00:56:48 2015 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../io/util/UnbufferedDataOutputStreamPlus.java |  9 +++-
 .../io/util/BufferedDataOutputStreamTest.java   | 45 +++++++++++++++++++-
 3 files changed, 53 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e3baf28b/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index c7eb9fe,ea11489..2ab4263
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,45 -1,7 +1,46 @@@
 -2.2.1
 +3.0.0-beta2
 + * Ensures frozen sets and maps are always sorted (CASSANDRA-10162)
 + * Don't deadlock when flushing CFS backed custom indexes (CASSANDRA-10181)
 + * Fix double flushing of secondary index tables (CASSANDRA-10180)
 + * Fix incorrect handling of range tombstones in thrift (CASSANDRA-10046)
 + * Only use batchlog when paired materialized view replica is remote 
(CASSANDRA-10061)
 + * Reuse TemporalRow when updating multiple MaterializedViews 
(CASSANDRA-10060)
 + * Validate gc_grace_seconds for batchlog writes and MVs (CASSANDRA-9917)
 + * Fix sstablerepairedset (CASSANDRA-10132)
 +Merged from 2.2:
+  * Fix broken UnbufferedDataOutputStreamPlus.writeUTF (CASSANDRA-10203)
 + * (cqlsh) default load-from-file encoding to utf-8 (CASSANDRA-9898)
 + * Avoid returning Permission.NONE when failing to query users table 
(CASSANDRA-10168)
   * (cqlsh) add CLEAR command (CASSANDRA-10086)
   * Support string literals as Role names for compatibility (CASSANDRA-10135)
 +Merged from 2.1:
 + * Change streaming_socket_timeout_in_ms default to 1 hour (CASSANDRA-8611)
 + * (cqlsh) update list of CQL keywords (CASSANDRA-9232)
 +
 +
 +3.0.0-beta1
 + * Redesign secondary index API (CASSANDRA-9459, 7771, 9041)
 + * Fix throwing ReadFailure instead of ReadTimeout on range queries 
(CASSANDRA-10125)
 + * Rewrite hinted handoff (CASSANDRA-6230)
 + * Fix query on static compact tables (CASSANDRA-10093)
 + * Fix race during construction of commit log (CASSANDRA-10049)
 + * Add option to only purge repaired tombstones (CASSANDRA-6434)
 + * Change authorization handling for MVs (CASSANDRA-9927)
 + * Add custom JMX enabled executor for UDF sandbox (CASSANDRA-10026)
 + * Fix row deletion bug for Materialized Views (CASSANDRA-10014)
 + * Support mixed-version clusters with Cassandra 2.1 and 2.2 (CASSANDRA-9704)
 + * Fix multiple slices on RowSearchers (CASSANDRA-10002)
 + * Fix bug in merging of collections (CASSANDRA-10001)
 + * Optimize batchlog replay to avoid full scans (CASSANDRA-7237)
 + * Repair improvements when using vnodes (CASSANDRA-5220)
 + * Disable scripted UDFs by default (CASSANDRA-9889)
 + * Bytecode inspection for Java-UDFs (CASSANDRA-9890)
 + * Use byte to serialize MT hash length (CASSANDRA-9792)
 + * Replace usage of Adler32 with CRC32 (CASSANDRA-8684)
 + * Fix migration to new format from 2.1 SSTable (CASSANDRA-10006)
 + * SequentialWriter should extend BufferedDataOutputStreamPlus 
(CASSANDRA-9500)
 + * Use the same repairedAt timestamp within incremental repair session 
(CASSANDRA-9111)
 +Merged from 2.2:
   * Allow count(*) and count(1) to be use as normal aggregation 
(CASSANDRA-10114)
   * An NPE is thrown if the column name is unknown for an IN relation 
(CASSANDRA-10043)
   * Apply commit_failure_policy to more errors on startup (CASSANDRA-9749)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e3baf28b/src/java/org/apache/cassandra/io/util/UnbufferedDataOutputStreamPlus.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e3baf28b/test/unit/org/apache/cassandra/io/util/BufferedDataOutputStreamTest.java
----------------------------------------------------------------------
diff --cc 
test/unit/org/apache/cassandra/io/util/BufferedDataOutputStreamTest.java
index 469bccb,ffe9cb9..b875a6a
--- a/test/unit/org/apache/cassandra/io/util/BufferedDataOutputStreamTest.java
+++ b/test/unit/org/apache/cassandra/io/util/BufferedDataOutputStreamTest.java
@@@ -466,133 -448,42 +471,171 @@@ public class BufferedDataOutputStreamTe
          return count;
      }
  
+     @Test
+     public void testWriteUTF() throws Exception
+     {
+         ByteArrayOutputStream baos = new ByteArrayOutputStream();
+         DataOutput dataOut = new DataOutputStream(baos);
+ 
+         StringBuilder sb = new StringBuilder(65535);
+         for (int ii = 0; ii < 1 << 16; ii++)
+         {
+             String s = sb.toString();
+             UnbufferedDataOutputStreamPlus.writeUTF(s, dataOut);
+             DataInput dataIn = new DataInputStream(new 
ByteArrayInputStream(baos.toByteArray()));
+             assertEquals(s, dataIn.readUTF());
+             baos.reset();
+             sb.append("a");
+         }
+     }
+ 
+     @Test
+     public void testWriteUTFBigChar() throws Exception
+     {
+         ByteArrayOutputStream baos = new ByteArrayOutputStream();
+         DataOutput dataOut = new DataOutputStream(baos);
+ 
+         StringBuilder sb = new StringBuilder(65535);
+         for (int ii = 0; ii < 1 << 15; ii++)
+         {
+             String s = sb.toString();
+             UnbufferedDataOutputStreamPlus.writeUTF(s, dataOut);
+             DataInput dataIn = new DataInputStream(new 
ByteArrayInputStream(baos.toByteArray()));
+             assertEquals(s, dataIn.readUTF());
+             baos.reset();
+             if (ii == (1 << 15) - 1)
+                 sb.append("a");
+             else
+                 sb.append(twoByte);
+         }
+     }
++
 +    /*
 +     * Add values to the array with a bit set in every position
 +     */
 +    public static long[] enrich(long vals[])
 +    {
 +        long retval[] = Arrays.copyOf(vals, vals.length + 64);
 +        for (int ii = 0; ii < 64; ii++)
 +            retval[vals.length + ii] = 1L << ii;
 +        return retval;
 +   }
 +
 +    @Test
 +    public void testVInt() throws Exception
 +    {
 +        setUp();
 +        long testValues[] = new long[] {
 +                0, 1, -1
 +                ,Long.MIN_VALUE, Long.MIN_VALUE + 1, Long.MAX_VALUE, 
Long.MAX_VALUE - 1
 +                ,Integer.MIN_VALUE, Integer.MIN_VALUE + 1, Integer.MAX_VALUE, 
Integer.MAX_VALUE - 1
 +                ,Short.MIN_VALUE, Short.MIN_VALUE + 1, Short.MAX_VALUE, 
Short.MAX_VALUE - 1
 +                ,Byte.MIN_VALUE, Byte.MIN_VALUE + 1, Byte.MAX_VALUE, 
Byte.MAX_VALUE - 1 };
 +        testValues = enrich(testValues);
 +
 +        int expectedSize = 0;
 +        for (long v : testValues)
 +        {
 +            expectedSize += VIntCoding.computeVIntSize(v);
 +            ndosp.writeVInt(v);
 +        }
 +
 +        ndosp.flush();
 +
 +        @SuppressWarnings("resource")
 +        ByteBufferDataInput bbdi = new 
ByteBufferDataInput(ByteBuffer.wrap(generated.toByteArray()), "", 0, 0);
 +
 +        assertEquals(expectedSize, generated.toByteArray().length);
 +
 +        for (long v : testValues)
 +        {
 +            assertEquals(v, bbdi.readVInt());
 +        }
 +    }
 +
 +    @Test
 +    public void testUnsignedVInt() throws Exception
 +    {
 +        setUp();
 +        long testValues[] = new long[] { //-1 };
 +                0, 1
 +                , UnsignedLong.MAX_VALUE.longValue(), 
UnsignedLong.MAX_VALUE.longValue() - 1, UnsignedLong.MAX_VALUE.longValue() + 1
 +                , UnsignedInteger.MAX_VALUE.longValue(), 
UnsignedInteger.MAX_VALUE.longValue() - 1, 
UnsignedInteger.MAX_VALUE.longValue() + 1
 +                , UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE - 1, 
UnsignedBytes.MAX_VALUE + 1
 +                , 65536, 65536 - 1, 65536 + 1 };
 +        testValues = enrich(testValues);
 +
 +        int expectedSize = 0;
 +        for (long v : testValues)
 +        {
 +            expectedSize += VIntCoding.computeUnsignedVIntSize(v);
 +            ndosp.writeUnsignedVInt(v);
 +        }
 +
 +        ndosp.flush();
 +
 +        @SuppressWarnings("resource")
 +        ByteBufferDataInput bbdi = new 
ByteBufferDataInput(ByteBuffer.wrap(generated.toByteArray()), "", 0, 0);
 +
 +        assertEquals(expectedSize, generated.toByteArray().length);
 +
 +        for (long v : testValues)
 +            assertEquals(v, bbdi.readUnsignedVInt());
 +    }
 +
 +    @Test
 +    public void testWriteSlowByteOrder() throws Exception
 +    {
 +        try (DataOutputBuffer dob = new DataOutputBuffer(4))
 +        {
 +            dob.order(ByteOrder.LITTLE_ENDIAN);
 +            dob.writeLong(42);
 +            assertEquals(42, 
ByteBuffer.wrap(dob.toByteArray()).order(ByteOrder.LITTLE_ENDIAN).getLong());
 +        }
 +    }
 +
 +    @Test
 +    public void testWriteExcessSlow() throws Exception
 +    {
 +        try (DataOutputBuffer dob = new DataOutputBuffer(4))
 +        {
 +            dob.strictFlushing = true;
 +            ByteBuffer buf = ByteBuffer.allocateDirect(8);
 +            buf.putLong(0, 42);
 +            dob.write(buf);
 +            assertEquals(42, ByteBuffer.wrap(dob.toByteArray()).getLong());
 +        }
 +    }
 +
 +    @Test
 +    public void testApplyToChannel() throws Exception
 +    {
 +        setUp();
 +        Object obj = new Object();
 +        Object retval = ndosp.applyToChannel( channel -> {
 +            ByteBuffer buf = ByteBuffer.allocate(8);
 +            buf.putLong(0, 42);
 +            try
 +            {
 +                channel.write(buf);
 +            }
 +            catch (Exception e)
 +            {
 +                throw new RuntimeException(e);
 +            }
 +            return obj;
 +        });
 +        assertEquals(obj, retval);
 +        assertEquals(42, ByteBuffer.wrap(generated.toByteArray()).getLong());
 +    }
 +
 +    @Test(expected = UnsupportedOperationException.class)
 +    public void testApplyToChannelThrowsForMisaligned() throws Exception
 +    {
 +        setUp();
 +        ndosp.strictFlushing = true;
 +        ndosp.applyToChannel( channel -> {
 +            return null;
 +        });
 +    }
- 
  }

Reply via email to