I wrote the following code in Astyanax AllRowsReader receipt
object CassandraScanner extends App with CassandraHelper {
val context = getContext("movielens_small")
val cf = new ColumnFamily[UUID, String]("movielens_small", UUIDSerializer.get, StringSerializer.get)
val keyspace = context.getClient
var count : AtomicInteger = new AtomicInteger(0)
val allReader = new AllRowsReader.Builder(keyspace, cf)
.withPageSize(100)
.withConcurrencyLevel(10)
.withPartitioner(null)
.forEachRow { case row : Row[UUID, String] =>
val cols = row.getColumns
val movieName = cols.getColumnByName("name")
val movieNameVal = movieName.getStringValue
count.incrementAndGet()
true
}
.build()
.call()
println(s"Total value ${count.get()}")
}
This code however throws and exception
18:12:22,759 INFO ThriftKeyspaceImpl:745 - Detected partitioner org.apache.cassandra.dht.Murmur3Partitioner for keyspace movielens_small
18:12:22,820 ERROR AllRowsReader:524 - Error process token/key range
com.netflix.astyanax.connectionpool.exceptions.BadRequestException: BadRequestException: [host=192.168.1.169(192.168.1.169):9160, latency=32(32), attempts=1]InvalidRequestException(why:unconfigured table movielens_small)
at com.netflix.astyanax.thrift.ThriftConverter.ToConnectionPoolException(ThriftConverter.java:159)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:65)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:28)
at com.netflix.astyanax.thrift.ThriftSyncConnectionFactoryImpl$ThriftConnection.execute(ThriftSyncConnectionFactoryImpl.java:153)
at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:119)
at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:352)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$2.execute(ThriftColumnFamilyQueryImpl.java:397)
at com.netflix.astyanax.recipes.reader.AllRowsReader$1.call(AllRowsReader.java:447)
at com.netflix.astyanax.recipes.reader.AllRowsReader$1.call(AllRowsReader.java:419)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: InvalidRequestException(why:unconfigured table movielens_small)
at org.apache.cassandra.thrift.Cassandra$get_range_slices_result$get_range_slices_resultStandardScheme.read(Cassandra.java:17430)
at org.apache.cassandra.thrift.Cassandra$get_range_slices_result$get_range_slices_resultStandardScheme.read(Cassandra.java:17397)
at org.apache.cassandra.thrift.Cassandra$get_range_slices_result.read(Cassandra.java:17323)
I was able to resolve the issue. The problem was with the line
here the name of the column family must be the name of the table we are scanning. So in my case it was "movies". (movielens_small is the name of my keyspace ... not column family).
So the working line is
when I made this change, i was able to scan the table easily.