public interface

AllRowsQuery

implements Execution<R>
com.netflix.astyanax.query.AllRowsQuery<K, C>
Known Indirect Subclasses

Class Overview

Specialized query to iterate the contents of a column family. ColumnFamily CF_STANDARD1 = new ColumnFamily("Standard1", StringSerializer.get(), StringSerializer.get()); Iterator> iter = keyspace.prepareQuery(MockConstants.CF_STANDARD1).iterator(); while (iter.hasNext()) { Row row = iter.next(); LOG.info("ROW: " + row.getKey()); } The iterator is implemented by making 'paginated' queries to Cassandra with each query returning up to a the block size set by setBlockSize (default is 10). The incremental query is hidden from the caller thereby providing a virtual view into the column family. There are a few important implementation details that need to be considered. This implementation assumes the random partitioner is used. Consequently the KeyRange query is done using tokens and not row keys. This is done because when using the random partitioner tokens are sorted while keys are not. However, because multiple keys could potentially map to the same token each incremental query to Cassandra will repeat the last token from the previous response. This will ensure that no keys are skipped. This does however have to very important implications. First, the last and potentially more (if they have the same token) row keys from the previous response will repeat. Second, if a range of repeating tokens is larger than the block size then the code will enter an infinite loop. This can be mitigated by selecting a block size that is large enough so that the likelyhood of this happening is very low. Also, if your application can tolerate the potential for skipped row keys then call setRepeatLastToken(false) to turn off this features.

Summary

Public Methods
abstract void executeWithCallback(RowCallback<K, C> callback)
Execute the operation in a separate thread for each token range and provide the results in a callback.@return
abstract AllRowsQuery<K, C> setBlockSize(int blockSize)
This method is deprecated. Use setRowLimit instead
abstract AllRowsQuery<K, C> setConcurrencyLevel(int numberOfThreads)
Split the query into N threads with each thread processing an equal size chunk from the token range.
abstract AllRowsQuery<K, C> setExceptionCallback(ExceptionCallback cb)
Sets the exception handler to use when handling exceptions inside Iterator.next().
abstract AllRowsQuery<K, C> setRepeatLastToken(boolean repeatLastToken)
If true will repeat the last token in the previous block.
abstract AllRowsQuery<K, C> setRowLimit(int rowLimit)
Maximum number of rows to return for each incremental query to Cassandra.
abstract AllRowsQuery<K, C> setThreadCount(int numberOfThreads)
abstract AllRowsQuery<K, C> withColumnRange(C startColumn, C endColumn, boolean reversed, int count)
Specify a range of columns to return.
abstract AllRowsQuery<K, C> withColumnRange(ByteBufferRange range)
Specify a range of composite columns.
abstract AllRowsQuery<K, C> withColumnRange(ByteBuffer startColumn, ByteBuffer endColumn, boolean reversed, int count)
Specify a range and provide pre-constructed start and end columns.
abstract AllRowsQuery<K, C> withColumnSlice(C... columns)
Specify a non-contiguous set of columns to retrieve.
abstract AllRowsQuery<K, C> withColumnSlice(Collection<C> columns)
Specify a non-contiguous set of columns to retrieve.
abstract AllRowsQuery<K, C> withColumnSlice(ColumnSlice<C> columns)
Use this when your application caches the column slice.
[Expand]
Inherited Methods
From interface com.netflix.astyanax.Execution

Public Methods

public abstract void executeWithCallback (RowCallback<K, C> callback)

Execute the operation in a separate thread for each token range and provide the results in a callback.@return

public abstract AllRowsQuery<K, C> setBlockSize (int blockSize)

This method is deprecated.
Use setRowLimit instead

public abstract AllRowsQuery<K, C> setConcurrencyLevel (int numberOfThreads)

Split the query into N threads with each thread processing an equal size chunk from the token range. Note that the actual number of threads is still limited by the available threads in the thread pool that was set with the AstyanaxConfiguration.

public abstract AllRowsQuery<K, C> setExceptionCallback (ExceptionCallback cb)

Sets the exception handler to use when handling exceptions inside Iterator.next(). This gives the caller a chance to implement a backoff strategy or stop the iteration.

public abstract AllRowsQuery<K, C> setRepeatLastToken (boolean repeatLastToken)

If true will repeat the last token in the previous block.

public abstract AllRowsQuery<K, C> setRowLimit (int rowLimit)

Maximum number of rows to return for each incremental query to Cassandra. This limit also represents the page size when paginating.

public abstract AllRowsQuery<K, C> setThreadCount (int numberOfThreads)

public abstract AllRowsQuery<K, C> withColumnRange (C startColumn, C endColumn, boolean reversed, int count)

Specify a range of columns to return.

Parameters
startColumn First column in the range
endColumn Last column in the range
reversed True if the order should be reversed. Note that for reversed, startColumn should be greater than endColumn.
count Maximum number of columns to return (similar to SQL LIMIT)

public abstract AllRowsQuery<K, C> withColumnRange (ByteBufferRange range)

Specify a range of composite columns. Use this in conjunction with the AnnotatedCompositeSerializer.buildRange().

public abstract AllRowsQuery<K, C> withColumnRange (ByteBuffer startColumn, ByteBuffer endColumn, boolean reversed, int count)

Specify a range and provide pre-constructed start and end columns. Use this with Composite columns

public abstract AllRowsQuery<K, C> withColumnSlice (C... columns)

Specify a non-contiguous set of columns to retrieve.

public abstract AllRowsQuery<K, C> withColumnSlice (Collection<C> columns)

Specify a non-contiguous set of columns to retrieve.

public abstract AllRowsQuery<K, C> withColumnSlice (ColumnSlice<C> columns)

Use this when your application caches the column slice.