3
我正在使用Cassandra 1.2.5和二級索引。當我運行準備語句時,沒有數據返回。我有數據。也爲索引列我有重複的值。我正在做的是根據user_id重新調整video_id列表。表格描述如下: [default @ video]描述視頻;Cassandra Datastax驅動程序沒有通過返回行準備
警告:CQL3表格有意從'describe'輸出中省略。 有關詳細信息,請參閱https://issues.apache.org/jira/browse/CASSANDRA-4377。
ColumnFamily: videos
Key Validation Class: org.apache.cassandra.db.marshal.IntegerType
Default column value validator: org.apache.cassandra.db.marshal.IntegerType
Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type
GC grace seconds: 864000
Compaction min/max thresholds: 4/32
Read repair chance: 0.1
DC Local Read repair chance: 0.0
Populate IO Cache on flush: false
Replicate on write: true
Caching: ALL
Bloom Filter FP chance: default
Built indexes: [videos.videos_user_id_idx]
Column Metadata:
Column Name: video_id
Validation Class: org.apache.cassandra.db.marshal.IntegerType
Column Name: user_id
Validation Class: org.apache.cassandra.db.marshal.IntegerType
Index Name: videos_user_id_idx
Index Type: KEYS
Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
Compression Options:
sstable_compression: org.apache.cassandra.io.compress.SnappyCompressor
我的代碼如下所示: int concurrency = 3; // final BoundStatement query = null; 嘗試創建會話到主機 Cluster cluster = new Cluster.Builder()。addContactPoints(String.valueOf(「localhost」))。build();
// final int maxRequestsPerConnection = 10;
// int maxConnections = concurrency/maxRequestsPerConnection + 1;
int maxConnections = 3;
PoolingOptions pools = cluster.getConfiguration().getPoolingOptions();
pools.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, concurrency);
pools.setCoreConnectionsPerHost(HostDistance.LOCAL, maxConnections);
pools.setMaxConnectionsPerHost(HostDistance.LOCAL, maxConnections);
pools.setCoreConnectionsPerHost(HostDistance.REMOTE, maxConnections);
pools.setMaxConnectionsPerHost(HostDistance.REMOTE, maxConnections);
Session session = cluster.connect();
//get list of video ids
String cql1 = "SELECT video_id from video.videos WHERE user_id=?";
com.datastax.driver.core.PreparedStatement stmt = session.prepare(cql1);
BoundStatement b = stmt.bind();
BigInteger i = BigInteger.valueOf(9);
b.setVarint("user_id",i);
long start, end;
start = System.nanoTime();
com.datastax.driver.core.ResultSet rs1 = session.execute(b);
end = System.nanoTime();
System.out.println("Datastax driver CQL Query prepared overall time ns:"
+ (end - start));
while(rs1.iterator().hasNext()) {
System.out.println("user_id:" + rs1.iterator().next().getVarint("video_id"));
}
請注意,即使我更改語句以替換?值爲9我仍然沒有返回行。
任何想法我做錯了什麼?
感謝, 託尼