td 0.10.20 → 0.10.21
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -0
- data/lib/td/command/import.rb +5 -5
- data/lib/td/command/list.rb +2 -0
- data/lib/td/command/sample.rb +33 -0
- data/lib/td/version.rb +1 -1
- metadata +13 -12
data/ChangeLog
CHANGED
data/lib/td/command/import.rb
CHANGED
@@ -24,7 +24,7 @@ module Command
|
|
24
24
|
op.banner << " json\n"
|
25
25
|
|
26
26
|
format = 'apache'
|
27
|
-
time_key =
|
27
|
+
time_key = 'time'
|
28
28
|
|
29
29
|
op.on('--format FORMAT', "file format (default: #{format})") {|s|
|
30
30
|
format = s
|
@@ -56,10 +56,10 @@ module Command
|
|
56
56
|
|
57
57
|
case format
|
58
58
|
when 'json', 'msgpack'
|
59
|
-
unless time_key
|
60
|
-
|
61
|
-
|
62
|
-
end
|
59
|
+
#unless time_key
|
60
|
+
# $stderr.puts "-t, --time-key COL_NAME (e.g. '-t created_at') parameter is required for #{format} format"
|
61
|
+
# exit 1
|
62
|
+
#end
|
63
63
|
if format == 'json'
|
64
64
|
require 'json'
|
65
65
|
require 'time'
|
data/lib/td/command/list.rb
CHANGED
@@ -265,6 +265,8 @@ module List
|
|
265
265
|
|
266
266
|
add_list 'server:status', %w[], 'Show status of the Treasure Data server'
|
267
267
|
|
268
|
+
add_list 'sample:apache', %w[path.json], 'Create a sample log file'
|
269
|
+
|
268
270
|
add_list 'help:all', %w[], 'Show usage of all commands'
|
269
271
|
add_list 'help', %w[command], 'Show usage of a command'
|
270
272
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
module TreasureData
|
3
|
+
module Command
|
4
|
+
|
5
|
+
def sample_apache(op)
|
6
|
+
fname = op.cmd_parse
|
7
|
+
|
8
|
+
require 'json'
|
9
|
+
|
10
|
+
t = Time.now.to_i
|
11
|
+
i = 0
|
12
|
+
last_time = nil
|
13
|
+
|
14
|
+
data = File.join(File.dirname(__FILE__), '../../../data/sample_apache.json')
|
15
|
+
File.open(data) {|df|
|
16
|
+
File.open(fname, 'w') {|of|
|
17
|
+
df.each_line {|line|
|
18
|
+
record = JSON.parse(line)
|
19
|
+
record['time'] = last_time = (t - (i**1.3)).to_i
|
20
|
+
of.puts record.to_json
|
21
|
+
i += 1
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
$stderr.puts "Create #{fname} with #{i} records whose time is"
|
27
|
+
$stderr.puts "from #{Time.at(last_time)} to #{Time.at(t)}."
|
28
|
+
$stderr.puts "Use '#{$prog} table:import <db> <table> --json #{fname}' to import this file."
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
data/lib/td/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: td
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.21
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-04 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: msgpack
|
16
|
-
requirement: &
|
16
|
+
requirement: &70131070404920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70131070404920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70131070404060 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.4.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70131070404060
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: hirb
|
38
|
-
requirement: &
|
38
|
+
requirement: &70131070401640 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.4.5
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70131070401640
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: td-client
|
49
|
-
requirement: &
|
49
|
+
requirement: &70131070399480 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.8.14
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70131070399480
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: td-logger
|
60
|
-
requirement: &
|
60
|
+
requirement: &70131070397240 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 0.3.8
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70131070397240
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
executables:
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/td/command/query.rb
|
89
89
|
- lib/td/command/result.rb
|
90
90
|
- lib/td/command/runner.rb
|
91
|
+
- lib/td/command/sample.rb
|
91
92
|
- lib/td/command/sched.rb
|
92
93
|
- lib/td/command/schema.rb
|
93
94
|
- lib/td/command/server.rb
|