Re: Insert LongType with ruby

2011-01-04 Thread vicent roca daniel
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.comwrote:

 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
 
 





Re: Insert LongType with ruby

2011-01-04 Thread Ryan King
On Tue, Jan 4, 2011 at 12:50 PM, vicent roca daniel sap...@gmail.com wrote:
 I'm getting more consistent results using Time.stamp instead of Time
 From: https://github.com/fauna/cassandra/blob/master/lib/cassandra/long.rb

Yeah, you were probably overwriting values then.

-ryan


Re: Insert LongType with ruby

2011-01-04 Thread vicent roca daniel
I don't know.
Looking the table with de cli I see this results:

Using app.insert(:Numers, 'device1-cpu', {Time.now = i.to_s }) :

= (column=5300944406187227576, value=3, timestamp=1294175880417061)
= (column=5300944406181604704, value=2, timestamp=1294175880415584)
= (column=5300944406071978530, value=1, timestamp=1294175880413584)


Using app.insert(:Numers, 'device1-cpu', {Time.stamp = i.to_s }) :

= (column=1294176156967820, value=3, timestamp=1294176156967851)
= (column=1294176156966904, value=2, timestamp=1294176156966949)
= (column=1294176156957286, value=1, timestamp=1294176156965795)

Which I think it makes more sense since this columns names are timestamps.
I'll keep working on this.
Thanks for your help ryan :)



On Tue, Jan 4, 2011 at 10:18 PM, Ryan King r...@twitter.com wrote:

 On Tue, Jan 4, 2011 at 12:50 PM, vicent roca daniel sap...@gmail.com
 wrote:
  I'm getting more consistent results using Time.stamp instead of Time
  From:
 https://github.com/fauna/cassandra/blob/master/lib/cassandra/long.rb

 Yeah, you were probably overwriting values then.

 -ryan



Re: Insert LongType with ruby

2011-01-03 Thread Ryan King
On Sun, Jan 2, 2011 at 3:45 PM, vicent roca daniel sap...@gmail.com wrote:
 Hi guys, I need your help.
 I'm trying to insert a column name of type LongType using the ruby wrapper,
 but I can't get it working.
 What I'm trying is something like this:
    app.insert(:Data, 'device1-cpu', { Time.now = 1234.to_s})
 The columnNames are tye TimeStamp. this way I got an ordened record by time.
 I think I'm not inserting a correct value here. ¿any thoughts ?

What error are you getting?

-ryan


Re: Insert LongType with ruby

2011-01-03 Thread vicent roca daniel
hi,
no I'n not getting any exception.
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



Re: Insert LongType with ruby

2011-01-03 Thread Ryan King
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




Re: Insert LongType with ruby

2011-01-03 Thread vicent roca daniel
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