Hello!!
i am using apache-cassandra-incubating-0.4.0-rc2 with java driver. The
following sequence of operations failed:
1. insert key 'k' into a columnfamily 'cf' with column 'c' and value 'x'
for time 't'
2. remove column 'c' from columnfamily 'cf' of key 'k'
3. insert key 'k' into a columnfamily 'cf' with column 'c' and value 'x'
for time 't' (same time as step 1)
4. get value of column 'c' from columnfamily 'cf' of key 'k' (this step
fails)
herewith we have attached a JUnit testcase for the above scenario.
any clues???
--
Ranjan Kumar
import java.text.ParseException;
import org.apache.cassandra.service.ColumnOrSuperColumn;
import org.apache.cassandra.service.ColumnPath;
import org.apache.cassandra.service.InvalidRequestException;
import org.apache.cassandra.service.NotFoundException;
import org.apache.cassandra.service.UnavailableException;
import org.apache.cassandra.service.Cassandra.Client;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import com.bitstat.timedb.DateUtil;
import junit.framework.TestCase;
public class TestRemoveIssue extends TestCase{
public void testRemove() throws Exception {
TTransport tr = new TSocket("localhost", 9160);
TProtocol proto = new TBinaryProtocol(tr);
Client client = new Client(proto);
try {
tr.open();
String keyspace = "Keyspace1";
String columnFamily = "Standard1";
String columnKey = "cKey";
String columnName = "cName";
String columnValue = "cValue";
ColumnPath columnPath = new ColumnPath(columnFamily, null, columnName.getBytes());
long time = System.currentTimeMillis();
client.insert(keyspace, columnKey, columnPath, columnValue.getBytes(), time, 0);
ColumnOrSuperColumn columnOrSuperColumn = client.get(keyspace, columnKey, columnPath, 1);
assertEquals(columnValue, new String(columnOrSuperColumn.getColumn().getValue()));
client.remove(keyspace, columnKey, columnPath, time, 0);
try {
client.get(keyspace, columnKey, columnPath, 1);
fail();
}catch(NotFoundException e) {
}
client.insert(keyspace, columnKey, columnPath, columnValue.getBytes(), time, 0);
columnOrSuperColumn = client.get(keyspace, columnKey, columnPath, 1);
assertEquals(columnValue, new String(columnOrSuperColumn.getColumn().getValue()));
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
tr.close();
}
}
}