forked from so-net-developer/Cassandra
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgetrange.rb
executable file
·61 lines (51 loc) · 1.05 KB
/
getrange.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env ruby
require 'rubygems'
require 'cassandra'
include Cassandra::Constants
class Cassandra1 < Cassandra
def get_schema
schema()
end
end
if ARGV[0].nil? then
puts "usage: getkey.rb keyspacename columfamily key"
keyspace = Cassandra.new("system")
keyspace.keyspaces().each { |obj|
puts obj
}
exit
end
if ARGV[1].nil? then
keyspace = Cassandra1.new(ARGV[0])
keyspace.get_schema().each { |col,property|
puts col
}
exit
end
if ARGV[2].nil? then
keyspace = Cassandra.new(ARGV[0])
keyspace.get_range(ARGV[1]).each { |obj|
puts obj.key
}
exit
end
if ARGV[3].nil? then
keyspace = Cassandra.new(ARGV[0])
keyspace.get_range(ARGV[1],:start => ARGV[2]).each { |obj|
if obj.key == ARGV[2] then
obj.columns.each { |col|
puts col.column.name
}
end
}
end
keyspace = Cassandra.new(ARGV[0])
keyspace.get_range(ARGV[1]).each { |obj|
if obj.key == ARGV[2] then
obj.columns.each { |col|
if col.column.name == ARGV[3] then
puts col.column.value
end
}
end
}