You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2014/05/13 16:48:20 UTC

git commit: Fix the InvertedIndex trigger example

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 256109c34 -> 820f0eb60


Fix the InvertedIndex trigger example

patch by Anthony Cozzie; reviewed by Aleksey Yeschenko for CASSANDRA-7211


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

Branch: refs/heads/cassandra-2.0
Commit: 820f0eb60b89e043761a8c882ff8a016c3ea2212
Parents: 256109c
Author: Anthony Cozzie <ac...@datastax.com>
Authored: Mon May 12 09:49:37 2014 -0600
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Tue May 13 17:46:21 2014 +0300

----------------------------------------------------------------------
 CHANGES.txt                                          |  1 +
 .../org/apache/cassandra/triggers/InvertedIndex.java | 15 +++++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/820f0eb6/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 32bd539..58cebbd 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,6 +9,7 @@
  * cqlsh can't tab-complete disabling compaction (CASSANDRA-7185)
  * cqlsh: Accept and execute CQL statement(s) from command-line parameter (CASSANDRA-7172)
  * Fix IllegalStateException in CqlPagingRecordReader (CASSANDRA-7198)
+ * Fix the InvertedIndex trigger example (CASSANDRA-7211)
 
 
 2.0.8

http://git-wip-us.apache.org/repos/asf/cassandra/blob/820f0eb6/examples/triggers/src/org/apache/cassandra/triggers/InvertedIndex.java
----------------------------------------------------------------------
diff --git a/examples/triggers/src/org/apache/cassandra/triggers/InvertedIndex.java b/examples/triggers/src/org/apache/cassandra/triggers/InvertedIndex.java
index a2d7644..ae58b33 100644
--- a/examples/triggers/src/org/apache/cassandra/triggers/InvertedIndex.java
+++ b/examples/triggers/src/org/apache/cassandra/triggers/InvertedIndex.java
@@ -40,12 +40,18 @@ public class InvertedIndex implements ITrigger
     public Collection<RowMutation> augment(ByteBuffer key, ColumnFamily update)
     {
         List<RowMutation> mutations = new ArrayList<>();
+
         for (Column cell : update)
         {
-            RowMutation mutation = new RowMutation(properties.getProperty("keyspace"), cell.value());
-            mutation.add(properties.getProperty("columnfamily"), cell.name(), key, System.currentTimeMillis());
-            mutations.add(mutation);
+            // Skip the row marker and other empty values, since they lead to an empty key.
+            if (cell.value().remaining() > 0)
+            {
+                RowMutation mutation = new RowMutation(properties.getProperty("keyspace"), cell.value());
+                mutation.add(properties.getProperty("columnfamily"), cell.name(), key, System.currentTimeMillis());
+                mutations.add(mutation);
+            }
         }
+
         return mutations;
     }
 
@@ -53,7 +59,8 @@ public class InvertedIndex implements ITrigger
     {
         Properties properties = new Properties();
         InputStream stream = InvertedIndex.class.getClassLoader().getResourceAsStream("InvertedIndex.properties");
-        try {
+        try
+        {
             properties.load(stream);
         }
         catch (Exception e)