Search code examples
cassandrahector

how to count the rows in cassandra column family


I'm writing a file with user profiles into cassandra with 5M profiles. My write operation finished sucessfully. I want to count the number of rows in my column family.

Keyspace keyspaceOperator = HFactory.createKeyspace(KEY_SPACE, cluster);
CqlQuery<String,String,Long> cqlQuery = new CqlQuery<String,String,Long>(keyspaceOperator, se, se, new LongSerializer());
cqlQuery.setQuery("SELECT COUNT(*) FROM up");
QueryResult<CqlRows<String,String,Long>> result = cqlQuery.execute();
System.out.println(result.get().getAsCount());

But the following code prints me always 10000. What am I doing wrong? And how can I make this operation from cli?


Solution

  • You can't for now. There's a default limit of 10K rows per query. There's an open ticket for this (CASSANDRA-3702) but no fix as of yet.