我正在尝试获取Cassandra列族中键值对的数量。以下是我使用的代码。
PreparedStatement statement = client.session
.prepare("select count(*) from corpus.word_usage");
ResultSet results = client.session.execute(statement.bind());
Row row = results.one();
System.out.println(row.getVarint(0));
但是当我运行这段代码时,我得到了以下异常。
Exception in thread "main" com.datastax.driver.core.exceptions.InvalidTypeException: Column count is of type bigint
at com.datastax.driver.core.ColumnDefinitions.checkType(ColumnDefinitions.java:291)
at com.datastax.driver.core.ArrayBackedRow.getVarint(ArrayBackedRow.java:185)
at SimpleClient.main(SimpleClient.java:57)
根据DataStax文档(http://www.datastax.com/drivers/java/2.0/com/datastax/driver/core/Row.html),getVarint应该返回一个BigInteger。那么为什么我在这里会得到一个异常?我做错了什么?