cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ble...@apache.org
Subject [4/4] cassandra git commit: Merge branch cassandra-2.2 into cassandra-3.0
Date Wed, 09 Sep 2015 20:21:59 GMT
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/cc0038b7
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/cc0038b7
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/cc0038b7

Branch: refs/heads/cassandra-3.0
Commit: cc0038b7d196d8cd072931bbf28ad276f7987abf
Parents: e097efc ec4b4d4
Author: blerer <benjamin.lerer@datastax.com>
Authored: Wed Sep 9 22:13:48 2015 +0200
Committer: blerer <benjamin.lerer@datastax.com>
Committed: Wed Sep 9 22:20:58 2015 +0200

----------------------------------------------------------------------
 .../validation/entities/CollectionsTest.java     | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/cc0038b7/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
index 088b9cf,6266fe7..df8d507
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
@@@ -590,81 -585,26 +590,100 @@@ public class CollectionsTest extends CQ
          assertInvalid("alter table %s add v set<int>");
      }
  
 -    /**
 -     * Test for 9838.
 -     */
 +    @Test
 +    public void testDropAndReaddDroppedCollection() throws Throwable
 +    {
 +        createTable("create table %s (k int primary key, v frozen<set<text>>,
x int)");
 +        execute("insert into %s (k, v) VALUES (0, {'fffffffff'})");
 +        flush();
 +        execute("alter table %s drop v");
 +        execute("alter table %s add v set<int>");
 +    }
 +
 +    @Test
 +    public void testMapWithLargePartition() throws Throwable
 +    {
 +        Random r = new Random();
 +        long seed = System.nanoTime();
 +        System.out.println("Seed " + seed);
 +        r.setSeed(seed);
 +
 +        int len = (1024 * 1024)/100;
 +        createTable("CREATE TABLE %s (userid text PRIMARY KEY, properties map<int, text>)
with compression = {}");
 +
 +        final int numKeys = 200;
 +        for (int i = 0; i < numKeys; i++)
 +        {
 +            byte[] b = new byte[len];
 +            r.nextBytes(b);
 +            execute("UPDATE %s SET properties[?] = ? WHERE userid = 'user'", i, new String(b));
 +        }
 +
 +        flush();
 +
 +        Object[][] rows = getRows(execute("SELECT properties from %s where userid = 'user'"));
 +        assertEquals(1, rows.length);
 +        assertEquals(numKeys, ((Map) rows[0][0]).size());
 +    }
 +
 +    @Test
 +    public void testMapWithTwoSStables() throws Throwable
 +    {
 +        createTable("CREATE TABLE %s (userid text PRIMARY KEY, properties map<int, text>)
with compression = {}");
 +
 +        final int numKeys = 100;
 +        for (int i = 0; i < numKeys; i++)
 +            execute("UPDATE %s SET properties[?] = ? WHERE userid = 'user'", i, "prop_"
+ Integer.toString(i));
 +
 +        flush();
 +
 +        for (int i = numKeys; i < 2*numKeys; i++)
 +            execute("UPDATE %s SET properties[?] = ? WHERE userid = 'user'", i, "prop_"
+ Integer.toString(i));
 +
 +        flush();
 +
 +        Object[][] rows = getRows(execute("SELECT properties from %s where userid = 'user'"));
 +        assertEquals(1, rows.length);
 +        assertEquals(numKeys * 2, ((Map) rows[0][0]).size());
 +    }
 +
 +    @Test
 +    public void testSetWithTwoSStables() throws Throwable
 +    {
 +        createTable("CREATE TABLE %s (userid text PRIMARY KEY, properties set<text>)
with compression = {}");
 +
 +        final int numKeys = 100;
 +        for (int i = 0; i < numKeys; i++)
 +            execute("UPDATE %s SET properties = properties + ? WHERE userid = 'user'", set("prop_"
+ Integer.toString(i)));
 +
 +        flush();
 +
 +        for (int i = numKeys; i < 2*numKeys; i++)
 +            execute("UPDATE %s SET properties = properties + ? WHERE userid = 'user'", set("prop_"
+ Integer.toString(i)));
 +
 +        flush();
 +
 +        Object[][] rows = getRows(execute("SELECT properties from %s where userid = 'user'"));
 +        assertEquals(1, rows.length);
 +        assertEquals(numKeys * 2, ((Set) rows[0][0]).size());
 +    }
++
+     @Test
+     public void testUpdateStaticList() throws Throwable
+     {
+         createTable("CREATE TABLE %s (k1 text, k2 text, s_list list<int> static, PRIMARY
KEY (k1, k2))");
+ 
+         execute("insert into %s (k1, k2) VALUES ('a','b')");
+         execute("update %s set s_list = s_list + [0] where k1='a'");
+         assertRows(execute("select s_list from %s where k1='a'"), row(list(0)));
+ 
+         execute("update %s set s_list[0] = 100 where k1='a'");
+         assertRows(execute("select s_list from %s where k1='a'"), row(list(100)));
+ 
+         execute("update %s set s_list = s_list + [0] where k1='a'");
+         assertRows(execute("select s_list from %s where k1='a'"), row(list(100, 0)));
+ 
+         execute("delete s_list[0] from %s where k1='a'");
+         assertRows(execute("select s_list from %s where k1='a'"), row(list(0)));
+     }
 -
  }


Mime
View raw message