0
有沒有一種方法來創建和使用下面的系列列Astyanax:如何使用靜態列從astyanax
CREATE TABLE mytest (id text, subid text, clustering text, static_value text static, value text, PRIMARY KEY((id, subid), clustering));
如果不是,有什麼靜態列的最佳選擇?
有沒有一種方法來創建和使用下面的系列列Astyanax:如何使用靜態列從astyanax
CREATE TABLE mytest (id text, subid text, clustering text, static_value text static, value text, PRIMARY KEY((id, subid), clustering));
如果不是,有什麼靜態列的最佳選擇?
的Astyanax Getting Started節包含如何通過註釋重點領域的「序」的關鍵字,以確保正確的序列化部分:
// Annotated composite class
Class SessionEvent{
private @Component(ordinal=0) String sessiondId;
private @Component(ordinal=1) UUID timestamp;
public SessionEvent() {
}
public int hashCode() { ... }
public boolean equals(Object o) { ... }
public int compareTo(Object o) { ... }
}
否則,Astyanax回購也有an example showing how to work directly with CQL3。要創建CF:
String CREATE_STATEMENT = "CREATE TABLE mytest (id text, subid text, clustering text, static_value text static, value text, PRIMARY KEY((id, subid), clustering))";
try {
@SuppressWarnings("unused")
OperationResult<CqlResult<Integer, String>> result = keyspace
.prepareQuery(EMP_CF)
.withCql(CREATE_STATEMENT)
.execute();
} catch (ConnectionException e) {
logger.error("failed to create CF", e);
throw new RuntimeException("failed to create CF", e);
}
以上(CQL3)鏈接還包含演示閱讀和插入,以及示例方法。
是的,有一種方法可以使用組合列,但複合行鍵呢?我意識到我可以使用blob,並自己寫作,只是好奇。還有什麼關於靜態列?我可以使用sql語句創建,但後來我將不得不使用cql來插入等等。它是否正確? – efan 2014-09-04 14:38:47
ColumnList類上有一個「getColumnByName」方法,該方法應該與靜態列一起工作。我認爲他們有辦法讓你通過複合分區鍵讀取。老實說,我有一段時間沒有使用Astyanax,所以我不確定它是如何更新以利用Cassandra 2.x的一些新功能的。所以如果你想確保你可以通過複合分區鍵(id,subid)來訪問,那麼使用CQL可能是你最好的選擇。 – Aaron 2014-09-04 14:46:14