td-client 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ == 2011-10-03 version 0.8.3
3
+
4
+ * Added Client#tail method
5
+
6
+
2
7
  == 2011-09-13 version 0.8.2
3
8
 
4
9
  * Added APIs for scheduled queries
data/lib/td/client.rb CHANGED
@@ -99,6 +99,10 @@ class Client
99
99
  raise NotFoundError, "Table '#{db_name}.#{table_name}' does not exist"
100
100
  end
101
101
 
102
+ def tail(db_name, table_name, count, to=nil, from=nil)
103
+ @api.tail(db_name, table_name, count, to, from)
104
+ end
105
+
102
106
  # => Job
103
107
  def query(db_name, q)
104
108
  job_id = @api.hive_query(q, db_name)
data/lib/td/client/api.rb CHANGED
@@ -182,6 +182,23 @@ class API
182
182
  return type
183
183
  end
184
184
 
185
+ def tail(db, table, count, to, from)
186
+ params = {'format' => 'msgpack'}
187
+ params['count'] = count.to_s if count
188
+ params['to'] = to.to_s if to
189
+ params['from'] = from.to_s if from
190
+ code, body, res = get("/v3/table/tail/#{e db}/#{e table}", params)
191
+ if code != "200"
192
+ raise_error("Tail table failed", res)
193
+ end
194
+ require 'msgpack'
195
+ result = []
196
+ MessagePack::Unpacker.new.feed_each(body) {|row|
197
+ result << row
198
+ }
199
+ return result
200
+ end
201
+
185
202
 
186
203
  ####
187
204
  ## Job API
@@ -71,6 +71,10 @@ class Table < Model
71
71
  def delete
72
72
  @client.delete_table(@db_name, @table_name)
73
73
  end
74
+
75
+ def tail(count, to=nil, from=nil)
76
+ @client.tail(@db_name, @table_name, count, to, from)
77
+ end
74
78
  end
75
79
 
76
80
  class Schema
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
 
3
- VERSION = '0.8.2'
3
+ VERSION = '0.8.3'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 2
10
- version: 0.8.2
9
+ - 3
10
+ version: 0.8.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sadayuki Furuhashi
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-13 00:00:00 +09:00
18
+ date: 2011-10-03 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency