cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject git commit: CQL3: support pre-epoch longs for TimestampType
Date Mon, 21 Oct 2013 07:17:09 GMT
Updated Branches:
  refs/heads/cassandra-2.0 1187c7aa0 -> 28caff5a4


CQL3: support pre-epoch longs for TimestampType

patch by Mikhail Stepura; reviewed by Aleksey Yeschenko for
CASSANDRA-6212


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

Branch: refs/heads/cassandra-2.0
Commit: 28caff5a44c3128394984fe8c968f62a5c3db0ff
Parents: 1187c7a
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Mon Oct 21 15:14:16 2013 +0800
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Mon Oct 21 15:14:16 2013 +0800

----------------------------------------------------------------------
 src/java/org/apache/cassandra/db/marshal/TimestampType.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/28caff5a/src/java/org/apache/cassandra/db/marshal/TimestampType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/TimestampType.java b/src/java/org/apache/cassandra/db/marshal/TimestampType.java
index 69ef07d..cf1ea41 100644
--- a/src/java/org/apache/cassandra/db/marshal/TimestampType.java
+++ b/src/java/org/apache/cassandra/db/marshal/TimestampType.java
@@ -20,10 +20,10 @@ package org.apache.cassandra.db.marshal;
 import java.nio.ByteBuffer;
 import java.text.ParseException;
 import java.util.Date;
+import java.util.regex.Pattern;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import org.apache.cassandra.cql3.CQL3Type;
 import org.apache.cassandra.serializers.TypeSerializer;
 import org.apache.cassandra.serializers.MarshalException;
@@ -44,6 +44,8 @@ public class TimestampType extends AbstractType<Date>
 
     public static final TimestampType instance = new TimestampType();
 
+    private static final Pattern timestampPattern = Pattern.compile("^-?\\d+$");
+
     private TimestampType() {} // singleton
 
     public int compare(ByteBuffer o1, ByteBuffer o2)
@@ -69,7 +71,7 @@ public class TimestampType extends AbstractType<Date>
           millis = System.currentTimeMillis();
       }
       // Milliseconds since epoch?
-      else if (source.matches("^\\d+$"))
+      else if (timestampPattern.matcher(source).matches())
       {
           try
           {


Mime
View raw message