rbbt-util 5.17.20 → 5.17.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58cd900e8238a97baf230cbb81502f4c3aca35ba
4
- data.tar.gz: fb08bda42782f76c8dd4a8b2b338d5ebc74a2038
3
+ metadata.gz: 557142d92147d54d45af152135df1fe1743002bd
4
+ data.tar.gz: 5f56410a030766911e3ca59be65a887a84925636
5
5
  SHA512:
6
- metadata.gz: bc6c3a7db160f46f55c8cfd7ab266168cc688045077bab418ca5ea0c146e162c89f4b1fdfb41cecb7268f73f5e23e689edeff342b647325ef172f68f4e5d493d
7
- data.tar.gz: fa5201d4762db7bba332aa5d0fce2e41c540447793fda061436405e6af902d15ede743197481c2134df90081f889ba7e0636aea169aa0819763e8fdf96e41338
6
+ metadata.gz: a58ff556d9be4894195d4e317ef7d9f0fb82bca320b7f03804355fb8d7eda0e72307caa50fb432fe1451d4d55ca40d03da5f20d059e105a4cd89044bdbe15ad1
7
+ data.tar.gz: 79582eaa89d75dccbce3396e71553b4ab3fad049d8787daaa6a6fc93a6fbac0309d0f277639f05faeb6b71ca779d9aeb4d1ec0ad96407ddfd7af30f2ffb06891
@@ -59,133 +59,8 @@ module Persist
59
59
  @closed = false
60
60
  self
61
61
  end
62
-
63
- #MAX_CHAR = 255.chr
64
-
65
- #def prefix(key)
66
- # range(key, 1, key + MAX_CHAR, 1)
67
- #end
68
-
69
- #def get_prefix(key)
70
- # keys = prefix(key)
71
- # select(:key => keys)
72
- #end
73
-
74
- #def closed?
75
- # @closed
76
- #end
77
-
78
- #def close
79
- # @closed = true
80
- # super
81
- #end
82
-
83
- #def read(force = false)
84
- # return if not write? and not closed and not force
85
- # self.close
86
- # if !self.open(@persistence_path, tokyocabinet_class::OREADER)
87
- # ecode = self.ecode
88
- # raise "Open error: #{self.errmsg(ecode)}. Trying to open file #{@persistence_path}"
89
- # end
90
- # @writable = false
91
- # @closed = false
92
- # self
93
- #end
94
-
95
- #def write(force = true)
96
- # return if write? and not closed and not force
97
- # self.close
98
-
99
- # if !self.open(@persistence_path, tokyocabinet_class::OWRITER)
100
- # ecode = self.ecode
101
- # raise "Open error: #{self.errmsg(ecode)}. Trying to open file #{@persistence_path}"
102
- # end
103
-
104
- # @writable = true
105
- # @closed = false
106
- # self
107
- #end
108
-
109
- #def write?
110
- # @writable
111
- #end
112
-
113
- #def read?
114
- # ! write?
115
- #end
116
-
117
- #def collect
118
- # res = []
119
- # each do |key, value|
120
- # res << if block_given?
121
- # yield key, value
122
- # else
123
- # [key, value]
124
- # end
125
- # end
126
- # res
127
- #end
128
-
129
- #def delete(key)
130
- # out(key)
131
- #end
132
-
133
- #def write_and_read
134
- # lock_filename = Persist.persistence_path(persistence_path + '.write', {:dir => TSV.lock_dir})
135
- # Misc.lock(lock_filename) do
136
- # @mutex.synchronize do
137
- # write if @closed or not write?
138
- # res = begin
139
- # yield
140
- # ensure
141
- # read
142
- # end
143
- # res
144
- # end
145
- # end
146
- #end
147
-
148
- #def write_and_close
149
- # lock_filename = Persist.persistence_path(persistence_path + '.write', {:dir => TSV.lock_dir})
150
- # Misc.lock(lock_filename) do
151
- # @mutex.synchronize do
152
- # write if @closed or not write?
153
- # res = begin
154
- # yield
155
- # ensure
156
- # close
157
- # end
158
- # res
159
- # end
160
- # end
161
- #end
162
-
163
- #def read_and_close
164
- # @mutex.synchronize do
165
- # read if @closed or not read?
166
- # res = begin
167
- # yield
168
- # ensure
169
- # close
170
- # end
171
- # res
172
- # end
173
- #end
174
-
175
-
176
- #def merge!(hash)
177
- # hash.each do |key,values|
178
- # self[key] = values
179
- # end
180
- #end
181
-
182
-
183
- #def range(*args)
184
- # super(*args) #- TSV::ENTRY_KEYS.to_a
185
- #end
186
62
  end
187
63
 
188
-
189
64
  def self.open_tokyocabinet(path, write, serializer = nil, tokyocabinet_class = TokyoCabinet::HDB)
190
65
  write = true unless File.exists? path
191
66
 
@@ -192,4 +192,63 @@ module Misc
192
192
  end
193
193
  end
194
194
 
195
+
196
+ def self.intersect_streams_read(io, sep=":")
197
+ line = io.gets.strip
198
+ parts = line.split(sep)
199
+ chr, start, eend, *rest = parts
200
+ [line,chr, start.to_i, eend.to_i, rest]
201
+ end
202
+
203
+ def self.intersect_streams(f1, f2, out, sep=":")
204
+ finish = false
205
+ line1, chr1, start1, eend1, rest1 = intersect_streams_read(f1,sep)
206
+ line2, chr2, start2, eend2, rest2 = intersect_streams_read(f2,sep)
207
+ Misc.profile do
208
+ while not finish
209
+ case chr1 <=> chr2
210
+ when -1
211
+ move = 1
212
+ when 1
213
+ move = 2
214
+ else
215
+ if eend1 < start2
216
+ move = 1
217
+ elsif eend2 < start1
218
+ move = 2
219
+ else
220
+ pos2 = f2.pos
221
+
222
+ sline2, schr2, sstart2, seend2, srest2 = line2, chr2, start2, eend2, rest2
223
+ while chr1 == chr2 and ((start1 <= eend2 and eend1 >= start2))
224
+ out.puts line1 + "\t" + line2
225
+ if f2.eof?
226
+ chr2 = 'next2'
227
+ else
228
+ line2, chr2, start2, eend2, rest2 = intersect_streams_read(f2,sep)
229
+ end
230
+ end
231
+ line2, chr2, start2, eend2, rest2 = sline2, schr2, sstart2, seend2, srest2
232
+ f2.seek(pos2)
233
+ move = 1
234
+ end
235
+ end
236
+
237
+ case move
238
+ when 1
239
+ if f1.eof?
240
+ finish = true
241
+ else
242
+ line1, chr1, start1, eend1, rest1 = intersect_streams_read(f1,sep)
243
+ end
244
+ when 2
245
+ if f2.eof?
246
+ finish = true
247
+ else
248
+ line2, chr2, start2, eend2, rest2 = intersect_streams_read(f2,sep)
249
+ end
250
+ end
251
+ end
252
+ end
253
+ end
195
254
  end
@@ -518,7 +518,7 @@ module Workflow
518
518
  workflow, task, options = dependency
519
519
 
520
520
  #options = dependency.last if Hash === dependency.last
521
- _inputs = inputs.dup
521
+ _inputs = IndiferentHash.setup(inputs.dup)
522
522
  options.each{|i,v|
523
523
  case v
524
524
  when Symbol
@@ -544,9 +544,11 @@ module Workflow
544
544
  when Step
545
545
  dependency
546
546
  when Symbol
547
- job(dependency, jobname, inputs)
547
+ _inputs = IndiferentHash.setup(inputs.dup)
548
+ job(dependency, jobname, _inputs)
548
549
  when Proc
549
- dependency.call jobname, inputs, real_dependencies
550
+ _inputs = IndiferentHash.setup(inputs.dup)
551
+ dependency.call jobname, _inputs, real_dependencies
550
552
  end
551
553
  end
552
554
  real_dependencies.flatten.compact
data/lib/rbbt/workflow.rb CHANGED
@@ -279,7 +279,7 @@ module Workflow
279
279
  task = tasks[taskname]
280
280
  raise "Task not found: #{ taskname }" if task.nil?
281
281
 
282
- IndiferentHash.setup(inputs)
282
+ inputs = IndiferentHash.setup(inputs)
283
283
 
284
284
  Workflow.resolve_locals(inputs)
285
285
 
@@ -239,4 +239,23 @@ class TestPersistTSVTC < Test::Unit::TestCase
239
239
  assert_equal "2", persisted_annotations.sort.last.test_annotation
240
240
  end
241
241
  end
242
+
243
+ def test_fdb
244
+ TmpFile.with_file do |tmp|
245
+ repo = Persist.open_tokyocabinet(tmp, true, :list, TokyoCabinet::FDB)
246
+ repo.write
247
+ repo.put(1, "hola")
248
+ repo.put(2, "adios")
249
+ 47000.times do |i|
250
+ repo.put(i*500, "key: " << i.to_s)
251
+ end
252
+ repo.read
253
+ Misc.profile do
254
+ repo.values_at *repo.range("[100,1000]")
255
+ end
256
+ Misc.benchmark(60_000) do
257
+ repo.values_at *repo.range("[100,1000]")
258
+ end
259
+ end
260
+ end
242
261
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.17.20
4
+ version: 5.17.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-29 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake