cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [6/6] cassandra git commit: Merge branch 'cassandra-3.11' into trunk
Date Fri, 22 Sep 2017 14:44:28 GMT
Merge branch 'cassandra-3.11' into trunk


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

Branch: refs/heads/trunk
Commit: 756fab87c97a7a03fcf6495af166d5193fa4e6ae
Parents: f1b7d6e 0e5c84a
Author: Paulo Motta <paulo@apache.org>
Authored: Fri Sep 22 09:43:38 2017 -0500
Committer: Paulo Motta <paulo@apache.org>
Committed: Fri Sep 22 09:44:02 2017 -0500

----------------------------------------------------------------------
 .../cassandra/triggers/TriggerExecutor.java     |  7 +++++-
 .../cassandra/triggers/TriggerExecutorTest.java | 26 +++++++++++++++-----
 .../apache/cassandra/triggers/TriggersTest.java | 24 +++++++++++-------
 3 files changed, 41 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/756fab87/src/java/org/apache/cassandra/triggers/TriggerExecutor.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/triggers/TriggerExecutor.java
index 906b342,0354fde..754183f
--- a/src/java/org/apache/cassandra/triggers/TriggerExecutor.java
+++ b/src/java/org/apache/cassandra/triggers/TriggerExecutor.java
@@@ -87,7 -86,12 +87,12 @@@ public class TriggerExecuto
          if (intermediate == null || intermediate.isEmpty())
              return updates;
  
-         return PartitionUpdate.merge(validateForSinglePartition(updates.metadata().id, updates.partitionKey(),
intermediate));
 -        List<PartitionUpdate> augmented = validateForSinglePartition(updates.metadata().cfId,
++        List<PartitionUpdate> augmented = validateForSinglePartition(updates.metadata().id,
+                                                                      updates.partitionKey(),
+                                                                      intermediate);
+         // concatenate augmented and origin
+         augmented.add(updates);
+         return PartitionUpdate.merge(augmented);
      }
  
      /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/756fab87/test/unit/org/apache/cassandra/triggers/TriggerExecutorTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/triggers/TriggerExecutorTest.java
index a796daf,0e4130d..aa5ee9b
--- a/test/unit/org/apache/cassandra/triggers/TriggerExecutorTest.java
+++ b/test/unit/org/apache/cassandra/triggers/TriggerExecutorTest.java
@@@ -33,7 -33,6 +33,8 @@@ import org.apache.cassandra.db.partitio
  import org.apache.cassandra.exceptions.ConfigurationException;
  import org.apache.cassandra.exceptions.InvalidRequestException;
  import org.apache.cassandra.schema.TriggerMetadata;
 +import org.apache.cassandra.schema.Triggers;
++import org.apache.cassandra.triggers.TriggerExecutorTest.SameKeySameCfTrigger;
  import org.apache.cassandra.utils.FBUtilities;
  
  import static org.apache.cassandra.utils.ByteBufferUtil.bytes;
@@@ -52,17 -51,30 +53,30 @@@ public class TriggerExecutorTes
      @Test
      public void sameKeySameCfColumnFamilies() throws ConfigurationException, InvalidRequestException
      {
 -        CFMetaData metadata = makeCfMetaData("ks1", "cf1", TriggerMetadata.create("test",
SameKeySameCfTrigger.class.getName()));
 +        TableMetadata metadata = makeTableMetadata("ks1", "cf1", TriggerMetadata.create("test",
SameKeySameCfTrigger.class.getName()));
+         // origin column 'c1' = "v1", augment extra column 'c2' = "trigger"
          PartitionUpdate mutated = TriggerExecutor.instance.execute(makeCf(metadata, "k1",
"v1", null));
  
-         try (RowIterator rowIterator = UnfilteredRowIterators.filter(mutated.unfilteredIterator(),
-                                                                      FBUtilities.nowInSeconds()))
+         List<Row> rows = new ArrayList<>();
+         try (RowIterator iterator = UnfilteredRowIterators.filter(mutated.unfilteredIterator(),
+                                                                   FBUtilities.nowInSeconds()))
          {
-             Iterator<Cell> cells = rowIterator.next().cells().iterator();
-             assertEquals(bytes("trigger"), cells.next().value());
- 
-             assertTrue(!rowIterator.hasNext());
+             iterator.forEachRemaining(rows::add);
          }
+ 
+         // only 1 row
+         assertEquals(1, rows.size());
+ 
+         List<Cell> cells = new ArrayList<>();
+         rows.get(0).cells().forEach(cells::add);
+ 
+         // 2 columns
+         assertEquals(2, cells.size());
+ 
+         // check column 'c1'
+         assertEquals(bytes("v1"), cells.get(0).value());
+         // check column 'c2'
+         assertEquals(bytes("trigger"), cells.get(1).value());
      }
  
      @Test(expected = InvalidRequestException.class)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/756fab87/test/unit/org/apache/cassandra/triggers/TriggersTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/triggers/TriggersTest.java
index 52cebc9,165a7fe..2cf0e84
--- a/test/unit/org/apache/cassandra/triggers/TriggersTest.java
+++ b/test/unit/org/apache/cassandra/triggers/TriggersTest.java
@@@ -117,9 -174,27 +117,9 @@@ public class TriggersTes
                                     "APPLY BATCH",
                                      ksName, cfName);
          QueryProcessor.process(cql, ConsistencyLevel.ONE);
-         assertUpdateIsAugmented(5);
+         assertUpdateIsAugmented(5, "v1", 5);
      }
  
 -    @Test
 -    public void executeTriggerOnThriftCASOperation() throws Exception
 -    {
 -        Cassandra.Client client = new Cassandra.Client(
 -                new TBinaryProtocol(
 -                        new TFramedTransportFactory().openTransport(
 -                                InetAddress.getLocalHost().getHostName(), 9170)));
 -        client.set_keyspace(ksName);
 -        client.cas(bytes(6),
 -                   cfName,
 -                   Collections.<Column>emptyList(),
 -                   Collections.singletonList(getColumnForInsert("v1", 6)),
 -                   org.apache.cassandra.thrift.ConsistencyLevel.LOCAL_SERIAL,
 -                   org.apache.cassandra.thrift.ConsistencyLevel.ONE);
 -
 -        assertUpdateIsAugmented(6, "v1", 6);
 -    }
 -
      @Test(expected=org.apache.cassandra.exceptions.InvalidRequestException.class)
      public void onCqlUpdateWithConditionsRejectGeneratedUpdatesForDifferentPartition() throws
Exception
      {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message