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 2016/06/23 09:07:27 UTC
[13/13] cassandra git commit: Merge branch 'cassandra-3.0' into trunk
Merge branch 'cassandra-3.0' into trunk
* cassandra-3.0:
Fix handling of clustering key > 64K
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c310adde
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c310adde
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c310adde
Branch: refs/heads/trunk
Commit: c310adde0ea1f53c46fec5529ecf18efe3af9429
Parents: 233c030 40ab631
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Thu Jun 23 11:06:53 2016 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Thu Jun 23 11:06:53 2016 +0200
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../cql3/statements/ModificationStatement.java | 10 ++++++
.../cassandra/net/OutboundTcpConnection.java | 3 +-
.../apache/cassandra/utils/ByteBufferUtil.java | 6 ++--
.../org/apache/cassandra/cql3/CQLTester.java | 2 ++
.../cql3/validation/operations/InsertTest.java | 37 +++++++++++++++-----
.../cql3/validation/operations/SelectTest.java | 21 +++++++++--
7 files changed, 66 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c310adde/CHANGES.txt
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c310adde/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c310adde/src/java/org/apache/cassandra/net/OutboundTcpConnection.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c310adde/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c310adde/test/unit/org/apache/cassandra/cql3/CQLTester.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c310adde/test/unit/org/apache/cassandra/cql3/validation/operations/InsertTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/validation/operations/InsertTest.java
index 5314d6a,a030613..9adcb62
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertTest.java
@@@ -22,8 -21,7 +22,9 @@@ import org.junit.Assert
import org.junit.Test;
import org.apache.cassandra.cql3.CQLTester;
+import org.apache.cassandra.cql3.UntypedResultSet;
+import org.apache.cassandra.cql3.UntypedResultSet.Row;
+ import org.apache.cassandra.exceptions.InvalidRequestException;
public class InsertTest extends CQLTester
{
@@@ -287,31 -285,27 +288,49 @@@
"INSERT INTO %s (partitionKey, clustering_2, staticValue) VALUES (0, 0, 'A')");
}
- private void flush(boolean forceFlush)
+ @Test
+ public void testInsertWithDefaultTtl() throws Throwable
{
- if (forceFlush)
- flush();
+ final int secondsPerMinute = 60;
+ createTable("CREATE TABLE %s (a int PRIMARY KEY, b int) WITH default_time_to_live = " + (10 * secondsPerMinute));
+
+ execute("INSERT INTO %s (a, b) VALUES (1, 1)");
+ UntypedResultSet resultSet = execute("SELECT ttl(b) FROM %s WHERE a = 1");
+ Assert.assertEquals(1, resultSet.size());
+ Row row = resultSet.one();
+ Assert.assertTrue(row.getInt("ttl(b)") >= (9 * secondsPerMinute));
+
+ execute("INSERT INTO %s (a, b) VALUES (2, 2) USING TTL ?", (5 * secondsPerMinute));
+ resultSet = execute("SELECT ttl(b) FROM %s WHERE a = 2");
+ Assert.assertEquals(1, resultSet.size());
+ row = resultSet.one();
+ Assert.assertTrue(row.getInt("ttl(b)") <= (5 * secondsPerMinute));
+
+ execute("INSERT INTO %s (a, b) VALUES (3, 3) USING TTL ?", 0);
+ assertRows(execute("SELECT ttl(b) FROM %s WHERE a = 3"), row(new Object[]{null}));
+
+ execute("INSERT INTO %s (a, b) VALUES (4, 4) USING TTL ?", unset());
+ resultSet = execute("SELECT ttl(b) FROM %s WHERE a = 4");
+ Assert.assertEquals(1, resultSet.size());
+ row = resultSet.one();
+ Assert.assertTrue(row.getInt("ttl(b)") >= (9 * secondsPerMinute));
}
+
+ @Test
+ public void testPKInsertWithValueOver64K() throws Throwable
+ {
+ createTable("CREATE TABLE %s (a text, b text, PRIMARY KEY (a, b))");
+
+ assertInvalidThrow(InvalidRequestException.class,
+ "INSERT INTO %s (a, b) VALUES (?, 'foo')", new String(TOO_BIG.array()));
+ }
+
+ @Test
+ public void testCKInsertWithValueOver64K() throws Throwable
+ {
+ createTable("CREATE TABLE %s (a text, b text, PRIMARY KEY (a, b))");
+
+ assertInvalidThrow(InvalidRequestException.class,
+ "INSERT INTO %s (a, b) VALUES ('foo', ?)", new String(TOO_BIG.array()));
+ }
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c310adde/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
index 7c0ca7c,65bfb32..dde87d8
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
@@@ -23,10 -23,11 +23,11 @@@ import java.util.UUID
import org.junit.Test;
import junit.framework.Assert;
+import org.apache.cassandra.cql3.CQLTester;
import org.apache.cassandra.cql3.UntypedResultSet;
import org.apache.cassandra.cql3.restrictions.StatementRestrictions;
+ import org.apache.cassandra.exceptions.InvalidRequestException;
import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.cql3.CQLTester;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;