scout-gear 10.3.0 → 10.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +100 -657
  3. data/Rakefile +1 -0
  4. data/VERSION +1 -1
  5. data/bin/scout +1 -3
  6. data/lib/scout/association/fields.rb +170 -0
  7. data/lib/scout/association/index.rb +229 -0
  8. data/lib/scout/association/item.rb +227 -0
  9. data/lib/scout/association/util.rb +7 -0
  10. data/lib/scout/association.rb +100 -0
  11. data/lib/scout/entity/format.rb +62 -0
  12. data/lib/scout/entity/identifiers.rb +111 -0
  13. data/lib/scout/entity/object.rb +20 -0
  14. data/lib/scout/entity/property.rb +165 -0
  15. data/lib/scout/entity.rb +40 -0
  16. data/lib/scout/offsite/step.rb +2 -2
  17. data/lib/scout/{tsv/persist → persist/engine}/fix_width_table.rb +25 -33
  18. data/lib/scout/persist/engine/packed_index.rb +100 -0
  19. data/lib/scout/persist/engine/sharder.rb +219 -0
  20. data/lib/scout/{tsv/persist → persist/engine}/tkrzw.rb +0 -17
  21. data/lib/scout/{tsv/persist → persist/engine}/tokyocabinet.rb +55 -31
  22. data/lib/scout/persist/engine.rb +4 -0
  23. data/lib/scout/{tsv/persist/adapter.rb → persist/tsv/adapter/base.rb} +80 -51
  24. data/lib/scout/persist/tsv/adapter/fix_width_table.rb +106 -0
  25. data/lib/scout/persist/tsv/adapter/packed_index.rb +95 -0
  26. data/lib/scout/persist/tsv/adapter/sharder.rb +54 -0
  27. data/lib/scout/persist/tsv/adapter/tkrzw.rb +18 -0
  28. data/lib/scout/persist/tsv/adapter/tokyocabinet.rb +65 -0
  29. data/lib/scout/persist/tsv/adapter.rb +6 -0
  30. data/lib/scout/{tsv/persist → persist/tsv}/serialize.rb +5 -0
  31. data/lib/scout/persist/tsv.rb +107 -0
  32. data/lib/scout/tsv/annotation/repo.rb +83 -0
  33. data/lib/scout/tsv/annotation.rb +169 -0
  34. data/lib/scout/tsv/attach.rb +104 -20
  35. data/lib/scout/tsv/change_id/translate.rb +148 -0
  36. data/lib/scout/tsv/change_id.rb +6 -3
  37. data/lib/scout/tsv/csv.rb +85 -0
  38. data/lib/scout/tsv/dumper.rb +113 -25
  39. data/lib/scout/tsv/entity.rb +5 -0
  40. data/lib/scout/tsv/index.rb +89 -37
  41. data/lib/scout/tsv/open.rb +21 -8
  42. data/lib/scout/tsv/parser.rb +156 -91
  43. data/lib/scout/tsv/path.rb +7 -2
  44. data/lib/scout/tsv/stream.rb +48 -6
  45. data/lib/scout/tsv/transformer.rb +25 -3
  46. data/lib/scout/tsv/traverse.rb +26 -18
  47. data/lib/scout/tsv/util/process.rb +8 -1
  48. data/lib/scout/tsv/util/reorder.rb +25 -15
  49. data/lib/scout/tsv/util/select.rb +9 -1
  50. data/lib/scout/tsv/util/sort.rb +90 -2
  51. data/lib/scout/tsv/util/unzip.rb +56 -0
  52. data/lib/scout/tsv/util.rb +52 -5
  53. data/lib/scout/tsv.rb +85 -19
  54. data/lib/scout/work_queue/socket.rb +8 -0
  55. data/lib/scout/work_queue/worker.rb +22 -5
  56. data/lib/scout/work_queue.rb +38 -24
  57. data/lib/scout/workflow/definition.rb +19 -11
  58. data/lib/scout/workflow/deployment/orchestrator.rb +20 -3
  59. data/lib/scout/workflow/deployment/trace.rb +205 -0
  60. data/lib/scout/workflow/deployment.rb +1 -0
  61. data/lib/scout/workflow/documentation.rb +1 -1
  62. data/lib/scout/workflow/step/archive.rb +42 -0
  63. data/lib/scout/workflow/step/children.rb +51 -0
  64. data/lib/scout/workflow/step/config.rb +1 -1
  65. data/lib/scout/workflow/step/dependencies.rb +24 -7
  66. data/lib/scout/workflow/step/file.rb +19 -0
  67. data/lib/scout/workflow/step/info.rb +37 -9
  68. data/lib/scout/workflow/step/progress.rb +11 -2
  69. data/lib/scout/workflow/step/status.rb +8 -1
  70. data/lib/scout/workflow/step.rb +80 -25
  71. data/lib/scout/workflow/task/dependencies.rb +4 -1
  72. data/lib/scout/workflow/task/inputs.rb +91 -41
  73. data/lib/scout/workflow/task.rb +54 -57
  74. data/lib/scout/workflow/usage.rb +1 -1
  75. data/lib/scout/workflow/util.rb +4 -0
  76. data/lib/scout/workflow.rb +110 -13
  77. data/lib/scout-gear.rb +2 -0
  78. data/lib/scout.rb +0 -1
  79. data/scout-gear.gemspec +80 -23
  80. data/scout_commands/rbbt +2 -0
  81. data/test/data/person/brothers +4 -0
  82. data/test/data/person/identifiers +10 -0
  83. data/test/data/person/marriages +3 -0
  84. data/test/data/person/parents +6 -0
  85. data/test/scout/association/test_fields.rb +105 -0
  86. data/test/scout/association/test_index.rb +70 -0
  87. data/test/scout/association/test_item.rb +21 -0
  88. data/test/scout/entity/test_format.rb +19 -0
  89. data/test/scout/entity/test_identifiers.rb +58 -0
  90. data/test/scout/entity/test_object.rb +0 -0
  91. data/test/scout/entity/test_property.rb +345 -0
  92. data/test/scout/{tsv/persist → persist/engine}/test_fix_width_table.rb +0 -1
  93. data/test/scout/persist/engine/test_packed_index.rb +99 -0
  94. data/test/scout/persist/engine/test_sharder.rb +31 -0
  95. data/test/scout/persist/engine/test_tkrzw.rb +0 -0
  96. data/test/scout/persist/engine/test_tokyocabinet.rb +17 -0
  97. data/test/scout/persist/test_tsv.rb +146 -0
  98. data/test/scout/{tsv/persist/test_adapter.rb → persist/tsv/adapter/test_base.rb} +3 -4
  99. data/test/scout/persist/tsv/adapter/test_fix_width_table.rb +46 -0
  100. data/test/scout/persist/tsv/adapter/test_packed_index.rb +37 -0
  101. data/test/scout/persist/tsv/adapter/test_serialize.rb +0 -0
  102. data/test/scout/persist/tsv/adapter/test_sharder.rb +290 -0
  103. data/test/scout/persist/tsv/adapter/test_tkrzw.rb +126 -0
  104. data/test/scout/persist/tsv/adapter/test_tokyocabinet.rb +282 -0
  105. data/test/scout/persist/tsv/test_serialize.rb +12 -0
  106. data/test/scout/test_association.rb +51 -0
  107. data/test/scout/test_entity.rb +40 -0
  108. data/test/scout/test_tsv.rb +63 -4
  109. data/test/scout/test_work_queue.rb +3 -2
  110. data/test/scout/test_workflow.rb +16 -15
  111. data/test/scout/tsv/annotation/test_repo.rb +150 -0
  112. data/test/scout/tsv/change_id/test_translate.rb +178 -0
  113. data/test/scout/tsv/test_annotation.rb +52 -0
  114. data/test/scout/tsv/test_attach.rb +226 -1
  115. data/test/scout/tsv/test_change_id.rb +25 -0
  116. data/test/scout/tsv/test_csv.rb +50 -0
  117. data/test/scout/tsv/test_dumper.rb +38 -0
  118. data/test/scout/tsv/test_entity.rb +0 -0
  119. data/test/scout/tsv/test_index.rb +82 -0
  120. data/test/scout/tsv/test_open.rb +44 -0
  121. data/test/scout/tsv/test_parser.rb +70 -0
  122. data/test/scout/tsv/test_stream.rb +22 -0
  123. data/test/scout/tsv/test_transformer.rb +39 -3
  124. data/test/scout/tsv/test_traverse.rb +78 -0
  125. data/test/scout/tsv/util/test_process.rb +36 -0
  126. data/test/scout/tsv/util/test_reorder.rb +67 -0
  127. data/test/scout/tsv/util/test_sort.rb +28 -1
  128. data/test/scout/tsv/util/test_unzip.rb +32 -0
  129. data/test/scout/work_queue/test_socket.rb +4 -1
  130. data/test/scout/workflow/deployment/test_orchestrator.rb +17 -26
  131. data/test/scout/workflow/deployment/test_trace.rb +25 -0
  132. data/test/scout/workflow/step/test_archive.rb +28 -0
  133. data/test/scout/workflow/step/test_children.rb +25 -0
  134. data/test/scout/workflow/step/test_info.rb +16 -0
  135. data/test/scout/workflow/task/test_dependencies.rb +16 -16
  136. data/test/scout/workflow/task/test_inputs.rb +45 -1
  137. data/test/scout/workflow/test_definition.rb +52 -0
  138. data/test/scout/workflow/test_step.rb +57 -0
  139. data/test/scout/workflow/test_task.rb +26 -1
  140. data/test/scout/workflow/test_usage.rb +4 -4
  141. data/test/test_helper.rb +23 -1
  142. metadata +71 -14
  143. data/lib/scout/tsv/persist.rb +0 -27
  144. data/test/scout/tsv/persist/test_tkrzw.rb +0 -123
  145. data/test/scout/tsv/persist/test_tokyocabinet.rb +0 -120
  146. data/test/scout/tsv/test_persist.rb +0 -45
@@ -0,0 +1,99 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ class TestClass < Test::Unit::TestCase
5
+ def test_packed_index
6
+
7
+ TmpFile.with_file do |tmpfile|
8
+ pi = PackedIndex.new tmpfile, true, %w(i i 23s f f f f f)
9
+ 100.times do |i|
10
+ pi << [i, i+2, i.to_s * 10, rand, rand, rand, rand, rand]
11
+ end
12
+ pi << nil
13
+ pi << nil
14
+ pi.close
15
+ pi = PackedIndex.new(tmpfile, false)
16
+ 100.times do |i|
17
+ assert_equal i, pi[i][0]
18
+ assert_equal i+2, pi[i][1]
19
+ end
20
+ assert_equal nil, pi[100]
21
+ assert_equal nil, pi[101]
22
+ end
23
+ end
24
+
25
+ def __test_benchmark_bgzip
26
+ size = 1000000
27
+ density = 0.1
28
+
29
+ access = []
30
+ (size * density).to_i.times do
31
+ access << rand(size-1) + 1
32
+ end
33
+ access.sort!
34
+ access.uniq!
35
+
36
+ TmpFile.with_file do |tmpfile|
37
+ pi = PackedIndex.new tmpfile, true, %w(i i 23s f f f f f)
38
+ size.times do |i|
39
+ pi << [i, i+2, i.to_s * 10, rand, rand, rand, rand, rand]
40
+ end
41
+ pi << nil
42
+ pi << nil
43
+ pi.close
44
+
45
+ pi = PackedIndex.new(tmpfile, false)
46
+ Misc.benchmark do
47
+ access.each do |point|
48
+ assert_equal point+2, pi[point][1]
49
+ end
50
+ end
51
+
52
+ `bgzip #{tmpfile} `
53
+ `mv #{tmpfile}.gz #{tmpfile}.bgz`
54
+
55
+ pi = PackedIndex.new(tmpfile + '.bgz', false)
56
+ pi[0]
57
+ Misc.benchmark do
58
+ access.each do |point|
59
+ assert_equal point+2, pi[point][1]
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ def __test_benchmark
66
+
67
+ TmpFile.with_file do |tmpfile|
68
+ pi = PackedIndex.new tmpfile, true, %w(i i 23s f f f f f)
69
+ 100.times do |i|
70
+ pi << [i, i+2, i.to_s * 10, rand, rand, rand, rand, rand]
71
+ end
72
+ pi << nil
73
+ pi << nil
74
+ pi.close
75
+ pi = PackedIndex.new(tmpfile, false)
76
+ Misc.benchmark(1000) do
77
+ 100.times do |i|
78
+ assert_equal i, pi[i][0]
79
+ assert_equal i+2, pi[i][1]
80
+ end
81
+ end
82
+
83
+ TmpFile.with_file do |tmpfile|
84
+ tk = Persist.open_tokyocabinet tmpfile, true, :json
85
+ 100.times do |i|
86
+ tk[i] = [i, i+2, (i.to_s * 10).to_i, rand, rand, rand, rand, rand]
87
+ end
88
+ Misc.benchmark(1000) do
89
+ 100.times do |i|
90
+ assert_equal i, tk[i][0]
91
+ assert_equal i+2, tk[i][1]
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+
98
+ end
99
+
@@ -0,0 +1,31 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout/persist'
5
+
6
+ class TestSharder < Test::Unit::TestCase
7
+ def test_shard_open
8
+
9
+ TmpFile.with_file do |tmpfile|
10
+ sharder = Sharder.new tmpfile, true, :HDB do |key|
11
+ key.to_s[-1]
12
+ end
13
+
14
+ sharder["key-a"] = "a"
15
+ sharder["key-b"] = "b"
16
+ assert_equal "a", sharder["key-a"]
17
+ assert_equal "b", sharder["key-b"]
18
+
19
+ sharder = Sharder.new tmpfile, true, :HDB
20
+ sharder.shard_function = proc do |key|
21
+ key.split("-").last
22
+ end
23
+
24
+ assert_equal "a", sharder["key-a"]
25
+ assert_equal "b", sharder["key-b"]
26
+
27
+ assert_equal 2, sharder.persistence_path.glob("*").select{|f| f.include?("shard-") }.length
28
+ end
29
+ end
30
+ end
31
+
File without changes
@@ -0,0 +1,17 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ class TestScoutCabinet < Test::Unit::TestCase
5
+ def test_open
6
+ TmpFile.with_file do |tmpfile|
7
+ db = ScoutCabinet.open(tmpfile)
8
+ db["a"] = 1
9
+ assert_equal "1", db["a"]
10
+ db.close
11
+
12
+ db = ScoutCabinet.open(tmpfile, false)
13
+ assert_equal "1", db["a"]
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,146 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout/tsv'
5
+
6
+ class TestTSVPersist < Test::Unit::TestCase
7
+ def test_persist
8
+ content =<<-'EOF'
9
+ #: :sep=/\s+/#:type=:double#:merge=:concat
10
+ #Id ValueA ValueB OtherID
11
+ row1 a|aa|aaa b Id1|Id2
12
+ row2 A B Id3
13
+ row2 a a id3
14
+ EOF
15
+
16
+
17
+ tsv = Persist.persist("TEST Persist TSV", :tsv) do
18
+ TmpFile.with_file(content) do |filename|
19
+ TSV.open(filename)
20
+ end
21
+ end
22
+
23
+ assert NamedArray === tsv["row1"]
24
+
25
+ assert_include tsv.keys, 'row1'
26
+ assert_include tsv.keys, 'row2'
27
+
28
+ tsv = Persist.persist("TEST Persist TSV", :tsv) do
29
+ TmpFile.with_file(content) do |filename|
30
+ TSV.open(filename)
31
+ end
32
+ end
33
+
34
+ assert_include tsv.keys, 'row1'
35
+ assert_include tsv.keys, 'row2'
36
+
37
+ assert_nothing_raised do
38
+ tsv = Persist.persist("TEST Persist TSV", :tsv) do
39
+ raise
40
+ end
41
+ end
42
+
43
+ assert_include tsv.keys, 'row1'
44
+ assert_include tsv.keys, 'row2'
45
+ end
46
+
47
+ def test_persist_with_data
48
+ content =<<-'EOF'
49
+ #: :sep=/\s+/#:type=:double#:merge=:concat
50
+ #Id ValueA ValueB OtherID
51
+ row1 a|aa|aaa b Id1|Id2
52
+ row2 A B Id3
53
+ row2 a a id3
54
+ EOF
55
+
56
+
57
+ tsv = nil
58
+ TmpFile.with_file do |tk|
59
+ data = Persist.open_tokyocabinet(tk, true, "HDB")
60
+ assert Open.exists?(tk)
61
+ tsv = Persist.persist("TEST Persist TSV", :HDB, :persist_data => data) do |data|
62
+ t = TmpFile.with_file(content) do |filename|
63
+ TSV.open(filename, persist_data: data)
64
+ end
65
+ t
66
+ nil
67
+ end
68
+ refute Open.exists?(tk)
69
+ assert Open.exists?(data.persistence_path)
70
+ end
71
+
72
+ assert_include tsv.keys, 'row1'
73
+ assert_include tsv.keys, 'row2'
74
+
75
+ assert_nothing_raised do
76
+ tsv = Persist.persist("TEST Persist TSV", :HDB) do
77
+ raise
78
+ end
79
+ end
80
+
81
+ assert_include tsv.keys, 'row1'
82
+ assert_include tsv.keys, 'row2'
83
+ end
84
+
85
+ def test_tsv
86
+ content =<<-'EOF'
87
+ #: :sep=/\s+/#:type=:double#:merge=:concat
88
+ #Id ValueA ValueB OtherID
89
+ row1 a|aa|aaa b Id1|Id2
90
+ row2 A B Id3
91
+ row2 a a id3
92
+ EOF
93
+
94
+
95
+ tsv = nil
96
+ TmpFile.with_file(content) do |filename|
97
+ tsv = Persist.tsv("Some TSV") do |data|
98
+ TSV.open(filename, persist_data: data)
99
+ end
100
+ assert_equal ['b'], tsv["row1"][1]
101
+ assert NamedArray === tsv["row1"]
102
+ assert_equal ['b'], tsv["row1"]["ValueB"]
103
+ assert_include tsv.keys, 'row1'
104
+ assert_include tsv.keys, 'row2'
105
+ assert_nothing_raised do
106
+ tsv = Persist.tsv("Some TSV") do |data|
107
+ raise
108
+ end
109
+ end
110
+ end
111
+
112
+ assert_include tsv.keys, 'row1'
113
+ assert_include tsv.keys, 'row2'
114
+ end
115
+
116
+ def test_persist_tsv
117
+ content =<<-'EOF'
118
+ #Id ValueA ValueB OtherID
119
+ row1 a|aa|aaa b Id1|Id2
120
+ row2 A B Id3
121
+ row2 a a id3
122
+ EOF
123
+
124
+
125
+ tsv = nil
126
+ TmpFile.with_file(content) do |filename|
127
+ tsv = Persist.persist_tsv("Some TSV", sep: /\s+/, type: :double) do |data|
128
+ TSV.open(filename, sep: /\s+/, type: :double, persist_data: data)
129
+ end
130
+ assert_equal ['b'], tsv["row1"][1]
131
+ assert NamedArray === tsv["row1"]
132
+ assert_equal ['b'], tsv["row1"]["ValueB"]
133
+ assert_include tsv.keys, 'row1'
134
+ assert_include tsv.keys, 'row2'
135
+ assert_nothing_raised do
136
+ tsv = Persist.persist_tsv("Some TSV", sep: /\s+/, type: :double) do |data|
137
+ raise
138
+ end
139
+ end
140
+ end
141
+
142
+ assert_include tsv.keys, 'row1'
143
+ assert_include tsv.keys, 'row2'
144
+ end
145
+ end
146
+
@@ -1,7 +1,6 @@
1
1
  require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
2
  require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
3
 
4
- require 'scout/tsv'
5
4
  class TestTSVAdapter < Test::Unit::TestCase
6
5
  def test_get_set
7
6
  tsv = TSV.setup({}, :type => :list, :key_field => "Key", :fields => %w(one two three))
@@ -9,7 +8,6 @@ class TestTSVAdapter < Test::Unit::TestCase
9
8
  tsv.extend TSVAdapter
10
9
  tsv["a"] = %w(1 2 3)
11
10
 
12
- assert_equal %w(1 2 3) * "\t", tsv.dup["a"]
13
11
  assert_equal %w(a), tsv.keys
14
12
  assert_equal [%w(1 2 3)], tsv.collect{|k,v| v }
15
13
  assert_equal [%w(1 2 3)], tsv.values
@@ -20,7 +18,6 @@ class TestTSVAdapter < Test::Unit::TestCase
20
18
  new.extend TSVAdapter
21
19
 
22
20
  tsv = new
23
- assert_equal %w(1 2 3) * "\t", tsv.dup["a"]
24
21
  assert_equal %w(a), tsv.keys
25
22
  assert_equal [%w(1 2 3)], tsv.collect{|k,v| v }
26
23
  assert_equal [%w(1 2 3)], tsv.values
@@ -35,10 +32,12 @@ class TestTSVAdapter < Test::Unit::TestCase
35
32
  tsv = TSV.setup({}, :type => :list, :key_field => "Key", :fields => %w(one two three))
36
33
  tsv.type = :list
37
34
  tsv.extend TSVAdapter
38
- tsv.serializer = :integer_array
35
+ tsv.serializer = :marshal
39
36
  tsv["a"] = [1, 2, 3]
40
37
 
38
+
41
39
  assert_equal [1, 2, 3], tsv["a"]
40
+ assert_equal [1, 2, 3], Marshal.load(tsv.orig_get("a"))
42
41
  end
43
42
  end
44
43
 
@@ -0,0 +1,46 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout/tsv'
5
+ class TestFixWidthTable < Test::Unit::TestCase
6
+ def load_data(data)
7
+ tsv = TSV.open(data, type: :list, :sep=>":", :cast => proc{|e| e =~ /(\s*)(_*)/; ($1.length..($1.length + $2.length - 1))})
8
+ tsv.add_field "Start" do |key, values|
9
+ values["Range"].first
10
+ end
11
+ tsv.add_field "End" do |key, values|
12
+ values["Range"].last
13
+ end
14
+
15
+ tsv = tsv.slice ["Start", "End"]
16
+
17
+ tsv
18
+ end
19
+
20
+ def test_open_fwt
21
+ data =<<-EOF
22
+ ##012345678901234567890
23
+ #ID:Range
24
+ a: ______
25
+ b: ______
26
+ c: _______
27
+ d: ____
28
+ e: ______
29
+ f: ___
30
+ g: ____
31
+ EOF
32
+ TmpFile.with_file(data) do |datafile|
33
+ tsv = load_data(datafile)
34
+ TmpFile.with_file do |filename|
35
+ f = Persist.open_fwt filename, 100, true
36
+ f.add_range tsv
37
+ f.read
38
+
39
+ assert_equal %w(), f.overlaps(0).sort
40
+ assert_equal %w(1:6), f.overlaps(1).sort
41
+ assert_equal %w(1:6:b), f.overlaps(1, true).sort
42
+ end
43
+ end
44
+ end
45
+ end
46
+
@@ -0,0 +1,37 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ class TestClass < Test::Unit::TestCase
5
+ def test_open
6
+ TmpFile.with_file do |tmpfile|
7
+ pi = Persist.open_pki tmpfile, true, %w(i i 23s f f f f f)
8
+ 100.times do |i|
9
+ pi << [i, i+2, i.to_s * 10, rand, rand, rand, rand, rand]
10
+ end
11
+ pi << nil
12
+ pi << nil
13
+ pi.close
14
+
15
+ TSV.setup(pi, :key_field => "Number", :fields => %w(i i2 s f1 f2 f3 f4 f5), :type => :list)
16
+
17
+ pi = PackedIndex.new(tmpfile, false)
18
+ 100.times do |i|
19
+ assert_equal i, pi[i][0]
20
+ assert_equal i+2, pi[i][1]
21
+ end
22
+ assert_equal nil, pi[100]
23
+ assert_equal nil, pi[101]
24
+
25
+ pi = Persist.open_pki tmpfile, false, %w(i i 23s f f f f f)
26
+ 100.times do |i|
27
+ assert_equal i, pi[i][0]
28
+ assert_equal i+2, pi[i][1]
29
+ end
30
+ assert_equal nil, pi[100]
31
+ assert_equal nil, pi[101]
32
+
33
+ assert_equal "Number", pi.key_field
34
+ end
35
+ end
36
+ end
37
+
File without changes