New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide timestamp column access #14

Closed
mperham opened this Issue Mar 3, 2010 · 17 comments

Comments

Projects
None yet
7 participants
@mperham
Contributor

mperham commented Mar 3, 2010

I'd like to be able to access the timestamp value as it is somewhat equivalent to Rails' updated_at field.

When I use Cassandra gem, I get this:

>>     c = Cassandra.new('Onespot', 'removed:9160')
>>     c.get(:ImageInfo, '0c8f0d9a9a64bb050d75e803d2d2cf7739c34fff')
=> {"02912452fc37dde56faf7474994b05f40594255c"=>"1", "selected"=>"02912452fc37dde56faf7474994b05f40594255c"}

But Cassandra's CLI gives me access:

cassandra> get Onespot.ImageInfo['0c8f0d9a9a64bb050d75e803d2d2cf7739c34fff']
=> (column=selected, value=02912452fc37dde56faf7474994b05f40594255c, timestamp=1267583251726377)
=> (column=02912452fc37dde56faf7474994b05f40594255c, value=1, timestamp=1267583251726377)
Returned 2 results.

I'd like to see an API that surfaces this info if possible.

@ryanking

This comment has been minimized.

Contributor

ryanking commented Mar 3, 2010

I'm not opposed to this, but since its not a priority for us, all I can contribute is design help/review. If you'd like to tackle it I can help sort out a design.

@mperham

This comment has been minimized.

Contributor

mperham commented Mar 3, 2010

If you want to give me commit access, I'd be happy to work on an API + tests with your suggestions.

@ryanking

This comment has been minimized.

Contributor

ryanking commented Mar 4, 2010

I'd prefer to use github's fork and pull model for development.

@IcyMidnight

This comment has been minimized.

IcyMidnight commented Apr 8, 2010

Based on the commit log and this issue being open, it doesn't seem this has been added. Are you still planning to look into this Mike? If not perhaps I can make an attempt myself.

@mperham

This comment has been minimized.

Contributor

mperham commented Apr 8, 2010

I spent an hour or two on it but it was a fairly large API change and I doubt I will have time to on it more. Feel free to work on it.

@siggy

This comment has been minimized.

Contributor

siggy commented May 5, 2010

Pull request sent for:
http://github.com/siggy/cassandra/commit/439ce611a1c6d15574b47780bd34d174b124dc9b

API backwards compatibility is preserved. However, enabling the new 'timestamp' option will alter the data structure returned.

>> twitter.get(:Statuses, "1")
=> #<OrderedHash {"text"=>"Nom nom nom nom nom.", "user_id"=>"5"}>
>> twitter.get(:Statuses, "1", :timestamp => true)
=> #<OrderedHash {"text"=>{"timestamp"=>1273096932561890, "value"=>"Nom nom nom nom nom."}, "user_id"=>{"timestamp"=>1273096932561890, "value"=>"5"}}>

Comments/suggestions?

@mperham

This comment has been minimized.

Contributor

mperham commented May 5, 2010

Nice!

Only thing I can think of would be an option to convert those timestamps to actual Ruby objects, rather than just raw integers. I guess if all you want to do is compare timestamps, it's not necessary.

@ryanking

This comment has been minimized.

Contributor

ryanking commented May 6, 2010

@mperham -

I assume you're talking about converting the timestamps to Time objects...

In cassandra, "timestamp" means "long that represents something like time" and not everyone uses it the same way, so I say we should just expose it as an int.

@evan

This comment has been minimized.

evan commented May 19, 2010

It is probably okay to consistently cast Timestamps in our client. People who use multiple clients will probably know what they're doing.

If you're going to use the deep hash response API, timestamp and value should be symbols.

Would it make sense to subclass String for the column names, and decorate it with an additional timestamp accessor? That way backwards compatibility could be preserved. Or maybe an explicit column struct would be better.

@ryanking

This comment has been minimized.

Contributor

ryanking commented May 20, 2010

Maybe we should extend OrderdHash with at timestamps method, so that you can do

twitter.get(:Statuses, "1").timestamps[:text] =>1273096932561890

@mrflip

This comment has been minimized.

Contributor

mrflip commented May 28, 2010

+1 to extending OrderedHash with a timestamps method rather than using the nested hash.

@tomafro

This comment has been minimized.

tomafro commented Jul 1, 2010

+1 from me also. If this isn't being worked on by anyone, I am happy to give it a go over the next fortnight

@ryanking

This comment has been minimized.

Contributor

ryanking commented Aug 23, 2010

Looks like this is dead?

@mperham

This comment has been minimized.

Contributor

mperham commented Aug 23, 2010

I no longer need this functionality. I'll defer to others.

@tomafro

This comment has been minimized.

tomafro commented Aug 24, 2010

Yeah, sorry. I looked in to adding it (seemed pretty easy), but quickly realised I had no real need for it.

@siggy

This comment has been minimized.

Contributor

siggy commented Aug 25, 2010

Pull request sent for:
http://github.com/siggy/cassandra/commit/87276cf3c44e89a1e1a5d3d8c3d064da85f2db47

OrderedHash::timestamps is itself a hash (unordered for RUBY_VERSION < 1.9):

>> twitter.get(:Statuses, "1").timestamps
=> {"text"=>1282724889876849, "user_id"=>1282724889876849} 

>> twitter.get(:Statuses, "2").timestamps
=> {"reply_to_id"=>1282724889881382, "text"=>1282724889881382, "user_id"=>1282724889881382}
@ryanking

This comment has been minimized.

Contributor

ryanking commented Aug 25, 2010

merged siggy's work. boom!

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment