News for hackers. Stuff that matters.
Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by JonnieCache on Thursday January 27, 2011 @02:35PM (#2149141)
And it's ActiveModel-based! Hallelujah!

For those not of a rails persuasion, ActiveModel is basically all the non-datastore stuff abstracted out from ActiveRecord, rails' ORM.

So, this Toy Store lib will share all its validation, accessor etc. apis with ActiveRecord and so will already automatically be compatible with the huge range of rails libraries out there. A good example is simple_form, a rails gem for doing lovely forms without any markup. In theory you should be able to hook this into Toy Store and therefore all those key/value stores with zero effort.

https://github.com/plataformatec/simple_form

ActiveModel is on course to become Rack for data objects. When this idea is fully explored it's gonna make so many things so easy.

Soon we're all going to be auto-generating javascript client-side validation code from our server-side activemodel validation definitions, without ever having to think for a second about how or where the data is actually stored.

Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by kotrin on Thursday January 27, 2011 @07:23PM (#2150226)
abstraction abstraction abstraction
Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by tomafro on Thursday January 27, 2011 @02:41PM (#2149158)
I'm not sure I quite get this.

The code looks great. The mapping features seem strong (thanks in part to the power of ActiveModel). However, by restricting the adapter interface to a simple key/value store, don't you lose access to many of the features that make each backend distinct?

I think Redis, Cassandra, MongoDB, etc. are great, but to me it't the differences amongst them which are interesting, not the similarities.

Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by iamwil on Thursday January 27, 2011 @03:29PM (#2149321)
New does travel quick. I was just reading about this thing this morning.

http://railstips.org/blog/archives/2011/01/27/data-modeling-...

So John in the above link was talking about how when you scale, you end up looking at bottlenecks, which are usually slow data accesses, and moving them into some sort of key-value store--that usually are based on a key-value access pattern. So by the time you're well into scaling your app, you noticed that much of your data access has turned into limiting yourself to doing key lookups to attain the performance you need.

Since (according to his experiences scaling) most of the performance bottlenecks seem to have this pattern, he asked, "what if you restricted your data access to just using key-value pairs from the very beginning?" That way you avoid some of the data access headaches later on. In answering that question, this is what they got.

Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by Smerity on Thursday January 27, 2011 @08:59PM (#2150480)
The same tactic was used by Google for Google App Engine - "if it doesn't scale then we're not including it as a feature". This is why so much of Google App Engine's documentation focuses on scaling [1]. Depending on who you ask this is genius or folly.

By forcing yourself into this tactic you end up having to consider all the scaling complexity in the prototyping stage before your app has even proven itself potentially successful. If your app becomes wildly popular then the combination of your early work and Google's behind the scene scaling means there are far less problems for you to worry about.

My major concern with this method is that people already focus far too much on premature optimizations before they even know where the real bottlenecks are in their application. If premature optimization leads to burn out or less features then it's a poison to our projects and should be avoided.

[1] http://code.google.com/appengine/articles/scaling/overview.h...

Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by tomafro on Friday January 28, 2011 @05:38AM (#2151420)
I think that's a good tactic; certainly a valid problem to solve. I think the headline on HN oversells the ability to use different backends, whereas the real value (as explained on railstips.org) is much more about destructuring data into this scalable key-value access pattern.
Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by tjpick on Thursday January 27, 2011 @01:32PM (#2148892)
This NoSQL stuff has me confused. I didn't think those systems were considered relational.

Why does one need an object-relational mapper?

Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by antirez on Thursday January 27, 2011 @01:49PM (#2148959)
NoSQL systems are not SQL, but this does not mean they are unable to model relations. For instance in Redis you often have something like:

    user:1000
That is an hash with a few attributes, and among this attribs you can have 'group_id", that is an integer, for instance 50. Then if you access

    group:50
You have another data structure representing the group the user is associated with.
Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by koudelka on Thursday January 27, 2011 @01:41PM (#2148928)
I believe the de-facto nomenclature for a NoSQL database's equivalent of an ORM is an "ODM", Object Document Mapper.
Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by netherland on Thursday January 27, 2011 @01:33PM (#2148901)
Good point. Probably should have just called it a mapper.
Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by netghost on Thursday January 27, 2011 @01:47PM (#2148947)
There's a better article on the rationale here: http://railstips.org/blog/archives/2011/01/27/data-modeling-...
Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by j2d2j2d2 on Thursday January 27, 2011 @04:08PM (#2149482)
I wrote something similar for Python. Not quite as robust, but on a similar path.

DictShield: https://github.com/j2labs/dictshield

Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by mariusmg on Thursday January 27, 2011 @02:15PM (#2149073)
if you need a ORM for key/value storage, you're doing it (very) wrong
Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by cheald on Thursday January 27, 2011 @04:21PM (#2149537)
If it's simple "stuff it in, pull it out" stuff, sure. Having things like validations and callbacks and association sugar and the like are really nice, though, in cases beyond the very simple. I think the point is to let you focus more on writing business logic, and less on mucking about with your underlying datastore. If it works as promised, then it could very certainly result in a productivity gain.
Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by rapind on Thursday January 27, 2011 @03:11PM (#2149252)
Exactly. I'm not sure why this is necessary. If you want to store rich objects, just serialize them and create your indexes as necessary.

Anyways, I'll definitely check it out. Maybe I'm missing something.

Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by wfarr on Thursday January 27, 2011 @06:10PM (#2149992)
The scale of the application affects how much you can really do just by adding indexes to tables and throwing more hardware at it.

At a certain point, servers are only so fast and disks only so large and fast.

Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by jrockway on Thursday January 27, 2011 @02:12PM (#2149063)
So basically, Elephant or KiokuDB, but for Ruby? I think people tend to call these "object databases" rather than ORMs.
[deleted]
Re:Toy Store: ORM for Riak, Redis, Cassandra, Memcached, dar... by wildmXranat on Thursday January 27, 2011 @03:58PM (#2149444)
'R'elevant. Good question.