cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1165672 - in /cassandra/trunk: drivers/java/src/org/apache/cassandra/cql/jdbc/ drivers/java/test/org/apache/cassandra/cql/ src/java/org/apache/cassandra/cql/jdbc/ src/java/org/apache/cassandra/db/marshal/ test/unit/org/apache/cassandra/db/...
Date Tue, 06 Sep 2011 13:56:49 GMT
Author: jbellis
Date: Tue Sep  6 13:56:48 2011
New Revision: 1165672

URL: http://svn.apache.org/viewvc?rev=1165672&view=rev
Log:
fix build after rename snafu

Added:
    cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/AbstractJdbcUUID.java
      - copied, changed from r1165666, cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLong.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcAscii.java
      - copied, changed from r1165666, cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/AsciiTerm.java
Modified:
    cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/jdbc/ColumnDecoder.java
    cassandra/trunk/drivers/java/test/org/apache/cassandra/cql/JdbcDriverTest.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/AsciiTerm.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcCounterColumn.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLexicalUUID.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLong.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcTimeUUID.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcUUID.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/TypesMap.java
    cassandra/trunk/src/java/org/apache/cassandra/db/marshal/AsciiType.java
    cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/marshal/RoundTripTest.java

Modified: cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/jdbc/ColumnDecoder.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/jdbc/ColumnDecoder.java?rev=1165672&r1=1165671&r2=1165672&view=diff
==============================================================================
--- cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/jdbc/ColumnDecoder.java (original)
+++ cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/jdbc/ColumnDecoder.java Tue
Sep  6 13:56:48 2011
@@ -86,7 +86,7 @@ class ColumnDecoder
         try
         {
             if (ByteBufferUtil.string(name).equalsIgnoreCase(ByteBufferUtil.string(cf.keyAlias)))
-                return AsciiTerm.instance;
+                return JdbcAscii.instance;
         }
         catch (CharacterCodingException e)
         {

Modified: cassandra/trunk/drivers/java/test/org/apache/cassandra/cql/JdbcDriverTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/java/test/org/apache/cassandra/cql/JdbcDriverTest.java?rev=1165672&r1=1165671&r2=1165672&view=diff
==============================================================================
--- cassandra/trunk/drivers/java/test/org/apache/cassandra/cql/JdbcDriverTest.java (original)
+++ cassandra/trunk/drivers/java/test/org/apache/cassandra/cql/JdbcDriverTest.java Tue Sep
 6 13:56:48 2011
@@ -31,10 +31,10 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.apache.cassandra.cql.jdbc.CassandraResultSet;
-import org.apache.cassandra.cql.jdbc.AsciiTerm;
+import org.apache.cassandra.cql.jdbc.JdbcAscii;
 import org.apache.cassandra.cql.jdbc.JdbcBytes;
 import org.apache.cassandra.cql.jdbc.JdbcInteger;
-import org.apache.cassandra.cql.jdbc.LongTerm;
+import org.apache.cassandra.cql.jdbc.JdbcLong;
 import org.apache.cassandra.cql.jdbc.JdbcUTF8;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -177,11 +177,11 @@ public class JdbcDriverTest extends Embe
         
         ResultSetMetaData md = rs.getMetaData();
         assert md.getColumnCount() == 2;
-        expectedMetaData(md, 1, Long.class.getName(), "JdbcLong", "Keyspace1", "1", Types.INTEGER,
LongTerm.class.getSimpleName(), true, false);
-        expectedMetaData(md, 2, Long.class.getName(), "JdbcLong", "Keyspace1", "2", Types.INTEGER,
LongTerm.class.getSimpleName(), true, false);
+        expectedMetaData(md, 1, Long.class.getName(), "JdbcLong", "Keyspace1", "1", Types.INTEGER,
JdbcLong.class.getSimpleName(), true, false);
+        expectedMetaData(md, 2, Long.class.getName(), "JdbcLong", "Keyspace1", "2", Types.INTEGER,
JdbcLong.class.getSimpleName(), true, false);
         
         for (int i = 0; i < md.getColumnCount(); i++)
-            expectedMetaData(md, i + 1, Long.class.getName(), Types.INTEGER, LongTerm.class.getSimpleName(),
true, false);
+            expectedMetaData(md, i + 1, Long.class.getName(), Types.INTEGER, JdbcLong.class.getSimpleName(),
true, false);
     }
 
     @Test
@@ -203,8 +203,8 @@ public class JdbcDriverTest extends Embe
         
         ResultSetMetaData md = rs0.getMetaData();
         assert md.getColumnCount() == 2;
-        expectedMetaData(md, 1, String.class.getName(), "JdbcAscii", "Keyspace1", "a", Types.VARCHAR,
AsciiTerm.class.getSimpleName(), false, true);
-        expectedMetaData(md, 2, String.class.getName(), "JdbcAscii", "Keyspace1", "b", Types.VARCHAR,
AsciiTerm.class.getSimpleName(), false, true);
+        expectedMetaData(md, 1, String.class.getName(), "JdbcAscii", "Keyspace1", "a", Types.VARCHAR,
JdbcAscii.class.getSimpleName(), false, true);
+        expectedMetaData(md, 2, String.class.getName(), "JdbcAscii", "Keyspace1", "b", Types.VARCHAR,
JdbcAscii.class.getSimpleName(), false, true);
         md = rs1.getMetaData();
         assert md.getColumnCount() == 2;
         expectedMetaData(md, 1, String.class.getName(), "JdbcUtf8", "Keyspace1", "a", Types.VARCHAR,
JdbcUTF8.class.getSimpleName(), false, true);
@@ -216,7 +216,7 @@ public class JdbcDriverTest extends Embe
                              i + 1,
                              String.class.getName(),
                              Types.VARCHAR,
-                             AsciiTerm.class.getSimpleName(),
+                             JdbcAscii.class.getSimpleName(),
                              false,
                              true);
             expectedMetaData(rs1.getMetaData(),

Copied: cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/AbstractJdbcUUID.java (from
r1165666, cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLong.java)
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/AbstractJdbcUUID.java?p2=cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/AbstractJdbcUUID.java&p1=cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLong.java&r1=1165666&r2=1165672&rev=1165672&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLong.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/AbstractJdbcUUID.java Tue Sep 
6 13:56:48 2011
@@ -24,7 +24,7 @@ package org.apache.cassandra.cql.jdbc;
 import java.sql.Types;
 import java.util.UUID;
 
-public abstract class JdbcLong extends AbstractJdbcType<UUID>
+public abstract class AbstractJdbcUUID extends AbstractJdbcType<UUID>
 {
     public String toString(UUID obj)
     {

Copied: cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcAscii.java (from r1165666,
cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/AsciiTerm.java)
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcAscii.java?p2=cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcAscii.java&p1=cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/AsciiTerm.java&r1=1165666&r2=1165672&rev=1165672&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/AsciiTerm.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcAscii.java Tue Sep  6 13:56:48
2011
@@ -25,15 +25,15 @@ import java.nio.ByteBuffer;
 import java.nio.charset.CharacterCodingException;
 import java.sql.Types;
 
-import org.apache.cassandra.utils.ByteBufferUtil;
-
 import com.google.common.base.Charsets;
 
-public class AsciiTerm extends AbstractJdbcType<String>
+import org.apache.cassandra.utils.ByteBufferUtil;
+
+public class JdbcAscii extends AbstractJdbcType<String>
 {
-    public static final AsciiTerm instance = new AsciiTerm();
+    public static final JdbcAscii instance = new JdbcAscii();
     
-    AsciiTerm() {}
+    JdbcAscii() {}
     
     public boolean isCaseSensitive()
     {

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcCounterColumn.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcCounterColumn.java?rev=1165672&r1=1165671&r2=1165672&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcCounterColumn.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcCounterColumn.java Tue Sep
 6 13:56:48 2011
@@ -1,6 +1,6 @@
 package org.apache.cassandra.cql.jdbc;
 
-public class JdbcCounterColumn extends LongTerm
+public class JdbcCounterColumn extends JdbcLong
 {
     public static final JdbcCounterColumn instance = new JdbcCounterColumn();
     

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLexicalUUID.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLexicalUUID.java?rev=1165672&r1=1165671&r2=1165672&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLexicalUUID.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLexicalUUID.java Tue Sep  6
13:56:48 2011
@@ -26,7 +26,7 @@ import java.util.UUID;
 
 import org.apache.cassandra.utils.UUIDGen;
 
-public class JdbcLexicalUUID extends JdbcLong
+public class JdbcLexicalUUID extends AbstractJdbcUUID
 {
     public static final JdbcLexicalUUID instance = new JdbcLexicalUUID();
     

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLong.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLong.java?rev=1165672&r1=1165671&r2=1165672&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLong.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcLong.java Tue Sep  6 13:56:48
2011
@@ -21,29 +21,32 @@ package org.apache.cassandra.cql.jdbc;
  */
 
 
+import java.nio.ByteBuffer;
 import java.sql.Types;
-import java.util.UUID;
 
-public abstract class JdbcLong extends AbstractJdbcType<UUID>
+import org.apache.cassandra.utils.ByteBufferUtil;
+
+public class JdbcLong extends AbstractJdbcType<Long>
 {
-    public String toString(UUID obj)
+    public static final JdbcLong instance = new JdbcLong();
+
+    JdbcLong()
     {
-        return obj.toString();
     }
-    
+
     public boolean isCaseSensitive()
     {
         return false;
     }
 
-    public int getScale(UUID obj)
+    public int getScale(Long obj)
     {
-        return -1;
+        return 0;
     }
 
-    public int getPrecision(UUID obj)
+    public int getPrecision(Long obj)
     {
-        return -1;
+        return obj.toString().length();
     }
 
     public boolean isCurrency()
@@ -53,7 +56,12 @@ public abstract class JdbcLong extends A
 
     public boolean isSigned()
     {
-        return false;
+        return true;
+    }
+
+    public String toString(Long obj)
+    {
+        return obj.toString();
     }
 
     public boolean needsQuotes()
@@ -61,13 +69,32 @@ public abstract class JdbcLong extends A
         return false;
     }
 
-    public Class<UUID> getType()
+    public String getString(ByteBuffer bytes)
+    {
+        if (bytes.remaining() == 0)
+        {
+            return "";
+        }
+        if (bytes.remaining() != 8)
+        {
+            throw new MarshalException("A long is exactly 8 bytes: " + bytes.remaining());
+        }
+
+        return String.valueOf(bytes.getLong(bytes.position()));
+    }
+
+    public Class<Long> getType()
     {
-        return UUID.class;
+        return Long.class;
     }
 
     public int getJdbcType()
     {
-        return Types.OTHER;
+        return Types.INTEGER;
+    }
+
+    public Long compose(ByteBuffer bytes)
+    {
+        return ByteBufferUtil.toLong(bytes);
     }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcTimeUUID.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcTimeUUID.java?rev=1165672&r1=1165671&r2=1165672&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcTimeUUID.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcTimeUUID.java Tue Sep  6 13:56:48
2011
@@ -26,7 +26,7 @@ import java.util.UUID;
 
 import org.apache.cassandra.utils.UUIDGen;
 
-public class JdbcTimeUUID extends JdbcLong
+public class JdbcTimeUUID extends AbstractJdbcUUID
 {
     public static final JdbcTimeUUID instance = new JdbcTimeUUID();
     

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcUUID.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcUUID.java?rev=1165672&r1=1165671&r2=1165672&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcUUID.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/JdbcUUID.java Tue Sep  6 13:56:48
2011
@@ -24,7 +24,7 @@ package org.apache.cassandra.cql.jdbc;
 import java.nio.ByteBuffer;
 import java.util.UUID;
 
-public class JdbcUUID extends JdbcLong
+public class JdbcUUID extends AbstractJdbcUUID
 {
     public static final JdbcUUID instance = new JdbcUUID();
     

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/TypesMap.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/TypesMap.java?rev=1165672&r1=1165671&r2=1165672&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/TypesMap.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/jdbc/TypesMap.java Tue Sep  6 13:56:48
2011
@@ -9,7 +9,7 @@ public class TypesMap
     
     static
     {
-        map.put("org.apache.cassandra.db.marshal.AsciiType", AsciiTerm.instance);
+        map.put("org.apache.cassandra.db.marshal.AsciiType", JdbcAscii.instance);
         map.put("org.apache.cassandra.db.marshal.BooleanType", JdbcBoolean.instance);
         map.put("org.apache.cassandra.db.marshal.BytesType", JdbcBytes.instance);
         map.put("org.apache.cassandra.db.marshal.ColumnCounterType", JdbcCounterColumn.instance);
@@ -18,7 +18,7 @@ public class TypesMap
         map.put("org.apache.cassandra.db.marshal.FloatType", JdbcFloat.instance);
         map.put("org.apache.cassandra.db.marshal.IntegerType", JdbcInteger.instance);
         map.put("org.apache.cassandra.db.marshal.LexicalUUIDType", JdbcLexicalUUID.instance);
-        map.put("org.apache.cassandra.db.marshal.LongType", LongTerm.instance);
+        map.put("org.apache.cassandra.db.marshal.LongType", JdbcLong.instance);
         map.put("org.apache.cassandra.db.marshal.TimeUUIDType", JdbcTimeUUID.instance);
         map.put("org.apache.cassandra.db.marshal.UTF8Type", JdbcUTF8.instance);
         map.put("org.apache.cassandra.db.marshal.UUIDType", JdbcUUID.instance);
@@ -28,7 +28,7 @@ public class TypesMap
     {
         // If not fully qualified, assume it's the short name for a built-in.
         if ((comparator != null) && (!comparator.contains(".")))
-            return map.get("org.apache.cassandra.db." + comparator);
+            return map.get("org.apache.cassandra.db.marshal." + comparator);
         return map.get(comparator);
     }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/marshal/AsciiType.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/marshal/AsciiType.java?rev=1165672&r1=1165671&r2=1165672&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/marshal/AsciiType.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/marshal/AsciiType.java Tue Sep  6 13:56:48
2011
@@ -25,7 +25,7 @@ import java.nio.ByteBuffer;
 
 import com.google.common.base.Charsets;
 
-import org.apache.cassandra.cql.jdbc.AsciiTerm;
+import org.apache.cassandra.cql.jdbc.JdbcAscii;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 public class AsciiType extends AbstractType<String>
@@ -38,7 +38,7 @@ public class AsciiType extends AbstractT
     {
         try
         {
-            return AsciiTerm.instance.getString(bytes);
+            return JdbcAscii.instance.getString(bytes);
         }
         catch (org.apache.cassandra.cql.jdbc.MarshalException e)
         {
@@ -53,7 +53,7 @@ public class AsciiType extends AbstractT
 
     public String compose(ByteBuffer bytes)
     {
-        return AsciiTerm.instance.getString(bytes);
+        return JdbcAscii.instance.getString(bytes);
     }
 
     public ByteBuffer decompose(String value)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java?rev=1165672&r1=1165671&r2=1165672&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/marshal/LongType.java Tue Sep  6 13:56:48
2011
@@ -23,7 +23,7 @@ package org.apache.cassandra.db.marshal;
 
 import java.nio.ByteBuffer;
 
-import org.apache.cassandra.cql.jdbc.LongTerm;
+import org.apache.cassandra.cql.jdbc.JdbcLong;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 public class LongType extends AbstractType<Long>
@@ -34,7 +34,7 @@ public class LongType extends AbstractTy
 
     public Long compose(ByteBuffer bytes)
     {
-        return LongTerm.instance.compose(bytes);
+        return ByteBufferUtil.toLong(bytes);
     }
 
     public ByteBuffer decompose(Long value)
@@ -65,7 +65,7 @@ public class LongType extends AbstractTy
     {
         try
         {
-            return LongTerm.instance.getString(bytes);
+            return JdbcLong.instance.getString(bytes);
         }
         catch (org.apache.cassandra.cql.jdbc.MarshalException e)
         {

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/marshal/RoundTripTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/marshal/RoundTripTest.java?rev=1165672&r1=1165671&r2=1165672&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/marshal/RoundTripTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/marshal/RoundTripTest.java Tue Sep 
6 13:56:48 2011
@@ -56,7 +56,7 @@ public class RoundTripTest
         assert LongType.instance.fromString(LongType.instance.getString(ByteBuffer.wrap(v)))
                 .equals(ByteBuffer.wrap(v));
         assert LongType.instance.compose(ByteBuffer.wrap(v)) == 1L;
-        assert LongTerm.instance.toString(1L).equals("1");
+        assert JdbcLong.instance.toString(1L).equals("1");
     }
     
     @Test
@@ -67,7 +67,7 @@ public class RoundTripTest
         assert AsciiType.instance.fromString(AsciiType.instance.getString(ByteBuffer.wrap(abc)))
                 .equals(ByteBuffer.wrap(abc));
         assert AsciiType.instance.compose(ByteBuffer.wrap(abc)).equals("abc");
-        assert AsciiTerm.instance.toString("abc").equals("abc");
+        assert JdbcAscii.instance.toString("abc").equals("abc");
     }
     
     @Test



Mime
View raw message