cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [6/7] git commit: Pig CounterColumnFamily support. Patch by Janne Jalkanen and brandonwilliams, reviewed by brandonwilliams for CASSANDRA-3973
Date Tue, 28 Feb 2012 15:51:08 GMT
Pig CounterColumnFamily support.
Patch by Janne Jalkanen and brandonwilliams, reviewed by brandonwilliams
for CASSANDRA-3973


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

Branch: refs/heads/trunk
Commit: 4a49b9dcc05d6f06c3354fb37a4a0199a2c283d5
Parents: 1ed6065
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Tue Feb 28 09:47:26 2012 -0600
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Tue Feb 28 09:47:26 2012 -0600

----------------------------------------------------------------------
 .../cassandra/hadoop/pig/CassandraStorage.java     |   19 ++++++--------
 contrib/pig/test/populate-cli.txt                  |   18 +++++++++----
 contrib/pig/test/test_storage.pig                  |   10 ++++++++
 3 files changed, 30 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a49b9dc/contrib/pig/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java
----------------------------------------------------------------------
diff --git a/contrib/pig/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java b/contrib/pig/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java
index a2213f7..6d1f76a 100644
--- a/contrib/pig/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java
+++ b/contrib/pig/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java
@@ -209,17 +209,11 @@ public class CassandraStorage extends LoadFunc implements StoreFuncInterface,
Lo
         AbstractType subcomparator;
         AbstractType default_validator;
         AbstractType key_validator;
-        try
-        {
-            comparator = TypeParser.parse(cfDef.getComparator_type());
-            subcomparator = TypeParser.parse(cfDef.getSubcomparator_type());
-            default_validator = TypeParser.parse(cfDef.getDefault_validation_class());
-            key_validator = TypeParser.parse(cfDef.getKey_validation_class());
-        }
-        catch (ConfigurationException e)
-        {
-            throw new IOException(e);
-        }
+
+        comparator = parseType(cfDef.getComparator_type());
+        subcomparator = parseType(cfDef.getSubcomparator_type());
+        default_validator = parseType(cfDef.getDefault_validation_class());
+        key_validator = parseType(cfDef.getKey_validation_class());
 
         marshallers.add(comparator);
         marshallers.add(default_validator);
@@ -254,6 +248,9 @@ public class CassandraStorage extends LoadFunc implements StoreFuncInterface,
Lo
     {
         try
         {
+            // always treat counters like longs, specifically CCT.compose is not what we
need
+            if (type != null && type.equals("org.apache.cassandra.db.marshal.CounterColumnType"))
+                    return LongType.instance;
             return TypeParser.parse(type);
         }
         catch (ConfigurationException e)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a49b9dc/contrib/pig/test/populate-cli.txt
----------------------------------------------------------------------
diff --git a/contrib/pig/test/populate-cli.txt b/contrib/pig/test/populate-cli.txt
index f266ce9..0164afe 100644
--- a/contrib/pig/test/populate-cli.txt
+++ b/contrib/pig/test/populate-cli.txt
@@ -1,8 +1,6 @@
-create keyspace PigTest;
+create keyspace PigTest with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy'
and strategy_options={replication_factor:1};
 use PigTest;
 create column family SomeApp with
-placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' and
-strategy_options = {replication_factor:1} and
 key_validation_class = UTF8Type and
 default_validation_class = LexicalUUIDType and
 comparator = UTF8Type and
@@ -17,8 +15,6 @@ column_metadata =
 ];
 
 create column family CopyOfSomeApp with
-placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' and
-strategy_options = {replication_factor:1} and
 key_validation_class = UTF8Type and
 default_validation_class = LexicalUUIDType and
 comparator = UTF8Type and
@@ -79,4 +75,14 @@ create column family Bytes with
     comparator = UTF8Type;
 
 set U8['foo']['x'] = ascii('Z');
-set Bytes[ascii('foo')]['x'] = ascii('Z')
+set Bytes[ascii('foo')]['x'] = ascii('Z');
+
+create column family CC with
+    key_validation_class = UTF8Type and
+    default_validation_class=CounterColumnType
+    and comparator=UTF8Type;
+
+incr CC['chuck']['kick'];
+incr CC['chuck']['kick'];
+incr CC['chuck']['kick'];
+incr CC['chuck']['fist'];

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a49b9dc/contrib/pig/test/test_storage.pig
----------------------------------------------------------------------
diff --git a/contrib/pig/test/test_storage.pig b/contrib/pig/test/test_storage.pig
index 7422db4..c49d4b3 100644
--- a/contrib/pig/test/test_storage.pig
+++ b/contrib/pig/test/test_storage.pig
@@ -37,3 +37,13 @@ dump a
 -- key should now be cast into a chararray
 c = join b by (chararray)key, U8 by (chararray)key;
 dump c
+
+
+--
+--  Test counter column family support
+--
+CC = load 'cassandra://PigTest/CC' using CassandraStorage();
+
+total_hits = foreach CC generate key, SUM(columns.value);
+
+dump total_hits;


Mime
View raw message