me.prettyprint.cassandra.model
Class HSlicePredicate<N>

java.lang.Object
  extended by me.prettyprint.cassandra.model.HSlicePredicate<N>

public final class HSlicePredicate<N>
extends Object

Hector's version of cassandra SlicePredicate

Author:
Ran Tavory, zznate

Nested Class Summary
protected static class HSlicePredicate.PredicateType
           
 
Field Summary
protected  Collection<N> columnNames
           
protected  Serializer<N> columnNameSerializer
           
protected  int count
           
protected  N finish
           
protected  HSlicePredicate.PredicateType predicateType
           
protected  boolean reversed
           
protected  N start
           
 
Constructor Summary
HSlicePredicate(Serializer<N> columnNameSerializer)
           
 
Method Summary
 HSlicePredicate<N> addColumnName(N columnName)
           
 Collection<N> getColumnNames()
           
 HSlicePredicate<N> setColumnNames(Collection<N> columnNames)
          Same as varargs signature, except we take a collection
 HSlicePredicate<N> setColumnNames(N... columnNames)
          Sets the column names to be retrieved by this query
 HSlicePredicate<N> setCount(int count)
          Set the number of columns to return for this slice Switches to HSlicePredicate.PredicateType.Range
 HSlicePredicate<N> setEndOn(N finish)
          Set the columnName on which we will end.
 HSlicePredicate<N> setKeysOnlyPredicate()
          Allows the use of returning just the keys.
 HSlicePredicate<N> setRange(N start, N finish, boolean reversed, int count)
          Set a predicate of start/finish to retrieve a list of columns in this range.
 HSlicePredicate<N> setReversed(boolean reversed)
          Sets the return order of the columns to be reversed.
 HSlicePredicate<N> setStartOn(N start)
          Set the columnName on which we will start.
 String toString()
           
 org.apache.cassandra.thrift.SlicePredicate toThrift()
          Will throw a runtime exception if neither columnsNames nor count were set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

columnNames

protected Collection<N> columnNames

start

protected N start

finish

protected N finish

reversed

protected boolean reversed

count

protected int count

columnNameSerializer

protected final Serializer<N> columnNameSerializer

predicateType

protected HSlicePredicate.PredicateType predicateType
Constructor Detail

HSlicePredicate

public HSlicePredicate(Serializer<N> columnNameSerializer)
Method Detail

setColumnNames

public HSlicePredicate<N> setColumnNames(N... columnNames)
Sets the column names to be retrieved by this query

Parameters:
columns - a list of column names

addColumnName

public HSlicePredicate<N> addColumnName(N columnName)

setColumnNames

public HSlicePredicate<N> setColumnNames(Collection<N> columnNames)
Same as varargs signature, except we take a collection

Parameters:
columns - a list of column names

setKeysOnlyPredicate

public HSlicePredicate<N> setKeysOnlyPredicate()
Allows the use of returning just the keys. This avoids de-serialization of row data and can be a huge optimization in some use cases


setStartOn

public HSlicePredicate<N> setStartOn(N start)
Set the columnName on which we will start. Switches to HSlicePredicate.PredicateType.Range


setEndOn

public HSlicePredicate<N> setEndOn(N finish)
Set the columnName on which we will end. Switches to HSlicePredicate.PredicateType.Range


setCount

public HSlicePredicate<N> setCount(int count)
Set the number of columns to return for this slice Switches to HSlicePredicate.PredicateType.Range


setReversed

public HSlicePredicate<N> setReversed(boolean reversed)
Sets the return order of the columns to be reversed. NOTE: this is slightly less efficient than reading in comparator order. Switches to HSlicePredicate.PredicateType.Range


setRange

public HSlicePredicate<N> setRange(N start,
                                   N finish,
                                   boolean reversed,
                                   int count)
Set a predicate of start/finish to retrieve a list of columns in this range. Either start and or finish can be null which will toggle the underlying predicate to use an empty byte[]

Parameters:
start - Start key
finish - End key
reversed -
count -
Returns:

getColumnNames

public Collection<N> getColumnNames()

toThrift

public org.apache.cassandra.thrift.SlicePredicate toThrift()
Will throw a runtime exception if neither columnsNames nor count were set.

Returns:

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.