cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [1/3] git commit: Fix the InvertedIndex trigger example
Date Tue, 13 May 2014 14:52:57 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk d24513e04 -> 4b0287957


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/trunk
Commit: 820f0eb60b89e043761a8c882ff8a016c3ea2212
Parents: 256109c
Author: Anthony Cozzie <acozzie@datastax.com>
Authored: Mon May 12 09:49:37 2014 -0600
Committer: Aleksey Yeschenko <aleksey@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)


Mime
View raw message