You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Ryan King <ry...@twitter.com> on 2010/06/19 23:48:59 UTC
Re: Learning-by-doing (also announcing a new Ruby Client Codename:
"Greek Architect")
On Sat, Jun 19, 2010 at 9:30 AM, Christian van der Leeden
<ch...@googlemail.com> wrote:
> Hi Thomas,
>
> did you look at cassandra gem from twitter (fauna/cassandra) on github?
> They also use the thrift_client and already have the basic cassandra API accessible.
>
> I'm also using ruby with cassandra and still need to find a slick way to do the inserts
> and when to update the indexes.
Have you looked at CassandraObject for that?
http://github.com/nzkoz/cassandra_object
-ryan
>
> If I understood correctly you want to look up a user by name. And you want to have
> the name as row keys where you would find the UID with which you could look up your user?
>
> From my understanding I would put the index into one row, name it e.g. "user_by_name",
> and insert columns where the column name is the user name and the value of the column
> would be the UUID of the user. Cassandra creates the index on the column names. You can
> efficiently insert new values into this row.
>
> What do you want to do with the users partitioned by date? Sorted by creation date? Login date?
>
> For the cascading deletes: a database would have to remove a record from its index, too.
> In Cassandra you would have to do it yourself..
>
> Christian
>
> On Jun 19, 2010, at 3:27 AM, Thomas Heller wrote:
>
>> Howdy!
>>
>> So, last week I finally got around to playing with Cassandra. After a
>> while I understood the basics. To test this assumption I started
>> working on my own Client implementation since "Learning-by-doing" is
>> what I do and existing Ruby Clients (which are awesome) already
>> abstracted too much for me to really grasp what was going on. Java is
>> not really my thing (anymore) so I began with the Thrift API and Ruby.
>>
>> Anyways back to Topic.
>>
>> This library is now is available at:
>> http://github.com/thheller/greek_architect
>>
>> Since I have virtually no experience with Cassandra (but plenty with
>> SQL) I started with the first use-case which I have programmed a bunch
>> of times before. User Management. I build websites which are used by
>> other people, so I need to store them somewhere.
>>
>> Step #1: Creating Users and persisting them in Cassandra
>>
>> Example here:
>> http://github.com/thheller/greek_architect/blob/master/spec/examples/user_create_spec.rb
>>
>> I hope my rspec-style documentation doesnt confuse too many people
>> since I already have a gazillion questions for this simple, but also
>> VERY common use-case. Since a question is best asked with a concrete
>> example to refer to, here goes my first one:
>>
>> Would any of you veterans build what I built the way I did? (refering
>> to the cassandra design, not the ruby client)
>>
>> I insert Users with UUID keys into one ColumnFamily. I then index them
>> by creating a row in another ColumnFamily using the Name as Key and
>> then adding one column holding a reference to the User UUID. I also
>> insert a reference into another ColumnFamily holding a List of Users
>> partitioned by Date.
>>
>> I'm really unsure about the index design, since they dont get updated
>> when a User row is removed. I could hook into the remove call (like I
>> did into mutations) and cascade the deletes where needed, but 10+
>> years of SQL always want to tell me I'm crazy for doing this stuff!
>>
>> I'd really appreciate some feedback.
>>
>> Cheers,
>> Thomas
>
>
Re: Learning-by-doing (also announcing a new Ruby Client Codename:
"Greek Architect")
Posted by Thomas Heller <in...@zilence.net>.
Hey,
of course I know about
http://github.com/fauna/cassandra
http://github.com/nzkoz/cassandra_object
and they are awesome and without them I probably would have had a much
harder time learning about Cassandra since its always good to have
some way to actually throw some stuff in there.
The cassandra gem chose to abstract the underlying data model by
building ruby hashes on top of it, which for me was already one
abstraction level too much to understand what exactly was going on
below (and losing timestamps in the process). cassandra_object builds
on top of that so that obviously is way too high.
However the motivation for my stuff was more about learning about
Cassandra than actually writing a new client to replace anything. I'd
recommend the cassandra(_object) gems to anyone wanting to USE
Cassandra NOW. I'm not entirely sure how everything works on the
server-side so I wanted to investigate it as closely as possible.
My goal is to develop some "best-practices" for using Cassandra since
AFAICT nothing like that exists yet. SQL actually has changed very
little over the years and at some point I learned what was "good" and
what to avoid. I have no experience actually using Cassandra (or
HBase, BigTable, etc) so I have no idea if what I come up with is any
good or will eventually blow up just like SQL would. "Best-Practice"s
obviously do not depend on a specific client since they would be the
same for every language and the thrift API basically already does all
you need. Building a client on top of it is a rather simple
programming exercise to make it more "pretty" and in my case more
"ruby-esque".
For example when starting with the cassandra gem I eventually found
myself using SuperColumns all over the place. I have no idea if that
is actually a good or a bad thing BUT, from my understanding of what
cassandra does with it, I'm pretty sure it wasnt optimal for what I
was doing.
Anyways, as mentioned I'm new to this stuff and have been learning
alot these past few days. I'm sure I'll come up with some more
specific questions soon, but right now I'm just browsing the java
sources to find out what exactly happens when.
Cheers,
/thomas