cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdusba...@apache.org
Subject svn commit: r1092687 [2/2] - in /cassandra/trunk: ./ contrib/ drivers/py/ drivers/py/cql/ drivers/py/test/ interface/thrift/gen-java/org/apache/cassandra/thrift/ lib/licenses/ src/java/org/apache/cassandra/cache/ src/java/org/apache/cassandra/cli/ src/...
Date Fri, 15 Apr 2011 12:48:16 GMT
Modified: cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java Fri Apr 15 12:48:15 2011
@@ -28,7 +28,6 @@ import java.security.MessageDigest;
 import java.util.*;
 import java.util.Map.Entry;
 import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import javax.management.MBeanServer;
@@ -529,7 +528,9 @@ public class CompactionManager implement
         // so in our single-threaded compaction world this is a valid way of determining if we're compacting
         // all the sstables (that existed when we started)
         boolean major = cfs.isCompleteSSTables(sstables);
-        String type = major ? "Major" : "Minor";
+        CompactionType type = major
+                            ? CompactionType.MAJOR
+                            : CompactionType.MINOR;
         logger.info("Compacting {}: {}", type, sstables);
 
         long startTime = System.currentTimeMillis();
@@ -1147,7 +1148,7 @@ public class CompactionManager implement
     {
         public ValidationCompactionIterator(ColumnFamilyStore cfs, Range range) throws IOException
         {
-            super("Validation",
+            super(CompactionType.VALIDATION,
                   getCollatingIterator(cfs.getSSTables(), range),
                   new CompactionController(cfs, cfs.getSSTables(), true, getDefaultGcBefore(cfs), false));
         }
@@ -1348,7 +1349,7 @@ public class CompactionManager implement
             {
                 return new CompactionInfo(sstable.descriptor.ksname,
                                           sstable.descriptor.cfname,
-                                          "Cleanup of " + sstable.getColumnFamilyName(),
+                                          CompactionType.CLEANUP,
                                           scanner.getFilePointer(),
                                           scanner.getFileLength());
             }
@@ -1375,7 +1376,7 @@ public class CompactionManager implement
             {
                 return new CompactionInfo(sstable.descriptor.ksname,
                                           sstable.descriptor.cfname,
-                                          "Scrub " + sstable,
+                                          CompactionType.SCRUB,
                                           dataFile.getFilePointer(),
                                           dataFile.length());
             }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Fri Apr 15 12:48:15 2011
@@ -40,6 +40,7 @@ import org.apache.cassandra.db.filter.Qu
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.dht.LocalToken;
 import org.apache.cassandra.io.CompactionInfo;
+import org.apache.cassandra.io.CompactionType;
 import org.apache.cassandra.io.sstable.ReducingKeyIterator;
 import org.apache.cassandra.io.sstable.SSTableDeletingReference;
 import org.apache.cassandra.io.sstable.SSTableReader;
@@ -614,7 +615,7 @@ public class Table
         {
             return new CompactionInfo(cfs.table.name,
                                       cfs.columnFamily,
-                                      String.format("Secondary index build %s", cfs.columnFamily),
+                                      CompactionType.INDEX_BUILD,
                                       iter.getTotalBytes(),
                                       iter.getBytesRead());
         }

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/CompactionInfo.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/CompactionInfo.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/CompactionInfo.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/CompactionInfo.java Fri Apr 15 12:48:15 2011
@@ -23,13 +23,15 @@ import java.io.Serializable;
 /** Implements serializable to allow structured info to be returned via JMX. */
 public final class CompactionInfo implements Serializable
 {
+
+
     private final String ksname;
     private final String cfname;
-    private final String tasktype;
+    private final CompactionType tasktype;
     private final long bytesComplete;
     private final long totalBytes;
 
-    public CompactionInfo(String ksname, String cfname, String tasktype, long bytesComplete, long totalBytes)
+    public CompactionInfo(String ksname, String cfname, CompactionType tasktype, long bytesComplete, long totalBytes)
     {
         this.ksname = ksname;
         this.cfname = cfname;
@@ -64,7 +66,7 @@ public final class CompactionInfo implem
         return totalBytes;
     }
 
-    public String getTaskType()
+    public CompactionType getTaskType()
     {
         return tasktype;
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java Fri Apr 15 12:48:15 2011
@@ -24,18 +24,14 @@ package org.apache.cassandra.io;
 import java.io.Closeable;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.commons.collections.iterators.CollatingIterator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.db.ColumnFamily;
-import org.apache.cassandra.db.ColumnFamilyStore;
 import org.apache.cassandra.db.CompactionManager;
 import org.apache.cassandra.io.sstable.SSTableIdentityIterator;
 import org.apache.cassandra.io.sstable.SSTableReader;
@@ -53,7 +49,7 @@ implements Closeable, CompactionInfo.Hol
     public static final int FILE_BUFFER_SIZE = 1024 * 1024;
 
     protected final List<SSTableIdentityIterator> rows = new ArrayList<SSTableIdentityIterator>();
-    protected final String type;
+    protected final CompactionType type;
     protected final CompactionController controller;
 
     private long totalBytes;
@@ -68,13 +64,13 @@ implements Closeable, CompactionInfo.Hol
     // current target bytes to compact per millisecond
     private int targetBytesPerMS = -1;
 
-    public CompactionIterator(String type, Iterable<SSTableReader> sstables, CompactionController controller) throws IOException
+    public CompactionIterator(CompactionType type, Iterable<SSTableReader> sstables, CompactionController controller) throws IOException
     {
         this(type, getCollatingIterator(sstables), controller);
     }
 
     @SuppressWarnings("unchecked")
-    protected CompactionIterator(String type, Iterator iter, CompactionController controller)
+    protected CompactionIterator(CompactionType type, Iterator iter, CompactionController controller)
     {
         super(iter);
         this.type = type;

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java Fri Apr 15 12:48:15 2011
@@ -28,6 +28,7 @@ import java.util.Set;
 
 import com.google.common.collect.Sets;
 
+import org.apache.cassandra.io.*;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -38,13 +39,7 @@ import org.apache.cassandra.db.ColumnFam
 import org.apache.cassandra.db.ColumnFamilyStore;
 import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.db.Table;
-import org.apache.cassandra.db.marshal.AbstractCommutativeType;
 import org.apache.cassandra.dht.IPartitioner;
-import org.apache.cassandra.io.AbstractCompactedRow;
-import org.apache.cassandra.io.CompactionController;
-import org.apache.cassandra.io.CompactionInfo;
-import org.apache.cassandra.io.LazilyCompactedRow;
-import org.apache.cassandra.io.PrecompactedRow;
 import org.apache.cassandra.io.util.BufferedRandomAccessFile;
 import org.apache.cassandra.io.util.FileMark;
 import org.apache.cassandra.io.util.FileUtils;
@@ -271,7 +266,7 @@ public class SSTableWriter extends SSTab
                 // both file offsets are still valid post-close
                 return new CompactionInfo(desc.ksname,
                                           desc.cfname,
-                                          "SSTable rebuild",
+                                          CompactionType.SSTABLE_BUILD,
                                           indexer.dfile.getFilePointer(),
                                           indexer.dfile.length());
             }

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java Fri Apr 15 12:48:15 2011
@@ -76,6 +76,7 @@ public class StorageProxy implements Sto
 
     private static final WritePerformer standardWritePerformer;
     private static final WritePerformer counterWritePerformer;
+    private static final WritePerformer counterWriteOnCoordinatorPerformer;
 
     public static final StorageProxy instance = new StorageProxy();
 
@@ -102,11 +103,25 @@ public class StorageProxy implements Sto
             }
         };
 
+        /*
+         * We execute counter writes in 2 places: either directly in the coordinator node if it is a replica, or
+         * in CounterMutationVerbHandler on a replica othewise. The write must be executed on the MUTATION stage
+         * but on the latter case, the verb handler already run on the MUTATION stage, so we must not execute the
+         * underlying on the stage otherwise we risk a deadlock. Hence two different performer.
+         */
         counterWritePerformer = new WritePerformer()
         {
             public void apply(IMutation mutation, Multimap<InetAddress, InetAddress> hintedEndpoints, IWriteResponseHandler responseHandler, String localDataCenter, ConsistencyLevel consistency_level) throws IOException
             {
-                applyCounterMutation(mutation, hintedEndpoints, responseHandler, localDataCenter, consistency_level);
+                applyCounterMutation(mutation, hintedEndpoints, responseHandler, localDataCenter, consistency_level, false);
+            }
+        };
+
+        counterWriteOnCoordinatorPerformer = new WritePerformer()
+        {
+            public void apply(IMutation mutation, Multimap<InetAddress, InetAddress> hintedEndpoints, IWriteResponseHandler responseHandler, String localDataCenter, ConsistencyLevel consistency_level) throws IOException
+            {
+                applyCounterMutation(mutation, hintedEndpoints, responseHandler, localDataCenter, consistency_level, true);
             }
         };
     }
@@ -367,7 +382,7 @@ public class StorageProxy implements Sto
 
                 if (endpoint.equals(FBUtilities.getLocalAddress()))
                 {
-                    applyCounterMutationOnLeader(cm);
+                    applyCounterMutationOnCoordinator(cm);
                 }
                 else
                 {
@@ -423,7 +438,14 @@ public class StorageProxy implements Sto
         write(Collections.singletonList(cm), cm.consistency(), counterWritePerformer, false);
     }
 
-    private static void applyCounterMutation(final IMutation mutation, final Multimap<InetAddress, InetAddress> hintedEndpoints, final IWriteResponseHandler responseHandler, final String localDataCenter, final ConsistencyLevel consistency_level)
+    // Same as applyCounterMutationOnLeader but must with the difference that it use the MUTATION stage to execute the write (while
+    // applyCounterMutationOnLeader assumes it is on the MUTATION stage already)
+    public static void applyCounterMutationOnCoordinator(CounterMutation cm) throws UnavailableException, TimeoutException, IOException
+    {
+        write(Collections.singletonList(cm), cm.consistency(), counterWriteOnCoordinatorPerformer, false);
+    }
+
+    private static void applyCounterMutation(final IMutation mutation, final Multimap<InetAddress, InetAddress> hintedEndpoints, final IWriteResponseHandler responseHandler, final String localDataCenter, final ConsistencyLevel consistency_level, boolean executeOnMutationStage)
     {
         // we apply locally first, then send it to other replica
         if (logger.isDebugEnabled())
@@ -456,7 +478,10 @@ public class StorageProxy implements Sto
                 }
             }
         };
-        StageManager.getStage(Stage.MUTATION).execute(runnable);
+        if (executeOnMutationStage)
+            StageManager.getStage(Stage.MUTATION).execute(runnable);
+        else
+            runnable.run();
     }
 
     /**

Modified: cassandra/trunk/test/long/org/apache/cassandra/db/LongCompactionSpeedTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/long/org/apache/cassandra/db/LongCompactionSpeedTest.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/test/long/org/apache/cassandra/db/LongCompactionSpeedTest.java (original)
+++ cassandra/trunk/test/long/org/apache/cassandra/db/LongCompactionSpeedTest.java Fri Apr 15 12:48:15 2011
@@ -20,28 +20,29 @@ package org.apache.cassandra.db;
 
 import java.io.IOException;
 import java.net.InetAddress;
+import java.nio.ByteBuffer;
 import java.util.*;
 
-import org.apache.cassandra.Util;
-
 import org.junit.Test;
-import org.apache.cassandra.io.util.FileUtils;
+import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.Util;
 import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.io.util.FileUtils;
+import org.apache.cassandra.io.sstable.Component;
 import org.apache.cassandra.io.sstable.SSTableReader;
 import org.apache.cassandra.io.sstable.SSTableUtils;
 import org.apache.cassandra.io.sstable.SSTableWriter;
-import org.apache.cassandra.CleanupHelper;
-import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.streaming.OperationType;
 import org.apache.cassandra.utils.ByteBufferUtil;
-import java.nio.ByteBuffer;
-import org.apache.cassandra.io.sstable.Component;
+import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.NodeId;
+import static org.apache.cassandra.db.context.CounterContext.ContextState;
+
 import static junit.framework.Assert.assertEquals;
 
 public class LongCompactionSpeedTest extends CleanupHelper
 {
     public static final String TABLE1 = "Keyspace1";
-    public static final InetAddress LOCAL = FBUtilities.getLocalAddress();
 
     /**
      * Test compaction with a very wide row.
@@ -188,12 +189,12 @@ public class LongCompactionSpeedTest ext
 
     protected CounterColumn createCounterColumn(String name)
     {
-        byte[] context = Util.concatByteArrays(
-            FBUtilities.getLocalAddress().getAddress(), FBUtilities.toByteArray(9L), FBUtilities.toByteArray(3L),
-            FBUtilities.toByteArray(2),  FBUtilities.toByteArray(4L), FBUtilities.toByteArray(2L),
-            FBUtilities.toByteArray(4),  FBUtilities.toByteArray(3L), FBUtilities.toByteArray(3L),
-            FBUtilities.toByteArray(8),  FBUtilities.toByteArray(2L), FBUtilities.toByteArray(4L)
-        );
-        return new CounterColumn(ByteBufferUtil.bytes(name), ByteBuffer.wrap(context), 0L);
+        ContextState context = ContextState.allocate(4, 1);
+        context.writeElement(NodeId.fromInt(1), 4L, 2L, true);
+        context.writeElement(NodeId.fromInt(2), 4L, 2L);
+        context.writeElement(NodeId.fromInt(4), 3L, 3L);
+        context.writeElement(NodeId.fromInt(8), 2L, 4L);
+
+        return new CounterColumn(ByteBufferUtil.bytes(name), context.context, 0L);
     }
 }

Modified: cassandra/trunk/test/system/test_cql.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_cql.py?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_cql.py (original)
+++ cassandra/trunk/test/system/test_cql.py Fri Apr 15 12:48:15 2011
@@ -23,18 +23,18 @@ import sys, uuid, time
 
 sys.path.append(join(abspath(dirname(__file__)), '../../drivers/py'))
 
-from cql import Connection
-from cql.errors import CQLException
+import cql
+from cql.connection import Connection
 from __init__ import ThriftTester
 from __init__ import thrift_client     # TODO: temporary
 
-def assert_raises(exception, method, *args):
+def assert_raises(exception, method, *args, **kwargs):
     try:
-        method(*args)
+        method(*args, **kwargs)
     except exception:
         return
     raise AssertionError("failed to see expected exception")
-    
+
 def uuid1bytes_to_millis(uuidbytes):
     return (uuid.UUID(bytes=uuidbytes).get_time() / 10000) - 12219292800000L
 
@@ -72,12 +72,12 @@ def load_sample(dbconn):
             WITH comparator = ascii AND default_validation = ascii;
     """)
     dbconn.execute("CREATE INDEX ON IndexedA (birthdate)")
-    
-    query = "UPDATE StandardString1 SET ? = ?, ? = ? WHERE KEY = ?"
-    dbconn.execute(query, "ca1", "va1", "col", "val", "ka")
-    dbconn.execute(query, "cb1", "vb1", "col", "val", "kb")
-    dbconn.execute(query, "cc1", "vc1", "col", "val", "kc")
-    dbconn.execute(query, "cd1", "vd1", "col", "val", "kd")
+
+    query = "UPDATE StandardString1 SET :c1 = :v1, :c2 = :v2 WHERE KEY = :key"
+    dbconn.execute(query, dict(c1="ca1", v1="va1", c2="col", v2="val", key="ka"))
+    dbconn.execute(query, dict(c1="cb1", v1="vb1", c2="col", v2="val", key="kb"))
+    dbconn.execute(query, dict(c1="cc1", v1="vc1", c2="col", v2="val", key="kc"))
+    dbconn.execute(query, dict(c1="cd1", v1="vd1", c2="col", v2="val", key="kd"))
 
     dbconn.execute("""
     BEGIN BATCH USING CONSISTENCY ONE
@@ -90,7 +90,7 @@ def load_sample(dbconn):
      UPDATE StandardLongA SET 5='5', 6='6', 7='8', 9='9' WHERE KEY='ag'
     APPLY BATCH
     """)
-    
+
     dbconn.execute("""
     BEGIN BATCH USING CONSISTENCY ONE
       UPDATE StandardIntegerA SET 10='a', 20='b', 30='c', 40='d' WHERE KEY='k1';
@@ -114,255 +114,294 @@ def load_sample(dbconn):
     """)
 
 def init(keyspace="Keyspace1"):
-    dbconn = Connection('localhost', 9170, keyspace)
-    load_sample(dbconn)
-    return dbconn
+    dbconn = cql.connect('localhost', 9170, keyspace)
+    cursor = dbconn.cursor()
+    load_sample(cursor)
+    return cursor
 
 class TestCql(ThriftTester):
     def test_select_simple(self):
         "retrieve a column"
-        conn = init()
-        r = conn.execute("SELECT 'ca1' FROM StandardString1 WHERE KEY='ka'")
-        assert r[0].key == 'ka'
-        assert r[0].columns[0].name == 'ca1'
-        assert r[0].columns[0].value == 'va1'
+        cursor = init()
+        cursor.execute("SELECT 'ca1' FROM StandardString1 WHERE KEY='ka'")
+        r = cursor.fetchone()
+        d = cursor.description
+
+        assert d[0][0] == cql.ROW_KEY
+        assert r[0] == 'ka'
+
+        assert d[1][0] == 'ca1'
+        assert r[1] == 'va1'
 
     def test_select_columns(self):
         "retrieve multiple columns"
-        conn = init()
-        r = conn.execute("""
+        cursor = init()
+        cursor.execute("""
             SELECT 'cd1', 'col' FROM StandardString1 WHERE KEY = 'kd'
         """)
-        assert "cd1" in [i.name for i in r[0].columns]
-        assert "col" in [i.name for i in r[0].columns]
+
+        d = cursor.description
+        assert "cd1" in [col_dscptn[0] for col_dscptn in d]
+        assert "col" in [col_dscptn[0] for col_dscptn in d]
 
     def test_select_row_range(self):
         "retrieve a range of rows with columns"
-        conn = init()
-        r = conn.execute("""
+        cursor = init()
+        cursor.execute("""
             SELECT 4 FROM StandardLongA WHERE KEY > 'ad' AND KEY < 'ag';
         """)
-        assert len(r) == 4
-        assert r[0].key == "ad"
-        assert r[1].key == "ae"
-        assert r[2].key == "af"
-        assert len(r[0].columns) == 1
-        assert len(r[1].columns) == 1
-        assert len(r[2].columns) == 1
+        keys = ['ad', 'ae', 'af']
+        assert cursor.rowcount == 4
+        for i in range(3):
+            r = cursor.fetchone()
+            assert len(r) == 2
+            assert r[0] == keys[i]
 
     def test_select_row_range_with_limit(self):
         "retrieve a limited range of rows with columns"
-        conn = init()
-        r = conn.execute("""
+        cursor = init()
+        cursor.execute("""
             SELECT 1,5,9 FROM StandardLongA WHERE KEY > 'aa'
                     AND KEY < 'ag' LIMIT 3
         """)
-        assert len(r) == 3
-        
-        r = conn.execute("""
+        assert cursor.rowcount == 3
+
+        cursor.execute("""
             SELECT 20,40 FROM StandardIntegerA WHERE KEY > 'k1'
                     AND KEY < 'k7' LIMIT 5
         """)
-        assert len(r) == 5
-        r[0].key == "k1"
-        r[4].key == "k5"
+        assert cursor.rowcount == 5
+        for i in range(5):
+            r = cursor.fetchone()
+            assert r[0] == "k%d" % (i+1)
 
     def test_select_columns_slice(self):
         "range of columns (slice) by row"
-        conn = init()
-        r = conn.execute("SELECT 1..3 FROM StandardLongA WHERE KEY = 'aa';")
-        assert len(r) == 1
-        assert r[0].columns[0].value == "1"
-        assert r[0].columns[1].value == "2"
-        assert r[0].columns[2].value == "3"
-        
-        r = conn.execute("SELECT 10..30 FROM StandardIntegerA WHERE KEY='k1'")
-        assert len(r) == 1
-        assert r[0].columns[0].value == "a"
-        assert r[0].columns[1].value == "b"
-        assert r[0].columns[2].value == "c"
-        
+        cursor = init()
+
+        cursor.execute("SELECT 1..3 FROM StandardLongA WHERE KEY = 'aa';")
+        assert cursor.rowcount == 1
+        r = cursor.fetchone()
+        assert r[0] == "aa"
+        assert r[1] == "1"
+        assert r[2] == "2"
+        assert r[3] == "3"
+
+        cursor.execute("SELECT 10..30 FROM StandardIntegerA WHERE KEY='k1'")
+        assert cursor.rowcount == 1
+        r = cursor.fetchone()
+        assert r[0] == "k1"
+        assert r[1] == "a"
+        assert r[2] == "b"
+        assert r[3] == "c"
+
     def test_select_columns_slice_all(self):
         "slice all columns in a row"
-        conn = init()
-        r = conn.execute("SELECT * FROM StandardString1 WHERE KEY = 'ka';")
-        assert len(r[0].columns) == 2
-        r = conn.execute("SELECT ''..'' FROM StandardString1 WHERE KEY = 'ka';")
-        assert len(r[0].columns) == 2
+        cursor = init()
+        cursor.execute("SELECT * FROM StandardString1 WHERE KEY = 'ka';")
+        r = cursor.fetchone()
+        assert len(r) == 3
+        cursor.execute("SELECT ''..'' FROM StandardString1 WHERE KEY = 'ka';")
+        r = cursor.fetchone()
+        assert len(r) == 3
 
     def test_select_columns_slice_with_limit(self):
         "range of columns (slice) by row with limit"
-        conn = init()
-        r = conn.execute("""
+        cursor = init()
+        cursor.execute("""
             SELECT FIRST 1 1..3 FROM StandardLongA WHERE KEY = 'aa';
         """)
-        assert len(r) == 1
-        assert len(r[0].columns) == 1
-        assert r[0].columns[0].value == "1"
+        assert cursor.rowcount == 1
+        r = cursor.fetchone()
+        assert len(r) == 2
+        assert r[0] == "aa"
+        assert r[1] == "1"
 
     def test_select_columns_slice_reversed(self):
         "range of columns (slice) by row reversed"
-        conn = init()
-        r = conn.execute("""
+        cursor= init()
+        cursor.execute("""
             SELECT FIRST 2 REVERSED 3..1 FROM StandardLongA WHERE KEY = 'aa';
         """)
-        assert len(r) == 1, "%d != 1" % len(r)
-        assert len(r[0].columns) == 2
-        assert r[0].columns[0].value == "3"
-        assert r[0].columns[1].value == "2"
+        assert cursor.rowcount == 1, "%d != 1" % cursor.rowcount
+        r = cursor.fetchone()
+        assert len(r) == 3
+        assert r[0] == 'aa'
+        assert r[1] == "3"
+        assert r[2] == "2"
 
     def test_error_on_multiple_key_by(self):
         "ensure multiple key-bys in where clause excepts"
-        conn = init()
-        assert_raises(CQLException, conn.execute, """
+        cursor = init()
+        assert_raises(cql.ProgrammingError, cursor.execute, """
             SELECT 'col' FROM StandardString1 WHERE KEY = 'ka' AND KEY = 'kb';
         """)
 
     def test_index_scan_equality(self):
         "indexed scan where column equals value"
-        conn = init()
-        r = conn.execute("""
+        cursor = init()
+        cursor.execute("""
             SELECT 'birthdate' FROM IndexedA WHERE 'birthdate' = 100
         """)
+        assert cursor.rowcount == 2
+
+        r = cursor.fetchone()
+        assert r[0] == "asmith"
+        assert len(r) == 2
+
+        r = cursor.fetchone()
+        assert r[0] == "dozer"
         assert len(r) == 2
-        assert r[0].key == "asmith"
-        assert r[1].key == "dozer"
-        assert len(r[0].columns) == 1
-        assert len(r[1].columns) == 1
 
     def test_index_scan_greater_than(self):
         "indexed scan where a column is greater than a value"
-        conn = init()
-        r = conn.execute("""
+        cursor = init()
+        cursor.execute("""
             SELECT 'birthdate' FROM IndexedA WHERE 'birthdate' = 100
                     AND 'unindexed' > 200
         """)
-        assert len(r) == 1
-        assert r[0].key == "asmith"
+        assert cursor.rowcount == 1
+        r = cursor.fetchone()
+        assert r[0] == "asmith"
 
     def test_index_scan_with_start_key(self):
         "indexed scan with a starting key"
-        conn = init()
-        r = conn.execute("""
+        cursor = init()
+        cursor.execute("""
             SELECT 'birthdate' FROM IndexedA WHERE 'birthdate' = 100
                     AND KEY > 'asmithZ'
         """)
-        assert len(r) == 1
-        assert r[0].key == "dozer"
+        assert cursor.rowcount == 1
+        r = cursor.fetchone()
+        assert r[0] == "dozer"
 
     def test_no_where_clause(self):
         "empty where clause (range query w/o start key)"
-        conn = init()
-        r = conn.execute("SELECT 'col' FROM StandardString1 LIMIT 3")
-        assert len(r) == 3
-        assert r[0].key == "ka"
-        assert r[1].key == "kb"
-        assert r[2].key == "kc"
+        cursor = init()
+        cursor.execute("SELECT 'col' FROM StandardString1 LIMIT 3")
+        assert cursor.rowcount == 3
+        rows = cursor.fetchmany(3)
+        assert rows[0][0] == "ka"
+        assert rows[1][0] == "kb"
+        assert rows[2][0] == "kc"
 
     def test_column_count(self):
         "getting a result count instead of results"
-        conn = init()
-        r = conn.execute("""
+        cursor = init()
+        cursor.execute("""
             SELECT COUNT(1..4) FROM StandardLongA WHERE KEY = 'aa';
         """)
-        assert r == 4, "expected 4 results, got %d" % (r and r or 0)
+        r = cursor.fetchone()
+        assert r[0] == 4, "expected 4 results, got %d" % (r and r or 0)
 
     def test_truncate_columnfamily(self):
         "truncating a column family"
-        conn = init()
-        conn.execute('TRUNCATE StandardString1;')
-        r = conn.execute("SELECT 'cd1' FROM StandardString1 WHERE KEY = 'kd'")
-        assert len(r) == 0
+        cursor = init()
+        cursor.execute('TRUNCATE StandardString1;')
+        cursor.execute("SELECT 'cd1' FROM StandardString1 WHERE KEY = 'kd'")
+        assert cursor.rowcount == 0
 
     def test_delete_columns(self):
         "delete columns from a row"
-        conn = init()
-        r = conn.execute("""
+        cursor = init()
+        cursor.execute("""
             SELECT 'cd1', 'col' FROM StandardString1 WHERE KEY = 'kd'
         """)
-        assert "cd1" in [i.name for i in r[0].columns]
-        assert "col" in [i.name for i in r[0].columns]
-        conn.execute("""
+        colnames = [col_d[0] for col_d in cursor.description]
+        assert "cd1" in colnames
+        assert "col" in colnames
+        cursor.execute("""
             DELETE 'cd1', 'col' FROM StandardString1 WHERE KEY = 'kd'
         """)
-        r = conn.execute("""
+        cursor.execute("""
             SELECT 'cd1', 'col' FROM StandardString1 WHERE KEY = 'kd'
         """)
-        assert len(r[0].columns) == 0
+        r = cursor.fetchone()
+        assert len(r) == 1
 
     def test_delete_columns_multi_rows(self):
         "delete columns from multiple rows"
-        conn = init()
-        r = conn.execute("SELECT 'col' FROM StandardString1 WHERE KEY = 'kc'")
-        assert len(r[0].columns) == 1
-        r = conn.execute("SELECT 'col' FROM StandardString1 WHERE KEY = 'kd'")
-        assert len(r[0].columns) == 1
+        cursor = init()
+
+        cursor.execute("SELECT 'col' FROM StandardString1 WHERE KEY = 'kc'")
+        r = cursor.fetchone()
+        assert  len(r) == 2
+
+        cursor.execute("SELECT 'col' FROM StandardString1 WHERE KEY = 'kd'")
+        r = cursor.fetchone()
+        assert  len(r) == 2
 
-        conn.execute("""
+        cursor.execute("""
             DELETE 'col' FROM StandardString1 WHERE KEY IN ('kc', 'kd')
         """)
-        r = conn.execute("SELECT 'col' FROM StandardString1 WHERE KEY = 'kc'")
-        assert len(r[0].columns) == 0
-        r = conn.execute("SELECT 'col' FROM StandardString1 WHERE KEY = 'kd'")
-        assert len(r[0].columns) == 0
+        cursor.execute("SELECT 'col' FROM StandardString1 WHERE KEY = 'kc'")
+        r = cursor.fetchone()
+        assert  len(r) == 1
+
+        cursor.execute("SELECT 'col' FROM StandardString1 WHERE KEY = 'kd'")
+        r = cursor.fetchone()
+        assert  len(r) == 1
 
     def test_delete_rows(self):
         "delete entire rows"
-        conn = init()
-        r = conn.execute("""
+        cursor = init()
+        cursor.execute("""
             SELECT 'cd1', 'col' FROM StandardString1 WHERE KEY = 'kd'
         """)
-        assert "cd1" in [i.name for i in r[0].columns]
-        assert "col" in [i.name for i in r[0].columns]
-        conn.execute("DELETE FROM StandardString1 WHERE KEY = 'kd'")
-        r = conn.execute("""
+        colnames = [col_d[0] for col_d in cursor.description]
+        assert "cd1" in colnames
+        assert "col" in colnames
+        cursor.execute("DELETE FROM StandardString1 WHERE KEY = 'kd'")
+        cursor.execute("""
             SELECT 'cd1', 'col' FROM StandardString1 WHERE KEY = 'kd'
         """)
-        assert len(r[0].columns) == 0
-        
+        r = cursor.fetchone()
+        assert len(r) == 1
+
     def test_create_keyspace(self):
         "create a new keyspace"
-        init().execute("""
+        cursor = init()
+        cursor.execute("""
         CREATE KEYSPACE TestKeyspace42 WITH strategy_options:DC1 = '1'
             AND strategy_class = 'NetworkTopologyStrategy'
         """)
-        
+
         # TODO: temporary (until this can be done with CQL).
         ksdef = thrift_client.describe_keyspace("TestKeyspace42")
-        
+
         strategy_class = "org.apache.cassandra.locator.NetworkTopologyStrategy"
         assert ksdef.strategy_class == strategy_class
         assert ksdef.strategy_options['DC1'] == "1"
-        
+
     def test_drop_keyspace(self):
         "removing a keyspace"
-        conn = init()
-        conn.execute("""
-        CREATE KEYSPACE Keyspace4Drop
-            WITH strategy_class = SimpleStrategy AND strategy_options:replication_factor = 1
+        cursor = init()
+        cursor.execute("""
+               CREATE KEYSPACE Keyspace4Drop WITH strategy_options:replication_factor = '1'
+                   AND strategy_class = 'SimpleStrategy'
         """)
-        
+
         # TODO: temporary (until this can be done with CQL).
         thrift_client.describe_keyspace("Keyspace4Drop")
-        
-        conn.execute('DROP KEYSPACE Keyspace4Drop;')
-        
+
+        cursor.execute('DROP KEYSPACE Keyspace4Drop;')
+
         # Technically this should throw a ttypes.NotFound(), but this is
         # temporary and so not worth requiring it on PYTHONPATH.
         assert_raises(Exception,
                       thrift_client.describe_keyspace,
                       "Keyspace4Drop")
-        
+
     def test_create_column_family(self):
         "create a new column family"
-        conn = init()
-        conn.execute("""
-            CREATE KEYSPACE CreateCFKeyspace WITH strategy_options:replication_factor = 1
-                AND strategy_class = 'SimpleStrategy';
-        """)
-        conn.execute("USE CreateCFKeyspace;")
-        
-        conn.execute("""
+        cursor = init()
+        cursor.execute("""
+               CREATE KEYSPACE CreateCFKeyspace WITH strategy_options:replication_factor = '1'
+                   AND strategy_class = 'SimpleStrategy';
+        """)
+        cursor.execute("USE CreateCFKeyspace;")
+
+        cursor.execute("""
             CREATE COLUMNFAMILY NewCf1 (
                 KEY varint PRIMARY KEY,
                 'username' text,
@@ -371,7 +410,7 @@ class TestCql(ThriftTester):
                 'id' uuid
             ) WITH comment = 'shiny, new, cf' AND default_validation = ascii;
         """)
-        
+
         # TODO: temporary (until this can be done with CQL).
         ksdef = thrift_client.describe_keyspace("CreateCFKeyspace")
         assert len(ksdef.cf_defs) == 1, \
@@ -383,27 +422,27 @@ class TestCql(ThriftTester):
         assert cfam.default_validation_class == "org.apache.cassandra.db.marshal.AsciiType"
         assert cfam.comparator_type == "org.apache.cassandra.db.marshal.UTF8Type"
         assert cfam.key_validation_class == "org.apache.cassandra.db.marshal.IntegerType"
-        
+
         # Missing primary key
-        assert_raises(CQLException, conn.execute, "CREATE COLUMNFAMILY NewCf2")
-        
+        assert_raises(cql.ProgrammingError, cursor.execute, "CREATE COLUMNFAMILY NewCf2")
+
         # Too many primary keys
-        assert_raises(CQLException,
-                      conn.execute,
+        assert_raises(cql.ProgrammingError,
+                      cursor.execute,
                       """CREATE COLUMNFAMILY NewCf2
                              (KEY varint PRIMARY KEY, KEY text PRIMARY KEY)""")
-        
+
         # No column defs
-        conn.execute("""CREATE COLUMNFAMILY NewCf3
+        cursor.execute("""CREATE COLUMNFAMILY NewCf3
                             (KEY varint PRIMARY KEY) WITH comparator = bigint""")
         ksdef = thrift_client.describe_keyspace("CreateCFKeyspace")
         assert len(ksdef.cf_defs) == 2, \
             "expected 3 column families total, found %d" % len(ksdef.cf_defs)
         cfam = [i for i in ksdef.cf_defs if i.name == "NewCf3"][0]
         assert cfam.comparator_type == "org.apache.cassandra.db.marshal.LongType"
-        
+
         # Column defs, defaults otherwise
-        conn.execute("""CREATE COLUMNFAMILY NewCf4
+        cursor.execute("""CREATE COLUMNFAMILY NewCf4
                             (KEY varint PRIMARY KEY, 'a' varint, 'b' varint)
                             WITH comparator = text;""")
         ksdef = thrift_client.describe_keyspace("CreateCFKeyspace")
@@ -415,34 +454,34 @@ class TestCql(ThriftTester):
         for coldef in cfam.column_metadata:
             assert coldef.name in ("a", "b"), "Unknown column name " + coldef.name
             assert coldef.validation_class.endswith("marshal.IntegerType")
-            
+
     def test_drop_columnfamily(self):
         "removing a column family"
-        conn = init()
-        conn.execute("""
-            CREATE KEYSPACE Keyspace4CFDrop WITH strategy_options:replication_factor = 1
-                AND strategy_class = 'SimpleStrategy';
-        """)
-        conn.execute('USE Keyspace4CFDrop;')
-        conn.execute('CREATE COLUMNFAMILY CF4Drop (KEY varint PRIMARY KEY);')
-        
+        cursor = init()
+        cursor.execute("""
+               CREATE KEYSPACE Keyspace4CFDrop WITH strategy_options:replication_factor = '1'
+                   AND strategy_class = 'SimpleStrategy';
+        """)
+        cursor.execute('USE Keyspace4CFDrop;')
+        cursor.execute('CREATE COLUMNFAMILY CF4Drop (KEY varint PRIMARY KEY);')
+
         # TODO: temporary (until this can be done with CQL).
         ksdef = thrift_client.describe_keyspace("Keyspace4CFDrop")
         assert len(ksdef.cf_defs), "Column family not created!"
-        
-        conn.execute('DROP COLUMNFAMILY CF4Drop;')
-        
+
+        cursor.execute('DROP COLUMNFAMILY CF4Drop;')
+
         ksdef = thrift_client.describe_keyspace("Keyspace4CFDrop")
         assert not len(ksdef.cf_defs), "Column family not deleted!"
-            
+
     def test_create_indexs(self):
         "creating column indexes"
-        conn = init()
-        conn.execute("USE Keyspace1")
-        conn.execute("CREATE COLUMNFAMILY CreateIndex1 (KEY text PRIMARY KEY)")
-        conn.execute("CREATE INDEX namedIndex ON CreateIndex1 (items)")
-        conn.execute("CREATE INDEX ON CreateIndex1 (stuff)")
-        
+        cursor = init()
+        cursor.execute("USE Keyspace1")
+        cursor.execute("CREATE COLUMNFAMILY CreateIndex1 (KEY text PRIMARY KEY)")
+        cursor.execute("CREATE INDEX namedIndex ON CreateIndex1 (items)")
+        cursor.execute("CREATE INDEX ON CreateIndex1 (stuff)")
+
         # TODO: temporary (until this can be done with CQL).
         ksdef = thrift_client.describe_keyspace("Keyspace1")
         cfam = [i for i in ksdef.cf_defs if i.name == "CreateIndex1"][0]
@@ -455,205 +494,208 @@ class TestCql(ThriftTester):
         assert stuff.index_type == 0, "missing index"
 
         # already indexed
-        assert_raises(CQLException,
-                      conn.execute,
+        assert_raises(cql.ProgrammingError,
+                      cursor.execute,
                       "CREATE INDEX ON CreateIndex1 (stuff)")
 
     def test_time_uuid(self):
         "store and retrieve time-based (type 1) uuids"
-        conn = init()
-        
+        cursor = init()
+
         # Store and retrieve a timeuuid using it's hex-formatted string
         timeuuid = uuid.uuid1()
-        conn.execute("""
+        cursor.execute("""
             UPDATE StandardTimeUUID SET '%s' = 10 WHERE KEY = 'uuidtest'
         """ % str(timeuuid))
-        
-        r = conn.execute("""
+
+        cursor.execute("""
             SELECT '%s' FROM StandardTimeUUID WHERE KEY = 'uuidtest'
         """ % str(timeuuid))
-        assert r[0].columns[0].name == timeuuid
-        
+        d = cursor.description
+        assert d[1][0] == timeuuid, "%s, %s" % (str(d[1][0]), str(timeuuid))
+
         # Tests a node-side conversion from bigint to UUID.
         ms = uuid1bytes_to_millis(uuid.uuid1().bytes)
-        conn.execute("""
+        cursor.execute("""
             UPDATE StandardTimeUUIDValues SET 'id' = %d WHERE KEY = 'uuidtest'
         """ % ms)
-        
-        r = conn.execute("""
+
+        cursor.execute("""
             SELECT 'id' FROM StandardTimeUUIDValues WHERE KEY = 'uuidtest'
         """)
-        assert uuid1bytes_to_millis(r[0].columns[0].value.bytes) == ms
-        
+        r = cursor.fetchone()
+        assert uuid1bytes_to_millis(r[1].bytes) == ms
+
         # Tests a node-side conversion from ISO8601 to UUID.
-        conn.execute("""
+        cursor.execute("""
             UPDATE StandardTimeUUIDValues SET 'id2' = '2011-01-31 17:00:00-0000'
             WHERE KEY = 'uuidtest'
         """)
-        
-        r = conn.execute("""
+
+        cursor.execute("""
             SELECT 'id2' FROM StandardTimeUUIDValues WHERE KEY = 'uuidtest'
         """)
         # 2011-01-31 17:00:00-0000 == 1296493200000ms
-        ms = uuid1bytes_to_millis(r[0].columns[0].value.bytes)
+        r = cursor.fetchone()
+        ms = uuid1bytes_to_millis(r[1].bytes)
         assert ms == 1296493200000, \
                 "%d != 1296493200000 (2011-01-31 17:00:00-0000)" % ms
 
         # Tests node-side conversion of timeuuid("now") to UUID
-        conn.execute("""
+        cursor.execute("""
             UPDATE StandardTimeUUIDValues SET 'id3' = 'now'
                     WHERE KEY = 'uuidtest'
         """)
-        
-        r = conn.execute("""
+
+        cursor.execute("""
             SELECT 'id3' FROM StandardTimeUUIDValues WHERE KEY = 'uuidtest'
         """)
-        ms = uuid1bytes_to_millis(r[0].columns[0].value.bytes)
+        r = cursor.fetchone()
+        ms = uuid1bytes_to_millis(r[1].bytes)
         assert ((time.time() * 1e3) - ms) < 100, \
             "new timeuuid not within 100ms of now (UPDATE vs. SELECT)"
 
         uuid_range = []
-        update = "UPDATE StandardTimeUUID SET ? = ? WHERE KEY = slicetest"
+        update = "UPDATE StandardTimeUUID SET :name = :val WHERE KEY = slicetest"
         for i in range(5):
             uuid_range.append(uuid.uuid1())
-            conn.execute(update, uuid_range[i], i)
+            cursor.execute(update, dict(name=uuid_range[i], val=i))
+
+        cursor.execute("""
+            SELECT :start..:finish FROM StandardTimeUUID WHERE KEY = slicetest
+            """, dict(start=uuid_range[0], finish=uuid_range[len(uuid_range)-1]))
+        d = cursor.description
+        for (i, col_d) in enumerate(d[1:]):
+            assert uuid_range[i] == col_d[0]
+
 
-        r = conn.execute("""
-            SELECT ?..? FROM StandardTimeUUID WHERE KEY = slicetest
-        """, uuid_range[0], uuid_range[len(uuid_range)-1])
-        
-        for (i, col) in enumerate(r[0]):
-            assert uuid_range[i] == col.name
-        
-        
     def test_lexical_uuid(self):
         "store and retrieve lexical uuids"
-        conn = init()
+        cursor = init()
         uid = uuid.uuid4()
-        conn.execute("UPDATE StandardUUID SET ? = 10 WHERE KEY = 'uuidtest'",
-                     uid)
-        
-        r = conn.execute("SELECT ? FROM StandardUUID WHERE KEY = 'uuidtest'",
-                         uid)
-        assert r[0].columns[0].name == uid, r[0].columns[0].name
-        
+        cursor.execute("UPDATE StandardUUID SET :name = 10 WHERE KEY = 'uuidtest'",
+                       dict(name=uid))
+
+        cursor.execute("SELECT :name FROM StandardUUID WHERE KEY = 'uuidtest'",
+                       dict(name=uid))
+        d = cursor.description
+        assert d[1][0] == uid, "expected %s, got %s (%s)" % \
+                (uid.bytes.encode('hex'), str(d[1][0]).encode('hex'), d[1][1])
+
         # TODO: slices of uuids from cf w/ LexicalUUIDType comparator
-        
+
     def test_utf8_read_write(self):
         "reading and writing utf8 values"
-        conn = init()
+        cursor = init()
         # Sorting: ¢ (u00a2) < © (u00a9) < ® (u00ae) < ¿ (u00bf)
-        conn.execute("UPDATE StandardUtf82 SET ? = v1 WHERE KEY = k1", "¿")
-        conn.execute("UPDATE StandardUtf82 SET ? = v1 WHERE KEY = k1", "©")
-        conn.execute("UPDATE StandardUtf82 SET ? = v1 WHERE KEY = k1", "®")
-        conn.execute("UPDATE StandardUtf82 SET ? = v1 WHERE KEY = k1", "¢")
-        
-        r = conn.execute("SELECT * FROM StandardUtf82 WHERE KEY = k1")
-        assert r[0][0].name == u"¢"
-        assert r[0][1].name == u"©"
-        assert r[0][2].name == u"®"
-        assert r[0][3].name == u"¿"
-        
-        r = conn.execute("SELECT ?..'' FROM StandardUtf82 WHERE KEY = k1", "©")
-        assert len(r[0]) == 3
-        assert r[0][0].name == u"©"
-        assert r[0][1].name == u"®"
-        assert r[0][2].name == u"¿"
-        
+        cursor.execute("UPDATE StandardUtf82 SET :name = v1 WHERE KEY = k1", dict(name="¿"))
+        cursor.execute("UPDATE StandardUtf82 SET :name = v1 WHERE KEY = k1", dict(name="©"))
+        cursor.execute("UPDATE StandardUtf82 SET :name = v1 WHERE KEY = k1", dict(name="®"))
+        cursor.execute("UPDATE StandardUtf82 SET :name = v1 WHERE KEY = k1", dict(name="¢"))
+
+        cursor.execute("SELECT * FROM StandardUtf82 WHERE KEY = k1")
+        d = cursor.description
+        assert d[1][0] == u"¢", d[1][0]
+        assert d[2][0] == u"©", d[2][0]
+        assert d[3][0] == u"®", d[3][0]
+        assert d[4][0] == u"¿", d[4][0]
+
+        cursor.execute("SELECT :start..'' FROM StandardUtf82 WHERE KEY = k1", dict(start="©"))
+        r = cursor.fetchone()
+        assert len(r) == 4
+        d = cursor.description
+        assert d[1][0] == u"©"
+        assert d[2][0] == u"®"
+        assert d[3][0] == u"¿"
+
     def test_read_write_negative_numerics(self):
         "reading and writing negative numeric values"
-        conn = init()
+        cursor = init()
         for cf in ("StandardIntegerA", "StandardLongA"):
             for i in range(10):
-                conn.execute("UPDATE ? SET ? = ? WHERE KEY = negatives;",
-                             cf,
-                             -(i + 1),
-                             i)
-            r = conn.execute("SELECT ?..? FROM ? WHERE KEY = negatives;",
-                             -10,
-                             -1,
-                             cf)
-            assert len(r[0]) == 10, \
-                "returned %d columns, expected %d" % (len(r[0]), 10)
-            assert r[0][0].name == -10
-            assert r[0][9].name == -1
-            
+                cursor.execute("UPDATE :cf SET :name = :val WHERE KEY = negatives;",
+                               dict(cf=cf, name=-(i + 1), val=i))
+
+            cursor.execute("SELECT :start..:finish FROM :cf WHERE KEY = negatives;",
+                           dict(start=-10, finish=-1, cf=cf))
+            r = cursor.fetchone()
+            assert len(r) == 11, \
+                "returned %d columns, expected %d" % (len(r) - 1, 10)
+            d = cursor.description
+            assert d[1][0] == -10
+            assert d[10][0] == -1
+
     def test_escaped_quotes(self):
         "reading and writing strings w/ escaped quotes"
-        conn = init()
-        
-        conn.execute("""
-            UPDATE StandardString1 SET 'x''and''y' = z WHERE KEY = ?
-        """, "test_escaped_quotes")
-                     
-        r = conn.execute("""
-            SELECT 'x''and''y' FROM StandardString1 WHERE KEY = ?
-        """, "test_escaped_quotes")
-        assert (len(r) == 1) and (len(r[0]) == 1), "wrong number of results"
-        assert r[0][0].name == "x\'and\'y"
-        
+        cursor = init()
+
+        cursor.execute("""
+                       UPDATE StandardString1 SET 'x''and''y' = z WHERE KEY = :key
+                       """, dict(key="test_escaped_quotes"))
+
+        cursor.execute("""
+                       SELECT 'x''and''y' FROM StandardString1 WHERE KEY = :key
+                       """, dict(key="test_escaped_quotes"))
+        assert cursor.rowcount == 1
+        r = cursor.fetchone()
+        assert len(r) == 2, "wrong number of results"
+        d = cursor.description
+        assert d[1][0] == "x\'and\'y"
+
     def test_typed_keys(self):
         "using typed keys"
-        conn = init()
-        r = conn.execute("SELECT * FROM StandardString1 WHERE KEY = ?", "ka")
-        assert isinstance(r[0].key, unicode), \
-            "wrong key-type returned, expected unicode, got %s" % type(r[0].key)
-        
+        cursor = init()
+        cursor.execute("SELECT * FROM StandardString1 WHERE KEY = :key", dict(key="ka"))
+        r = cursor.fetchone()
+        assert isinstance(r[0], unicode), \
+            "wrong key-type returned, expected unicode, got %s" % type(r[0])
+
         # FIXME: The above is woefully inadequate, but the test config uses
         # CollatingOrderPreservingPartitioner which only supports UTF8.
-        
+
     def test_write_using_insert(self):
         "peforming writes using \"insert\""
-        conn = init()
-        conn.execute("INSERT INTO StandardUtf82 (KEY, ?, ?) VALUES (?, ?, ?)",
-                     "pork",
-                     "beef",
-                     "meat",
-                     "bacon",
-                     "brisket")
-        
-        r = conn.execute("SELECT * FROM StandardUtf82 WHERE KEY = ?", "meat")
-        assert r[0][0].name == "beef"
-        assert r[0][0].value == "brisket"
-        assert r[0][1].name == "pork"
-        assert r[0][1].value == "bacon"
-        
+        cursor = init()
+        cursor.execute("INSERT INTO StandardUtf82 (KEY, :c1, :c2) VALUES (:key, :v1, :v2)", 
+                       dict(c1="pork", c2="beef", key="meat", v1="bacon", v2="brisket"))
+
+        cursor.execute("SELECT * FROM StandardUtf82 WHERE KEY = :key", dict(key="meat"))
+        r = cursor.fetchone()
+        d = cursor.description
+        assert d[1][0] == "beef"
+        assert r[1] == "brisket"
+
+        assert d[2][0] == "pork"
+        assert r[2] == "bacon"
+
         # Bad writes.
-        
+
         # Too many column values
-        assert_raises(CQLException,
-                      conn.execute,
-                      "INSERT INTO StandardUtf82 (KEY, ?) VALUES (?, ?, ?)",
-                      "name1",
-                      "key0",
-                      "value1",
-                      "value2")
-                      
+        assert_raises(cql.ProgrammingError,
+                      cursor.execute,
+                      "INSERT INTO StandardUtf82 (KEY, :c1) VALUES (:key, :v1, :v2)",
+                      dict(c1="name1", key="key0", v1="value1", v2="value2"))
+
         # Too many column names, (not enough column values)
-        assert_raises(CQLException,
-                      conn.execute,
-                      "INSERT INTO StandardUtf82 (KEY, ?, ?) VALUES (?, ?)",
-                      "name1",
-                      "name2",
-                      "key0",
-                      "value1")
-                      
+        assert_raises(cql.ProgrammingError,
+                      cursor.execute,
+                      "INSERT INTO StandardUtf82 (KEY, :c1, :c2) VALUES (:key, :v1)",
+                      dict(c1="name1", c2="name2", key="key0", v1="value1"))
+
     def test_compression_disabled(self):
         "reading and writing w/ compression disabled"
-        conn = init()
-        conn.execute("UPDATE StandardString1 SET ? = ? WHERE KEY = ?",
-                     "some_name",
-                     "some_value",
-                     "compression_test",
-                     compression='NONE')
-                     
-        r = conn.execute("SELECT ? FROM StandardString1 WHERE KEY = ?",
-                         "some_name",
-                         "compression_test",
-                         compression='NONE')
-                         
-        assert len(r) == 1, "expected 1 result, got %d" % len(r)
-        assert r[0][0].name == "some_name", \
-                "unrecognized name '%s'" % r[0][0].name
-        assert r[0][0].value == "some_value", \
-                "unrecognized value '%s'" % r[0][0].value
+        cursor = init()
+        cursor.compression = 'NONE'
+        cursor.execute("UPDATE StandardString1 SET :name = :val WHERE KEY = :key",
+                        dict(name="some_name", val="some_value", key="compression_test"))
+
+        cursor.execute("SELECT :name FROM StandardString1 WHERE KEY = :key",
+                       dict(name="some_name", key="compression_test"))
+
+        assert cursor.rowcount == 1, "expected 1 result, got %d" % cursor.rowcount
+        colnames = [col_d[0] for col_d in cursor.description]
+        assert colnames[1] == "some_name", \
+               "unrecognized name '%s'" % colnames[1]
+        r = cursor.fetchone()
+        assert r[1] == "some_value", \
+               "unrecognized value '%s'" % r[1]

Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java Fri Apr 15 12:48:15 2011
@@ -27,9 +27,7 @@ import java.io.*;
 import java.nio.ByteBuffer;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
-import java.util.HashSet;
 import java.util.Collection;
-import java.util.Set;
 import java.util.concurrent.ExecutionException;
 
 import org.apache.cassandra.CleanupHelper;
@@ -309,7 +307,7 @@ public class LazilyCompactedRowTest exte
     {
         public LazyCompactionIterator(Iterable<SSTableReader> sstables, CompactionController controller) throws IOException
         {
-            super("Lazy", sstables, controller);
+            super(CompactionType.UNKNOWN, sstables, controller);
         }
 
         @Override
@@ -323,7 +321,7 @@ public class LazilyCompactedRowTest exte
     {
         public PreCompactingIterator(Iterable<SSTableReader> sstables, CompactionController controller) throws IOException
         {
-            super("Pre", sstables, controller);
+            super(CompactionType.UNKNOWN, sstables, controller);
         }
 
         @Override

Modified: cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/Session.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/Session.java?rev=1092687&r1=1092686&r2=1092687&view=diff
==============================================================================
--- cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/Session.java (original)
+++ cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/Session.java Fri Apr 15 12:48:15 2011
@@ -229,9 +229,6 @@ public class Session
             if (cmd.hasOption("g"))
                 keysPerCall = Integer.parseInt(cmd.getOptionValue("g"));
 
-            if (cmd.hasOption("l"))
-                replicationStrategyOptions.put("replication_factor", String.valueOf(Integer.parseInt(cmd.getOptionValue("l"))));
-
             if (cmd.hasOption("e"))
                 consistencyLevel = ConsistencyLevel.valueOf(cmd.getOptionValue("e").toUpperCase());
 
@@ -241,6 +238,11 @@ public class Session
             if (cmd.hasOption("R"))
                 replicationStrategy = cmd.getOptionValue("R");
 
+            if (cmd.hasOption("l"))
+                replicationStrategyOptions.put("replication_factor", String.valueOf(Integer.parseInt(cmd.getOptionValue("l"))));
+            else if (replicationStrategy.endsWith("SimpleStrategy"))
+                replicationStrategyOptions.put("replication_factor", "1");
+
             if (cmd.hasOption("O"))
             {
                 String[] pairs = StringUtils.split(cmd.getOptionValue("O"), ',');
@@ -421,19 +423,18 @@ public class Session
 
         keyspace.setCf_defs(new ArrayList<CfDef>(Arrays.asList(standardCfDef, superCfDef, counterCfDef, counterSuperCfDef)));
 
-
         Cassandra.Client client = getClient(false);
 
         try
         {
             client.system_add_keyspace(keyspace);
             out.println(String.format("Created keyspaces. Sleeping %ss for propagation.", nodes.length));
-
             Thread.sleep(nodes.length * 1000); // seconds
         }
         catch (InvalidRequestException e)
         {
-            out.println(e.getWhy());
+            out.println("Unable to create stress keyspace: " + e.getWhy());
+            System.exit(1);
         }
         catch (Exception e)
         {



Mime
View raw message