Good Day
I have this table created on my cassandra 2.0 im trying to read and write with it using astyanax but unfortunately im really new to cassandra and java
create table requestformatlist (
usedbyid text, // rowkey
rfid text , // rfid
keystoadd Set<text>,
keystoremove Set<text>,
primary key (usedbyid, rfid) );
table contents
gid | rfid | keystoadd | keystoremove
------+------+----------------------------------+----------------------------
1111 | 1111 | {'AddMe1', 'AddMe2'} | {'RemoveMe1', 'RemoveMe2'}
0003 | 0003 | {'address', 'name', 'state'} | {'z1', 'z2', 'z3'}
I have read this but unfortunately Im confused why do we need two writes if we want to add just one row
http://brianoneill.blogspot.com/2012/09/composite-keys-connecting-dots-between.html http://brianoneill.blogspot.com/2012/10/cql-astyanax-and-compoundcomposite-keys.html
i have the astyanaxdao and i could connect with it but cannot read and write to it
i have the following code
public void testRead() throws Exception {
RequestFormatDAO dao = new RequestFormatDAO("localhost:9160", "l2");
log(dao.read("0003"));
}
public ColumnList<RequestFormatListEntry> read(String rowKey) throws ConnectionException {
OperationResult<ColumnList<RequestFormatListEntry>> result = this.getKeyspace().prepareQuery(COLUMN_FAMILY).getKey(rowKey)
.execute();
ColumnList<RequestFormatListEntry> requestFormat = result.getResult();
LOG.debug("Read list [" + rowKey + "]");
return requestFormat;
}
public class RequestFormatListEntry {
@Component(ordinal = 0)
public String rfid;
@Component(ordinal = 1)
public String field1;
public RequestFormatListEntry(){}
}
Results that I have on Read:
Read list [0003]
listEntry.rfid=>[0003]
listEntry.keystoremove=>[null]
listEntry.rfid=>[0003]
listEntry.keystoremove=>[keystoadd]
listEntry.rfid=>[0003]
listEntry.keystoremove=>[keystoadd]
listEntry.rfid=>[0003]
listEntry.keystoremove=>[keystoadd]
listEntry.rfid=>[0003]
listEntry.keystoremove=>[keystoremove]
listEntry.rfid=>[0003]
listEntry.keystoremove=>[keystoremove]
listEntry.rfid=>[0003]
listEntry.keystoremove=>[keystoremove]