me.prettyprint.cassandra.model
Class CqlQuery<K,N,V>

java.lang.Object
  extended by me.prettyprint.cassandra.model.AbstractBasicQuery<K,N,CqlRows<K,N,V>>
      extended by me.prettyprint.cassandra.model.CqlQuery<K,N,V>
All Implemented Interfaces:
Query<CqlRows<K,N,V>>

public class CqlQuery<K,N,V>
extends AbstractBasicQuery<K,N,CqlRows<K,N,V>>

First cut at a CQL implementation. Not too much time has been spent here as this API is currently a moving target. We have a lot of experience with these hijinks by the Apache Cassandra team, so it was deemed prudent to do something simple initially until the dust settles. You are expected to know what you are getting into if you plan on using CQL queries in your application. Spend some time looking through the unit tests here in Hector and the Cassandra source tree. For a number of detailed examples, see test_cql.py in the test/system folder of the Apache Cassandra source distribution. Note: if you immediately get an exception such as: "InvalidRequestException(why:cannot parse 'foo' as hex bytes)" It means one of two things:

  1. you have not formatted your query correct
  2. You have not configured the correct validators on your column family
In both cases, even though the query is most likely a string, it is up to you to format this query according to the comparator (used for the column name), key validator and value validator. This can be a little confusing as only the comparator is required. The other two default to BytesType. See the docs on CqlRows for additional details.

Author:
zznate

Field Summary
 
Fields inherited from class me.prettyprint.cassandra.model.AbstractBasicQuery
columnFamilyName, columnNameSerializer, keySerializer, keyspace
 
Constructor Summary
CqlQuery(Keyspace k, Serializer<K> keySerializer, Serializer<N> nameSerializer, Serializer<V> valueSerializer)
           
 
Method Summary
 QueryResult<CqlRows<K,N,V>> execute()
           
 CqlQuery<K,N,V> setQuery(ByteBuffer qeury)
           
 CqlQuery<K,N,V> setQuery(String query)
          Set the query as a String.
 CqlQuery<K,N,V> useCompression()
           
 
Methods inherited from class me.prettyprint.cassandra.model.AbstractBasicQuery
getColumnNameSerializer, getKeySerializer, setColumnFamily, setColumnNameSerializer, setKeySerializer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CqlQuery

public CqlQuery(Keyspace k,
                Serializer<K> keySerializer,
                Serializer<N> nameSerializer,
                Serializer<V> valueSerializer)
Method Detail

setQuery

public CqlQuery<K,N,V> setQuery(String query)
Set the query as a String. Here for convienience. See above for some caveats. Calls StringSerializer.toByteBuffer(String) directly.

Parameters:
query -
Returns:

setQuery

public CqlQuery<K,N,V> setQuery(ByteBuffer qeury)

useCompression

public CqlQuery<K,N,V> useCompression()

execute

public QueryResult<CqlRows<K,N,V>> execute()


Copyright © 2011. All Rights Reserved.