You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Sam D <te...@gmail.com> on 2009/04/09 23:02:10 UTC

Sample Client Code

Hi,

I am new to Cassandra, just installed the latest version on my machine.  I
am able to insert rows using the web (@7002), but I am not able to get a
java client to insert rows into a table. Below the piece of code I am using,
the insert call goes through fine without any exceptions, but I am not able
to see the row in the table, so I assume its not being inserted properly.

        socket = new TSocket(machine,port);
        TProtocol tp = new TBinaryProtocol(socket);
        cl = new Cassandra.Client(tp);
        socket.open();
        cl.insert("xmls", "x1", "content:xml", "xyz", 0);

Can you please point me to any sample code available which I can refer to ?.

Thanks
Sam.

Re: Sample Client Code

Posted by Sandeep Tata <sa...@gmail.com>.
Sure.
There wan another user on the old lists using Cassandra to store images, see:

http://groups.google.com/group/cassandra-user/browse_thread/thread/6dc9bbb39b3b00f4/3f364cb072e6ef00?lnk=gst&q=staubo#3f364cb072e6ef00

Off the top of my head,  one way would be to base64 encode the file so
you could hand it as a string to the thrift interface. Not ideal, but
it would work.

On Thu, Apr 9, 2009 at 5:40 PM, Sam D <te...@gmail.com> wrote:
> Thanks Jonathan, it issue was due to some connectivity issues.  Its working
> fine now.
>
> I had one more question.
>
> Can we insert byte arrays as values for the columns ?. I am trying to store
> JPEG images.
>
> Thanks
>
> On Thu, Apr 9, 2009 at 2:38 PM, Jonathan Ellis <jb...@gmail.com> wrote:
>>
>> So content:xml is your ColumnFamily:column tuple.  That looks right.
>>
>> That exception is from the client side, right?  That looks to me like
>> it can't connect to the server.
>>
>> Your connection code looks okay... port should be the thrift port,
>> 9160 if you haven't changed it.
>>
>> On Thu, Apr 9, 2009 at 4:31 PM, Sam D <te...@gmail.com> wrote:
>> > No, its not a supercolumn, how do I retrieve it if its not a supercolumn
>> > ?.
>> >
>> >      <Table Name = "xmls">
>> >        <ColumnFamily ColumnSort="Name" Name="content"/>
>> >      </Table>
>> >
>> > I didn't notice it earlier, but yes, I am seeing the following exception
>> > in
>> > the log
>> >
>> > Exception in thread "main"
>> > com.facebook.thrift.transport.TTransportException: Cannot write to null
>> > outputStream
>> >     at com.facebook.thrift.transport.TIOStreamTransport.write(Unknown
>> > Source)
>> >     at com.facebook.thrift.protocol.TBinaryProtocol.writeI32(Unknown
>> > Source)
>> >
>> > Thanks
>> >
>> > On Thu, Apr 9, 2009 at 2:24 PM, Jonathan Ellis <jb...@gmail.com>
>> > wrote:
>> >>
>> >> is content a supercolumn?  otherwise specifying a subcolumn isn't going
>> >> to
>> >> work.
>> >>
>> >> did you check your log file for exceptions?
>> >>
>> >> On Thu, Apr 9, 2009 at 4:19 PM, Sam D <te...@gmail.com> wrote:
>> >> > Thanks for the quick response,
>> >> >
>> >> > I have only one node. So the web client also should see the data,
>> >> > right
>> >> > ?.
>> >> > Below is the code which I am using to read.
>> >> >
>> >> >        socket = new TSocket(machine,port);
>> >> >         TProtocol tp = new TBinaryProtocol(socket);
>> >> >         cl = new Cassandra.Client(tp);
>> >> >         socket.open();
>> >> >         column_t u1 = cl.get_column("xmls","x1","content:xml");
>> >> >         System.out.println("xml : " + u1.value);
>> >> >
>> >> > Sam.
>> >> >
>> >> > On Thu, Apr 9, 2009 at 2:07 PM, Jonathan Ellis <jb...@gmail.com>
>> >> > wrote:
>> >> >>
>> >> >> That looks reasonable.  How are you reading the data back out?  The
>> >> >> web interface only hits the local machine so it is not very useful
>> >> >> in
>> >> >> a clustered situation.
>> >> >>
>> >> >> -Jonathan
>> >> >>
>> >> >> On Thu, Apr 9, 2009 at 4:02 PM, Sam D <te...@gmail.com>
>> >> >> wrote:
>> >> >> > Hi,
>> >> >> >
>> >> >> > I am new to Cassandra, just installed the latest version on my
>> >> >> > machine.
>> >> >> > I
>> >> >> > am able to insert rows using the web (@7002), but I am not able to
>> >> >> > get a
>> >> >> > java client to insert rows into a table. Below the piece of code I
>> >> >> > am
>> >> >> > using,
>> >> >> > the insert call goes through fine without any exceptions, but I am
>> >> >> > not
>> >> >> > able
>> >> >> > to see the row in the table, so I assume its not being inserted
>> >> >> > properly.
>> >> >> >
>> >> >> >         socket = new TSocket(machine,port);
>> >> >> >         TProtocol tp = new TBinaryProtocol(socket);
>> >> >> >         cl = new Cassandra.Client(tp);
>> >> >> >         socket.open();
>> >> >> >         cl.insert("xmls", "x1", "content:xml", "xyz", 0);
>> >> >> >
>> >> >> > Can you please point me to any sample code available which I can
>> >> >> > refer
>> >> >> > to ?.
>> >> >> >
>> >> >> > Thanks
>> >> >> > Sam.
>> >> >> >
>> >> >
>> >> >
>> >
>> >
>
>

Re: Sample Client Code

Posted by Sam D <te...@gmail.com>.
Thanks. I am able to load and retrieve files from Cassandra now.

On Thu, Apr 9, 2009 at 6:25 PM, Jonathan Ellis <jb...@gmail.com> wrote:

> For now you'll have to encode it somehow.
>
> We have a ticket (https://issues.apache.org/jira/browse/CASSANDRA-29)
> to switch to binary data as column values and that's high on my list
> to get done.
>
> -Jonathan
>
> On Thu, Apr 9, 2009 at 7:40 PM, Sam D <te...@gmail.com> wrote:
> > Thanks Jonathan, it issue was due to some connectivity issues.  Its
> working
> > fine now.
> >
> > I had one more question.
> >
> > Can we insert byte arrays as values for the columns ?. I am trying to
> store
> > JPEG images.
> >
> > Thanks
> >
> > On Thu, Apr 9, 2009 at 2:38 PM, Jonathan Ellis <jb...@gmail.com>
> wrote:
> >>
> >> So content:xml is your ColumnFamily:column tuple.  That looks right.
> >>
> >> That exception is from the client side, right?  That looks to me like
> >> it can't connect to the server.
> >>
> >> Your connection code looks okay... port should be the thrift port,
> >> 9160 if you haven't changed it.
> >>
> >> On Thu, Apr 9, 2009 at 4:31 PM, Sam D <te...@gmail.com> wrote:
> >> > No, its not a supercolumn, how do I retrieve it if its not a
> supercolumn
> >> > ?.
> >> >
> >> >      <Table Name = "xmls">
> >> >        <ColumnFamily ColumnSort="Name" Name="content"/>
> >> >      </Table>
> >> >
> >> > I didn't notice it earlier, but yes, I am seeing the following
> exception
> >> > in
> >> > the log
> >> >
> >> > Exception in thread "main"
> >> > com.facebook.thrift.transport.TTransportException: Cannot write to
> null
> >> > outputStream
> >> >     at com.facebook.thrift.transport.TIOStreamTransport.write(Unknown
> >> > Source)
> >> >     at com.facebook.thrift.protocol.TBinaryProtocol.writeI32(Unknown
> >> > Source)
> >> >
> >> > Thanks
> >> >
> >> > On Thu, Apr 9, 2009 at 2:24 PM, Jonathan Ellis <jb...@gmail.com>
> >> > wrote:
> >> >>
> >> >> is content a supercolumn?  otherwise specifying a subcolumn isn't
> going
> >> >> to
> >> >> work.
> >> >>
> >> >> did you check your log file for exceptions?
> >> >>
> >> >> On Thu, Apr 9, 2009 at 4:19 PM, Sam D <te...@gmail.com>
> wrote:
> >> >> > Thanks for the quick response,
> >> >> >
> >> >> > I have only one node. So the web client also should see the data,
> >> >> > right
> >> >> > ?.
> >> >> > Below is the code which I am using to read.
> >> >> >
> >> >> >        socket = new TSocket(machine,port);
> >> >> >         TProtocol tp = new TBinaryProtocol(socket);
> >> >> >         cl = new Cassandra.Client(tp);
> >> >> >         socket.open();
> >> >> >         column_t u1 = cl.get_column("xmls","x1","content:xml");
> >> >> >         System.out.println("xml : " + u1.value);
> >> >> >
> >> >> > Sam.
> >> >> >
> >> >> > On Thu, Apr 9, 2009 at 2:07 PM, Jonathan Ellis <jb...@gmail.com>
> >> >> > wrote:
> >> >> >>
> >> >> >> That looks reasonable.  How are you reading the data back out?
>  The
> >> >> >> web interface only hits the local machine so it is not very useful
> >> >> >> in
> >> >> >> a clustered situation.
> >> >> >>
> >> >> >> -Jonathan
> >> >> >>
> >> >> >> On Thu, Apr 9, 2009 at 4:02 PM, Sam D <te...@gmail.com>
> >> >> >> wrote:
> >> >> >> > Hi,
> >> >> >> >
> >> >> >> > I am new to Cassandra, just installed the latest version on my
> >> >> >> > machine.
> >> >> >> > I
> >> >> >> > am able to insert rows using the web (@7002), but I am not able
> to
> >> >> >> > get a
> >> >> >> > java client to insert rows into a table. Below the piece of code
> I
> >> >> >> > am
> >> >> >> > using,
> >> >> >> > the insert call goes through fine without any exceptions, but I
> am
> >> >> >> > not
> >> >> >> > able
> >> >> >> > to see the row in the table, so I assume its not being inserted
> >> >> >> > properly.
> >> >> >> >
> >> >> >> >         socket = new TSocket(machine,port);
> >> >> >> >         TProtocol tp = new TBinaryProtocol(socket);
> >> >> >> >         cl = new Cassandra.Client(tp);
> >> >> >> >         socket.open();
> >> >> >> >         cl.insert("xmls", "x1", "content:xml", "xyz", 0);
> >> >> >> >
> >> >> >> > Can you please point me to any sample code available which I can
> >> >> >> > refer
> >> >> >> > to ?.
> >> >> >> >
> >> >> >> > Thanks
> >> >> >> > Sam.
> >> >> >> >
> >> >> >
> >> >> >
> >> >
> >> >
> >
> >
>

Re: Sample Client Code

Posted by Jonathan Ellis <jb...@gmail.com>.
For now you'll have to encode it somehow.

We have a ticket (https://issues.apache.org/jira/browse/CASSANDRA-29)
to switch to binary data as column values and that's high on my list
to get done.

-Jonathan

On Thu, Apr 9, 2009 at 7:40 PM, Sam D <te...@gmail.com> wrote:
> Thanks Jonathan, it issue was due to some connectivity issues.  Its working
> fine now.
>
> I had one more question.
>
> Can we insert byte arrays as values for the columns ?. I am trying to store
> JPEG images.
>
> Thanks
>
> On Thu, Apr 9, 2009 at 2:38 PM, Jonathan Ellis <jb...@gmail.com> wrote:
>>
>> So content:xml is your ColumnFamily:column tuple.  That looks right.
>>
>> That exception is from the client side, right?  That looks to me like
>> it can't connect to the server.
>>
>> Your connection code looks okay... port should be the thrift port,
>> 9160 if you haven't changed it.
>>
>> On Thu, Apr 9, 2009 at 4:31 PM, Sam D <te...@gmail.com> wrote:
>> > No, its not a supercolumn, how do I retrieve it if its not a supercolumn
>> > ?.
>> >
>> >      <Table Name = "xmls">
>> >        <ColumnFamily ColumnSort="Name" Name="content"/>
>> >      </Table>
>> >
>> > I didn't notice it earlier, but yes, I am seeing the following exception
>> > in
>> > the log
>> >
>> > Exception in thread "main"
>> > com.facebook.thrift.transport.TTransportException: Cannot write to null
>> > outputStream
>> >     at com.facebook.thrift.transport.TIOStreamTransport.write(Unknown
>> > Source)
>> >     at com.facebook.thrift.protocol.TBinaryProtocol.writeI32(Unknown
>> > Source)
>> >
>> > Thanks
>> >
>> > On Thu, Apr 9, 2009 at 2:24 PM, Jonathan Ellis <jb...@gmail.com>
>> > wrote:
>> >>
>> >> is content a supercolumn?  otherwise specifying a subcolumn isn't going
>> >> to
>> >> work.
>> >>
>> >> did you check your log file for exceptions?
>> >>
>> >> On Thu, Apr 9, 2009 at 4:19 PM, Sam D <te...@gmail.com> wrote:
>> >> > Thanks for the quick response,
>> >> >
>> >> > I have only one node. So the web client also should see the data,
>> >> > right
>> >> > ?.
>> >> > Below is the code which I am using to read.
>> >> >
>> >> >        socket = new TSocket(machine,port);
>> >> >         TProtocol tp = new TBinaryProtocol(socket);
>> >> >         cl = new Cassandra.Client(tp);
>> >> >         socket.open();
>> >> >         column_t u1 = cl.get_column("xmls","x1","content:xml");
>> >> >         System.out.println("xml : " + u1.value);
>> >> >
>> >> > Sam.
>> >> >
>> >> > On Thu, Apr 9, 2009 at 2:07 PM, Jonathan Ellis <jb...@gmail.com>
>> >> > wrote:
>> >> >>
>> >> >> That looks reasonable.  How are you reading the data back out?  The
>> >> >> web interface only hits the local machine so it is not very useful
>> >> >> in
>> >> >> a clustered situation.
>> >> >>
>> >> >> -Jonathan
>> >> >>
>> >> >> On Thu, Apr 9, 2009 at 4:02 PM, Sam D <te...@gmail.com>
>> >> >> wrote:
>> >> >> > Hi,
>> >> >> >
>> >> >> > I am new to Cassandra, just installed the latest version on my
>> >> >> > machine.
>> >> >> > I
>> >> >> > am able to insert rows using the web (@7002), but I am not able to
>> >> >> > get a
>> >> >> > java client to insert rows into a table. Below the piece of code I
>> >> >> > am
>> >> >> > using,
>> >> >> > the insert call goes through fine without any exceptions, but I am
>> >> >> > not
>> >> >> > able
>> >> >> > to see the row in the table, so I assume its not being inserted
>> >> >> > properly.
>> >> >> >
>> >> >> >         socket = new TSocket(machine,port);
>> >> >> >         TProtocol tp = new TBinaryProtocol(socket);
>> >> >> >         cl = new Cassandra.Client(tp);
>> >> >> >         socket.open();
>> >> >> >         cl.insert("xmls", "x1", "content:xml", "xyz", 0);
>> >> >> >
>> >> >> > Can you please point me to any sample code available which I can
>> >> >> > refer
>> >> >> > to ?.
>> >> >> >
>> >> >> > Thanks
>> >> >> > Sam.
>> >> >> >
>> >> >
>> >> >
>> >
>> >
>
>

Re: Sample Client Code

Posted by Sam D <te...@gmail.com>.
Thanks Jonathan, it issue was due to some connectivity issues.  Its working
fine now.

I had one more question.

Can we insert byte arrays as values for the columns ?. I am trying to store
JPEG images.

Thanks

On Thu, Apr 9, 2009 at 2:38 PM, Jonathan Ellis <jb...@gmail.com> wrote:

> So content:xml is your ColumnFamily:column tuple.  That looks right.
>
> That exception is from the client side, right?  That looks to me like
> it can't connect to the server.
>
> Your connection code looks okay... port should be the thrift port,
> 9160 if you haven't changed it.
>
> On Thu, Apr 9, 2009 at 4:31 PM, Sam D <te...@gmail.com> wrote:
> > No, its not a supercolumn, how do I retrieve it if its not a supercolumn
> ?.
> >
> >      <Table Name = "xmls">
> >        <ColumnFamily ColumnSort="Name" Name="content"/>
> >      </Table>
> >
> > I didn't notice it earlier, but yes, I am seeing the following exception
> in
> > the log
> >
> > Exception in thread "main"
> > com.facebook.thrift.transport.TTransportException: Cannot write to null
> > outputStream
> >     at com.facebook.thrift.transport.TIOStreamTransport.write(Unknown
> > Source)
> >     at com.facebook.thrift.protocol.TBinaryProtocol.writeI32(Unknown
> Source)
> >
> > Thanks
> >
> > On Thu, Apr 9, 2009 at 2:24 PM, Jonathan Ellis <jb...@gmail.com>
> wrote:
> >>
> >> is content a supercolumn?  otherwise specifying a subcolumn isn't going
> to
> >> work.
> >>
> >> did you check your log file for exceptions?
> >>
> >> On Thu, Apr 9, 2009 at 4:19 PM, Sam D <te...@gmail.com> wrote:
> >> > Thanks for the quick response,
> >> >
> >> > I have only one node. So the web client also should see the data,
> right
> >> > ?.
> >> > Below is the code which I am using to read.
> >> >
> >> >        socket = new TSocket(machine,port);
> >> >         TProtocol tp = new TBinaryProtocol(socket);
> >> >         cl = new Cassandra.Client(tp);
> >> >         socket.open();
> >> >         column_t u1 = cl.get_column("xmls","x1","content:xml");
> >> >         System.out.println("xml : " + u1.value);
> >> >
> >> > Sam.
> >> >
> >> > On Thu, Apr 9, 2009 at 2:07 PM, Jonathan Ellis <jb...@gmail.com>
> >> > wrote:
> >> >>
> >> >> That looks reasonable.  How are you reading the data back out?  The
> >> >> web interface only hits the local machine so it is not very useful in
> >> >> a clustered situation.
> >> >>
> >> >> -Jonathan
> >> >>
> >> >> On Thu, Apr 9, 2009 at 4:02 PM, Sam D <te...@gmail.com>
> wrote:
> >> >> > Hi,
> >> >> >
> >> >> > I am new to Cassandra, just installed the latest version on my
> >> >> > machine.
> >> >> > I
> >> >> > am able to insert rows using the web (@7002), but I am not able to
> >> >> > get a
> >> >> > java client to insert rows into a table. Below the piece of code I
> am
> >> >> > using,
> >> >> > the insert call goes through fine without any exceptions, but I am
> >> >> > not
> >> >> > able
> >> >> > to see the row in the table, so I assume its not being inserted
> >> >> > properly.
> >> >> >
> >> >> >         socket = new TSocket(machine,port);
> >> >> >         TProtocol tp = new TBinaryProtocol(socket);
> >> >> >         cl = new Cassandra.Client(tp);
> >> >> >         socket.open();
> >> >> >         cl.insert("xmls", "x1", "content:xml", "xyz", 0);
> >> >> >
> >> >> > Can you please point me to any sample code available which I can
> >> >> > refer
> >> >> > to ?.
> >> >> >
> >> >> > Thanks
> >> >> > Sam.
> >> >> >
> >> >
> >> >
> >
> >
>

Re: Sample Client Code

Posted by Jonathan Ellis <jb...@gmail.com>.
So content:xml is your ColumnFamily:column tuple.  That looks right.

That exception is from the client side, right?  That looks to me like
it can't connect to the server.

Your connection code looks okay... port should be the thrift port,
9160 if you haven't changed it.

On Thu, Apr 9, 2009 at 4:31 PM, Sam D <te...@gmail.com> wrote:
> No, its not a supercolumn, how do I retrieve it if its not a supercolumn ?.
>
>      <Table Name = "xmls">
>        <ColumnFamily ColumnSort="Name" Name="content"/>
>      </Table>
>
> I didn't notice it earlier, but yes, I am seeing the following exception in
> the log
>
> Exception in thread "main"
> com.facebook.thrift.transport.TTransportException: Cannot write to null
> outputStream
>     at com.facebook.thrift.transport.TIOStreamTransport.write(Unknown
> Source)
>     at com.facebook.thrift.protocol.TBinaryProtocol.writeI32(Unknown Source)
>
> Thanks
>
> On Thu, Apr 9, 2009 at 2:24 PM, Jonathan Ellis <jb...@gmail.com> wrote:
>>
>> is content a supercolumn?  otherwise specifying a subcolumn isn't going to
>> work.
>>
>> did you check your log file for exceptions?
>>
>> On Thu, Apr 9, 2009 at 4:19 PM, Sam D <te...@gmail.com> wrote:
>> > Thanks for the quick response,
>> >
>> > I have only one node. So the web client also should see the data, right
>> > ?.
>> > Below is the code which I am using to read.
>> >
>> >        socket = new TSocket(machine,port);
>> >         TProtocol tp = new TBinaryProtocol(socket);
>> >         cl = new Cassandra.Client(tp);
>> >         socket.open();
>> >         column_t u1 = cl.get_column("xmls","x1","content:xml");
>> >         System.out.println("xml : " + u1.value);
>> >
>> > Sam.
>> >
>> > On Thu, Apr 9, 2009 at 2:07 PM, Jonathan Ellis <jb...@gmail.com>
>> > wrote:
>> >>
>> >> That looks reasonable.  How are you reading the data back out?  The
>> >> web interface only hits the local machine so it is not very useful in
>> >> a clustered situation.
>> >>
>> >> -Jonathan
>> >>
>> >> On Thu, Apr 9, 2009 at 4:02 PM, Sam D <te...@gmail.com> wrote:
>> >> > Hi,
>> >> >
>> >> > I am new to Cassandra, just installed the latest version on my
>> >> > machine.
>> >> > I
>> >> > am able to insert rows using the web (@7002), but I am not able to
>> >> > get a
>> >> > java client to insert rows into a table. Below the piece of code I am
>> >> > using,
>> >> > the insert call goes through fine without any exceptions, but I am
>> >> > not
>> >> > able
>> >> > to see the row in the table, so I assume its not being inserted
>> >> > properly.
>> >> >
>> >> >         socket = new TSocket(machine,port);
>> >> >         TProtocol tp = new TBinaryProtocol(socket);
>> >> >         cl = new Cassandra.Client(tp);
>> >> >         socket.open();
>> >> >         cl.insert("xmls", "x1", "content:xml", "xyz", 0);
>> >> >
>> >> > Can you please point me to any sample code available which I can
>> >> > refer
>> >> > to ?.
>> >> >
>> >> > Thanks
>> >> > Sam.
>> >> >
>> >
>> >
>
>

Re: Sample Client Code

Posted by Sam D <te...@gmail.com>.
No, its not a supercolumn, how do I retrieve it if its not a supercolumn ?.


     <Table Name = "xmls">
       <ColumnFamily ColumnSort="Name" Name="content"/>
     </Table>

I didn't notice it earlier, but yes, I am seeing the following exception in
the log

Exception in thread "main"
com.facebook.thrift.transport.TTransportException: Cannot write to null
outputStream
    at com.facebook.thrift.transport.TIOStreamTransport.write(Unknown
Source)
    at com.facebook.thrift.protocol.TBinaryProtocol.writeI32(Unknown Source)

Thanks

On Thu, Apr 9, 2009 at 2:24 PM, Jonathan Ellis <jb...@gmail.com> wrote:

> is content a supercolumn?  otherwise specifying a subcolumn isn't going to
> work.
>
> did you check your log file for exceptions?
>
> On Thu, Apr 9, 2009 at 4:19 PM, Sam D <te...@gmail.com> wrote:
> > Thanks for the quick response,
> >
> > I have only one node. So the web client also should see the data, right
> ?.
> > Below is the code which I am using to read.
> >
> >        socket = new TSocket(machine,port);
> >         TProtocol tp = new TBinaryProtocol(socket);
> >         cl = new Cassandra.Client(tp);
> >         socket.open();
> >         column_t u1 = cl.get_column("xmls","x1","content:xml");
> >         System.out.println("xml : " + u1.value);
> >
> > Sam.
> >
> > On Thu, Apr 9, 2009 at 2:07 PM, Jonathan Ellis <jb...@gmail.com>
> wrote:
> >>
> >> That looks reasonable.  How are you reading the data back out?  The
> >> web interface only hits the local machine so it is not very useful in
> >> a clustered situation.
> >>
> >> -Jonathan
> >>
> >> On Thu, Apr 9, 2009 at 4:02 PM, Sam D <te...@gmail.com> wrote:
> >> > Hi,
> >> >
> >> > I am new to Cassandra, just installed the latest version on my
> machine.
> >> > I
> >> > am able to insert rows using the web (@7002), but I am not able to get
> a
> >> > java client to insert rows into a table. Below the piece of code I am
> >> > using,
> >> > the insert call goes through fine without any exceptions, but I am not
> >> > able
> >> > to see the row in the table, so I assume its not being inserted
> >> > properly.
> >> >
> >> >         socket = new TSocket(machine,port);
> >> >         TProtocol tp = new TBinaryProtocol(socket);
> >> >         cl = new Cassandra.Client(tp);
> >> >         socket.open();
> >> >         cl.insert("xmls", "x1", "content:xml", "xyz", 0);
> >> >
> >> > Can you please point me to any sample code available which I can refer
> >> > to ?.
> >> >
> >> > Thanks
> >> > Sam.
> >> >
> >
> >
>

Re: Sample Client Code

Posted by Jonathan Ellis <jb...@gmail.com>.
is content a supercolumn?  otherwise specifying a subcolumn isn't going to work.

did you check your log file for exceptions?

On Thu, Apr 9, 2009 at 4:19 PM, Sam D <te...@gmail.com> wrote:
> Thanks for the quick response,
>
> I have only one node. So the web client also should see the data, right ?.
> Below is the code which I am using to read.
>
>        socket = new TSocket(machine,port);
>         TProtocol tp = new TBinaryProtocol(socket);
>         cl = new Cassandra.Client(tp);
>         socket.open();
>         column_t u1 = cl.get_column("xmls","x1","content:xml");
>         System.out.println("xml : " + u1.value);
>
> Sam.
>
> On Thu, Apr 9, 2009 at 2:07 PM, Jonathan Ellis <jb...@gmail.com> wrote:
>>
>> That looks reasonable.  How are you reading the data back out?  The
>> web interface only hits the local machine so it is not very useful in
>> a clustered situation.
>>
>> -Jonathan
>>
>> On Thu, Apr 9, 2009 at 4:02 PM, Sam D <te...@gmail.com> wrote:
>> > Hi,
>> >
>> > I am new to Cassandra, just installed the latest version on my machine.
>> > I
>> > am able to insert rows using the web (@7002), but I am not able to get a
>> > java client to insert rows into a table. Below the piece of code I am
>> > using,
>> > the insert call goes through fine without any exceptions, but I am not
>> > able
>> > to see the row in the table, so I assume its not being inserted
>> > properly.
>> >
>> >         socket = new TSocket(machine,port);
>> >         TProtocol tp = new TBinaryProtocol(socket);
>> >         cl = new Cassandra.Client(tp);
>> >         socket.open();
>> >         cl.insert("xmls", "x1", "content:xml", "xyz", 0);
>> >
>> > Can you please point me to any sample code available which I can refer
>> > to ?.
>> >
>> > Thanks
>> > Sam.
>> >
>
>

Re: Sample Client Code

Posted by Sam D <te...@gmail.com>.
Thanks for the quick response,

I have only one node. So the web client also should see the data, right ?.
Below is the code which I am using to read.

       socket = new TSocket(machine,port);
        TProtocol tp = new TBinaryProtocol(socket);
        cl = new Cassandra.Client(tp);
        socket.open();
        column_t u1 = cl.get_column("xmls","x1","content:xml");
        System.out.println("xml : " + u1.value);

Sam.

On Thu, Apr 9, 2009 at 2:07 PM, Jonathan Ellis <jb...@gmail.com> wrote:

> That looks reasonable.  How are you reading the data back out?  The
> web interface only hits the local machine so it is not very useful in
> a clustered situation.
>
> -Jonathan
>
> On Thu, Apr 9, 2009 at 4:02 PM, Sam D <te...@gmail.com> wrote:
> > Hi,
> >
> > I am new to Cassandra, just installed the latest version on my machine.
> I
> > am able to insert rows using the web (@7002), but I am not able to get a
> > java client to insert rows into a table. Below the piece of code I am
> using,
> > the insert call goes through fine without any exceptions, but I am not
> able
> > to see the row in the table, so I assume its not being inserted properly.
> >
> >         socket = new TSocket(machine,port);
> >         TProtocol tp = new TBinaryProtocol(socket);
> >         cl = new Cassandra.Client(tp);
> >         socket.open();
> >         cl.insert("xmls", "x1", "content:xml", "xyz", 0);
> >
> > Can you please point me to any sample code available which I can refer to
> ?.
> >
> > Thanks
> > Sam.
> >
>

Re: Sample Client Code

Posted by Jonathan Ellis <jb...@gmail.com>.
That looks reasonable.  How are you reading the data back out?  The
web interface only hits the local machine so it is not very useful in
a clustered situation.

-Jonathan

On Thu, Apr 9, 2009 at 4:02 PM, Sam D <te...@gmail.com> wrote:
> Hi,
>
> I am new to Cassandra, just installed the latest version on my machine.  I
> am able to insert rows using the web (@7002), but I am not able to get a
> java client to insert rows into a table. Below the piece of code I am using,
> the insert call goes through fine without any exceptions, but I am not able
> to see the row in the table, so I assume its not being inserted properly.
>
>         socket = new TSocket(machine,port);
>         TProtocol tp = new TBinaryProtocol(socket);
>         cl = new Cassandra.Client(tp);
>         socket.open();
>         cl.insert("xmls", "x1", "content:xml", "xyz", 0);
>
> Can you please point me to any sample code available which I can refer to ?.
>
> Thanks
> Sam.
>