CORRECTION:
ColumnPath cp1 = new ColumnPath("Super2");
cp1.setSuper_column("Best Western".getBytes());
cp1.setColumn("name".getBytes());
client.insert(KEYSPACE, "hotel", cp1, "Best Western of SF".getBytes(),
System.currentTimeMillis(), ConsistencyLevel.ALL);
-----Original Message-----
From: Peter Minearo [mailto:[email protected]]
Sent: Friday, July 23, 2010 2:14 PM
To: [email protected]
Subject: RE: CRUD test
Interesting!! Let me rephrase to make sure I understood what is going on:
When Inserting data via the "insert" function/method:
void insert(string keyspace, string key, ColumnPath column_path, binary value,
i64 timestamp, ConsistencyLevel consistency_level)
The "key" parameter is the actual Key to the "Row", which contains
SuperColumns. The 'ColumnPath' gives the path within the Key.
INCORRECT:
ColumnPath cp1 = new ColumnPath("Super2");
cp1.setSuper_column("hotel".getBytes());
cp1.setColumn("Best Western".getBytes()); client.insert(KEYSPACE, "name", cp1,
"Best Western of SF".getBytes(), System.currentTimeMillis(),
ConsistencyLevel.ALL);
CORRECT:
ColumnPath cp1 = new ColumnPath("Super2");
cp1.setSuper_column("name".getBytes());
cp1.setColumn("Best Western".getBytes()); client.insert(KEYSPACE, "hotel", cp1,
"Best Western of SF".getBytes(), System.currentTimeMillis(),
ConsistencyLevel.ALL);
-----Original Message-----
From: Jonathan Shook [mailto:[email protected]]
Sent: Friday, July 23, 2010 1:49 PM
To: [email protected]
Subject: Re: CRUD test
Correct.
After the initial insert,
cassandra> get Keyspace1.Super2['name']
=> (super_column=hotel,
(column=Best Western, value=Best Western of SF, timestamp=1279916772571)
(column=Econolodge, value=Econolodge of SF, timestamp=1279916772573))
Returned 1 results.
... and ...
cassandra> get Keyspace1.Super2['hotel']
Returned 0 results.
On Fri, Jul 23, 2010 at 3:41 PM, Peter Minearo
<[email protected]> wrote:
> The Model Should look like:
>
>
> Super2 = {
> hotel: {
> Best Western: {name: "Best Western of SF"}
> Econolodge: {name: "Econolodge of SF"}
> }
> }
>
> Are the CRUD Operations not referencing this correctly?
>
>
>
> -----Original Message-----
> From: Jonathan Shook [mailto:[email protected]]
> Sent: Friday, July 23, 2010 1:34 PM
> To: [email protected]
> Subject: Re: CRUD test
>
> There seem to be data consistency bugs in the test. Are "name" and "hotel"
> being used in a pair-wise way?
> Specifically, the first test is using creating one and checking for the other.
>
> On Fri, Jul 23, 2010 at 2:46 PM, Oleg Tsvinev <[email protected]> wrote:
>> Johathan,
>> I followed your suggestion. Unfortunately, CRUD test still does not
>> work for me. Can you provide a simplest CRUD test possible that works?
>> On Fri, Jul 23, 2010 at 10:59 AM, Jonathan Shook <[email protected]> wrote:
>>>
>>> I suspect that it is still your timestamps.
>>> You can verify this with a fake timestamp generator that is simply
>>> incremented on each getTimestamp().
>>>
>>> 1 millisecond is a long time for code that is wrapped tightly in a
>>> test. You are likely using the same logical time stamp for multiple
>>> operations.
>>>
>>>
>>> On Thu, Jul 22, 2010 at 6:29 PM, Peter Minearo
>>> <[email protected]> wrote:
>>> > I am able to reproduce his problem. If you take the default
>>> > storage-conf.xml file and utilize the "Super2" ColumnFamily with
>>> > the code below. You will see that the data is not getting created
>>> > once you run the delete. It seems to not allow you to create data
>>> > via Thrift. HOWEVER, data can be created via the command line tool.
>>> >
>>> > import java.io.UnsupportedEncodingException;
>>> > import java.util.List;
>>> >
>>> > import org.apache.cassandra.thrift.Cassandra;
>>> > import org.apache.cassandra.thrift.Column;
>>> > import org.apache.cassandra.thrift.ColumnOrSuperColumn;
>>> > import org.apache.cassandra.thrift.ColumnParent;
>>> > import org.apache.cassandra.thrift.ColumnPath;
>>> > import org.apache.cassandra.thrift.ConsistencyLevel;
>>> > import org.apache.cassandra.thrift.InvalidRequestException;
>>> > import org.apache.cassandra.thrift.NotFoundException;
>>> > import org.apache.cassandra.thrift.SlicePredicate;
>>> > import org.apache.cassandra.thrift.SliceRange;
>>> > import org.apache.cassandra.thrift.SuperColumn;
>>> > import org.apache.cassandra.thrift.TimedOutException;
>>> > import org.apache.cassandra.thrift.UnavailableException;
>>> > 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;
>>> >
>>> >
>>> > public class CrudTest {
>>> >
>>> >
>>> > private static final String KEYSPACE = "Keyspace1";
>>> >
>>> >
>>> > public static void main(String[] args) {
>>> > CrudTest client = new CrudTest();
>>> >
>>> > try {
>>> > client.run();
>>> > } catch (Exception e) {
>>> > e.printStackTrace();
>>> > }
>>> >
>>> > }
>>> >
>>> >
>>> > public void run() throws TException,
>>> > InvalidRequestException, UnavailableException,
>>> > UnsupportedEncodingException, NotFoundException, TimedOutException
>>> > {
>>> > TTransport tr = new TSocket("localhost", 9160);
>>> > TProtocol proto = new TBinaryProtocol(tr);
>>> > Cassandra.Client client = new
>>> > Cassandra.Client(proto);
>>> > tr.open();
>>> >
>>> > System.out.println("******** CREATING DATA
>>> > *********");
>>> > createData(client);
>>> > getData(client);
>>> > System.out.println();
>>> > System.out.println("******** DELETING DATA
>>> > *********");
>>> > deleteData(client);
>>> > getData(client);
>>> > System.out.println();
>>> > System.out.println("******** CREATING DATA
>>> > *********");
>>> > createData(client);
>>> > getData(client);
>>> >
>>> > tr.close();
>>> > }
>>> >
>>> >
>>> > private void createData(Cassandra.Client client) throws
>>> > InvalidRequestException, UnavailableException, TimedOutException,
>>> > TException {
>>> > ColumnPath cp1 = new ColumnPath("Super2");
>>> > cp1.setSuper_column("hotel".getBytes());
>>> > cp1.setColumn("Best Western".getBytes());
>>> >
>>> >
>>> > client.insert(KEYSPACE,
>>> > "name",
>>> > cp1,
>>> > "Best Western of SF".getBytes(),
>>> > System.currentTimeMillis(),
>>> > ConsistencyLevel.ALL);
>>> >
>>> > ColumnPath cp2 = new ColumnPath("Super2");
>>> > cp2.setSuper_column("hotel".getBytes());
>>> > cp2.setColumn("Econolodge".getBytes());
>>> >
>>> > client.insert(KEYSPACE,
>>> > "name",
>>> > cp2,
>>> > "Econolodge of SF".getBytes(),
>>> > System.currentTimeMillis(),
>>> > ConsistencyLevel.ALL);
>>> >
>>> > }
>>> >
>>> >
>>> > private void deleteData(Cassandra.Client client) throws
>>> > InvalidRequestException, UnavailableException, TimedOutException,
>>> > TException {
>>> >
>>> > client.remove(KEYSPACE,
>>> > "hotel",
>>> > new ColumnPath("Super2"),
>>> > System.currentTimeMillis(),
>>> > ConsistencyLevel.ONE);
>>> >
>>> > }
>>> >
>>> >
>>> > private void getData(Cassandra.Client client) throws
>>> > InvalidRequestException, UnavailableException, TimedOutException,
>>> > TException {
>>> > SliceRange sliceRange = new SliceRange();
>>> > sliceRange.setStart(new byte[] {});
>>> > sliceRange.setFinish(new byte[] {});
>>> >
>>> > SlicePredicate slicePredicate = new
>>> > SlicePredicate();
>>> > slicePredicate.setSlice_range(sliceRange);
>>> >
>>> > getData(client, slicePredicate);
>>> > }
>>> >
>>> >
>>> > private void getData(Cassandra.Client client,
>>> > SlicePredicate
>>> > slicePredicate) throws InvalidRequestException,
>>> > UnavailableException, TimedOutException, TException {
>>> > List<ColumnOrSuperColumn> coscList =
>>> > client.get_slice(KEYSPACE, "hotel", new ColumnParent("Super2"),
>>> > slicePredicate, ConsistencyLevel.ALL);
>>> >
>>> > if (coscList.isEmpty()) {
>>> > System.out.println("Column Or Super Column
>>> > is EMPTY");
>>> > }
>>> >
>>> > for (ColumnOrSuperColumn cosc: coscList) {
>>> >
>>> > if (cosc == null) {
>>> > System.out.println("NULL RETURN
>>> > VALUE");
>>> > }
>>> >
>>> > SuperColumn superColumn =
>>> > cosc.getSuper_column();
>>> >
>>> > if (superColumn == null) {
>>> > System.out.println("Super Column is
>>> > NULL");
>>> > }
>>> > else {
>>> > showSuperColumnInfo(superColumn);
>>> > }
>>> >
>>> > }
>>> >
>>> > }
>>> >
>>> >
>>> > private void showSuperColumnInfo(SuperColumn superColumn) {
>>> > System.out.println("######## Super Columns
>>> > ###########");
>>> > System.out.println("Super Column Name = " + new
>>> > String(superColumn.getName()));
>>> > List<Column> columnList = superColumn.getColumns();
>>> >
>>> > System.out.println("--------- Start Columns
>>> > -----------");
>>> > for (Column column: columnList) {
>>> > System.out.println("Column Name = " + new
>>> > String(column.getName()));
>>> > System.out.println("Column Value = " + new
>>> > String(column.getValue()));
>>> > }
>>> > System.out.println("--------- End Columns
>>> > -----------");
>>> >
>>> > System.out.println("##################################");
>>> > }
>>> >
>>> >
>>> > }
>>> >
>>> >
>>> >
>>> >
>>> > -----Original Message-----
>>> > From: Oleg Tsvinev [mailto:[email protected]]
>>> > Sent: Thu 7/22/2010 1:56 PM
>>> > To: [email protected]
>>> > Subject: Re: CRUD test
>>> >
>>> > Yes, and that was the issue. But now after I delete a row from
>>> > cassandra-cli, I cannot insert anything back with my code. Insert
>>> > code works does not throw any exceptions but when I read just
>>> > inserted columns I get NotFoundException at the last line:
>>> >
>>> > client = borrowClient();
>>> > Keyspace keyspace = client.getKeyspace(KEYSPACE,
>>> > CONSISTENCY_LEVEL);
>>> > ColumnPath cp = new ColumnPath(application);
>>> > cp.setSuper_column(uuid.getBytes());
>>> > SuperColumn sc = keyspace.getSuperColumn(category, cp);
>>> >
>>> > It makes me think that once I remove supercolumn it cannot be
>>> > created again.
>>> >
>>> >
>>> > On Jul 22, 2010 1:13 AM, "Colin Vipurs" <[email protected]> wrote:
>>> >
>>> > Have you checked the timestamp you're using for the subsequent
>>> > inserts is higher than that used in the delete?
>>> >
>>> >
>>> > On Thu, Jul 22, 2010 at 2:29 AM, Oleg Tsvinev
>>> > <[email protected]>
>>> > wrote:
>>> >> Hi there,
>>> >> I'm try...
>>> > --
>>> > Maybe she awoke to see the roommate's boyfriend swinging from the
>>> > chandelier wearing a boar's head.
>>> >
>>> > Something which you, I, and everyone else would call "Tuesday", of
>>> > course.
>>> >
>>> >
>>
>>
>