cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [5/7] git commit: Pig: support for DateType. Patch by brandonwilliams, reviewed by Rick Branson for CASSANDRA-4204
Date Tue, 01 May 2012 17:06:57 GMT
Pig: support for DateType.
Patch by brandonwilliams, reviewed by Rick Branson for CASSANDRA-4204


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

Branch: refs/heads/trunk
Commit: 6ba063387f3088e4e21aab20509c6d9237809ce9
Parents: a725f80
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Tue May 1 12:03:36 2012 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Tue May 1 12:03:36 2012 -0500

----------------------------------------------------------------------
 .../cassandra/hadoop/pig/CassandraStorage.java     |    4 +++-
 contrib/pig/test/populate-cli.txt                  |    6 ++++++
 2 files changed, 9 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba06338/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 9c2dded..329155c 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
@@ -217,6 +217,8 @@ public class CassandraStorage extends LoadFunc implements StoreFuncInterface,
Lo
            pair.set(position, new DataByteArray(ByteBufferUtil.getArray((ByteBuffer) value)));
        else if (value instanceof UUID)
            pair.set(position, new DataByteArray(UUIDGen.decompose((java.util.UUID) value)));
+       else if (value instanceof Date)
+           pair.set(position, new DataByteArray(ByteBufferUtil.getArray(DateType.instance.decompose((Date)
value))));
        else
            pair.set(position, value);
     }
@@ -463,7 +465,7 @@ public class CassandraStorage extends LoadFunc implements StoreFuncInterface,
Lo
 
     private byte getPigType(AbstractType type)
     {
-        if (type instanceof LongType)
+        if (type instanceof LongType || type instanceof DateType) // DateType is bad and
it should feel bad
             return DataType.LONG;
         else if (type instanceof IntegerType)
             return DataType.INTEGER;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba06338/contrib/pig/test/populate-cli.txt
----------------------------------------------------------------------
diff --git a/contrib/pig/test/populate-cli.txt b/contrib/pig/test/populate-cli.txt
index c8124dd..7ec6cd6 100644
--- a/contrib/pig/test/populate-cli.txt
+++ b/contrib/pig/test/populate-cli.txt
@@ -12,6 +12,7 @@ column_metadata =
     {column_name: score, validation_class: LongType},
     {column_name: percent, validation_class: FloatType},
     {column_name: atomic_weight, validation_class: DoubleType},
+    {column_name: created, validation_class: DateType},
 ];
 
 create column family CopyOfSomeApp with
@@ -26,6 +27,7 @@ column_metadata =
     {column_name: score, validation_class: LongType},
     {column_name: percent, validation_class: FloatType},
     {column_name: atomic_weight, validation_class: DoubleType},
+    {column_name: created, validation_class: DateType},
 ];
 
 set SomeApp['foo']['name'] = 'User Foo';
@@ -34,6 +36,7 @@ set SomeApp['foo']['rating'] = 8;
 set SomeApp['foo']['score'] = 125000;
 set SomeApp['foo']['percent'] = '85.0';
 set SomeApp['foo']['atomic_weight'] = '2.7182818284590451';
+set SomeApp['foo']['created'] = 1335890877;
 
 set SomeApp['bar']['name'] = 'User Bar';
 set SomeApp['bar']['vote_type'] = 'like';
@@ -41,6 +44,7 @@ set SomeApp['bar']['rating'] = 9;
 set SomeApp['bar']['score'] = 15000;
 set SomeApp['bar']['percent'] = '35.0';
 set SomeApp['bar']['atomic_weight'] = '3.1415926535897931';
+set SomeApp['bar']['created'] = 1335890877;
 
 set SomeApp['baz']['name'] = 'User Baz';
 set SomeApp['baz']['vote_type'] = 'dislike';
@@ -48,6 +52,7 @@ set SomeApp['baz']['rating'] = 3;
 set SomeApp['baz']['score'] = 512000;
 set SomeApp['baz']['percent'] = '95.3';
 set SomeApp['baz']['atomic_weight'] = '1.61803399';
+set SomeApp['baz']['created'] = 1335890877;
 set SomeApp['baz']['extra1'] = lexicaluuid();
 set SomeApp['baz']['extra2'] = lexicaluuid();
 set SomeApp['baz']['extra3'] = lexicaluuid();
@@ -58,6 +63,7 @@ set SomeApp['qux']['rating'] = 2;
 set SomeApp['qux']['score'] = 12000;
 set SomeApp['qux']['percent'] = '64.7';
 set SomeApp['qux']['atomic_weight'] = '0.660161815846869';
+set SomeApp['qux']['created'] = 1335890877;
 set SomeApp['qux']['extra1'] = lexicaluuid();
 set SomeApp['qux']['extra2'] = lexicaluuid();
 set SomeApp['qux']['extra3'] = lexicaluuid();


Mime
View raw message