I'm getting more consistent results using Time.stamp instead of Time

From: https://github.com/fauna/cassandra/blob/master/lib/cassandra/long.rb

when NilClass, Time
        # Time.stamp is 52 bytes, so we have 12 bytes of entropy left over
        int = ((bytes || Time).stamp << 12) + rand(2**12)

I'll keep looking at this.
Thanks! :)


On Mon, Jan 3, 2011 at 10:24 PM, vicent roca daniel <sap...@gmail.com>wrote:

> The problem I think I have is that I think I'm not storing the correct
> value.
> If I do this (for example):
>
> app.insert(:NumData, 'device1-cpu', { Time.now + 1 minut => 10.to_s })
> app.insert(:NumData, 'device1-cpu', { Time.now + 1 minu => 10.to_s })
> app.insert(:NumData, 'device1-cpu', { Time.now + 1 minu => 10.to_s })
> app.insert(:NumData, 'device1-cpu', { Time.now + 1 minu => 10.to_s })
>
> and I do a get query with :start=> first_Time.now and :finish=> the second
> Time, I should get two columns, but I'm getting none.
> I suspect that the column name is not a valid Time.
>
> ¿That make sense?
> I'm really new, so please, understand me if I did something crazy :)
>
>
> On Mon, Jan 3, 2011 at 10:17 PM, Ryan King <r...@twitter.com> wrote:
>
>> On Mon, Jan 3, 2011 at 1:15 PM, vicent roca daniel <sap...@gmail.com>
>> wrote:
>> > hi,
>> > no I'n not getting any exception.
>>
>> Then what problem are you seeing?
>>
>> -ryan
>>
>> > The value gets inserted withou problem.
>> > If I try to convert to string I get:
>> > Cassandra::Comparable::TypeError: Expected "2011-01-03 22:14:40 +0100"
>> to
>> > cast to a Cassandra::Long (invalid bytecount)
>> > from
>> >
>> /Users/armandolalala/.rvm/gems/ruby-1.9.2-p0/gems/cassandra-0.9.0/lib/cassandra/long.rb:20:in
>> > `initialize'
>> > from
>> >
>> /Users/armandolalala/.rvm/gems/ruby-1.9.2-p0/gems/cassandra-0.9.0/lib/cassandra/0.6/columns.rb:10:in
>> > `new'
>> > from
>> >
>> /Users/armandolalala/.rvm/gems/ruby-1.9.2-p0/gems/cassandra-0.9.0/lib/cassandra/0.6/columns.rb:10:in
>> > `_standard_insert_mutation'
>> > from
>> >
>> /Users/armandolalala/.rvm/gems/ruby-1.9.2-p0/gems/cassandra-0.9.0/lib/cassandra/cassandra.rb:125:in
>> > `block in insert'
>> > from
>> >
>> /Users/armandolalala/.rvm/gems/ruby-1.9.2-p0/gems/cassandra-0.9.0/lib/cassandra/cassandra.rb:125:in
>> > `each'
>> > from
>> >
>> /Users/armandolalala/.rvm/gems/ruby-1.9.2-p0/gems/cassandra-0.9.0/lib/cassandra/cassandra.rb:125:in
>> > `collect'
>> > from
>> >
>> /Users/armandolalala/.rvm/gems/ruby-1.9.2-p0/gems/cassandra-0.9.0/lib/cassandra/cassandra.rb:125:in
>> > `insert'
>> > from (irb):6
>> > from /Users/armandolalala/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in
>> `<main>'
>> >
>> > On Mon, Jan 3, 2011 at 10:06 PM, Ryan King <r...@twitter.com> wrote:
>> >>
>> >> On Mon, Jan 3, 2011 at 12:56 PM, vicent roca daniel <sap...@gmail.com>
>> >> wrote:
>> >> > Hi again!
>> >> > code:
>> >> > require 'rubygems'
>> >> > require 'cassandra'
>> >> > app = Cassandra.new('AOM', servers = "127.0.0.1:9160")
>> >> > app.insert(:NumData, 'device1-cpu', { Time.now => 10.to_s })
>> >>
>> >> I'm going to assume you're getting an exception here? I think you need
>> >> to convert the time to a string.
>> >>
>> >> > ....
>> >> > storag-confl.xm.
>> >> > <Keyspace Name="AOM">
>> >> > <ColumnFamily CompareWith="LongType" Name="NumericArchive" />
>> >> > </..>
>> >> >
>> >> > Thanks!!
>> >>
>> >> -ryan
>> >
>> >
>>
>
>

Reply via email to