marty 1.2.4 → 1.2.5

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: 7a63225a41641bfe7a573dd21373cef1746df111
4
- data.tar.gz: 46359fc851683968330d72b02a5695072ea81eec
3
+ metadata.gz: 7de135b5a4bf224982326860d6741402abea2d23
4
+ data.tar.gz: c24dfff6a7c31694b37ef0e6f0d0cae4ef843db3
5
5
  SHA512:
6
- metadata.gz: 456016ef7f36a7474dcf5ce564b5616c2616525701db782a6f6582e9e3d638627b41c027838c603c89bec34f723ccac9b7cc94a6e59768a8c24b762d62efa27a
7
- data.tar.gz: d1ba3c2c1366c034d76629ab4643a85ffd11d2d06400111fb30f33cf974a9b6ff6c8d43a55dda9bee7a964fd3a684c4e33b1aa14c50aeac477e745d1597c0ba4
6
+ metadata.gz: 8a2649e6ea371e5dccc52aaa50ae0f9db245657f2ad0dc56ee65c8a7d1a823af0f2c97272dce953486f69a95420abe0e6ec5e42ab7604e57507e30f544202ffc
7
+ data.tar.gz: 298317fcd41ef5fee4d9687439a56e19c7f31ffe5cffbc55b4256f7f2adc2dcf67c558866d5a41cb69eb21969129f4fcf57047545dd383d96f5463d474be30dc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- marty (1.2.3)
4
+ marty (1.2.5)
5
5
  axlsx (= 2.1.0pre)
6
6
  coderay
7
7
  delorean_lang (~> 0.3.33)
@@ -83,7 +83,7 @@ GEM
83
83
  delayed_job_active_record (4.1.2)
84
84
  activerecord (>= 3.0, < 5.2)
85
85
  delayed_job (>= 3.0, < 5)
86
- delorean_lang (0.3.34)
86
+ delorean_lang (0.3.36)
87
87
  activerecord (>= 3.2)
88
88
  treetop (~> 1.5)
89
89
  diff-lcs (1.3)
@@ -89,6 +89,13 @@ class Marty::DataGrid < Marty::Base
89
89
  gen_mcfly_lookup :lookup, [:name], cache: true
90
90
  gen_mcfly_lookup :get_all, [], mode: nil
91
91
 
92
+ cached_delorean_fn :lookup_h, sig: [2,3] do
93
+ |pt, name, fields = %w(id group_id created_dt metadata data_type)|
94
+
95
+ dga = get_all(pt).where(name: name).pluck(*fields).first
96
+ dga && Hash[fields.zip(dga)]
97
+ end
98
+
92
99
  cached_mcfly_lookup :lookup_id, sig: 2 do
93
100
  |pt, group_id|
94
101
  find_by_group_id group_id
@@ -157,15 +164,18 @@ class Marty::DataGrid < Marty::Base
157
164
 
158
165
  PLV_DT_FMT = "%Y-%m-%d %H:%M:%S.%N6"
159
166
 
160
- def plv_lookup_grid_distinct(h_passed, ret_grid_data=false, distinct=true)
167
+ def self.plv_lookup_grid_distinct(h_passed, dgh, ret_grid_data=false,
168
+ distinct=true)
169
+ cd = dgh["created_dt"]
170
+ @@dtcache ||= {}
171
+ @@dtcache[cd] ||= cd.strftime(PLV_DT_FMT)
161
172
  row_info = {
162
- "id" => id,
163
- "group_id" => group_id,
164
- "created_dt" => (
165
- @@dtcache ||= {})[created_dt] ||= created_dt.strftime(PLV_DT_FMT)
173
+ "id" => dgh["id"],
174
+ "group_id" => dgh["group_id"],
175
+ "created_dt" => @@dtcache[cd]
166
176
  }
167
177
 
168
- h = metadata.each_with_object({}) do |m, h|
178
+ h = dgh["metadata"].each_with_object({}) do |m, h|
169
179
  attr = m["attr"]
170
180
  inc = h_passed.fetch(attr, :__nf__)
171
181
  next if inc == :__nf__
@@ -196,7 +206,8 @@ class Marty::DataGrid < Marty::Base
196
206
  end
197
207
 
198
208
  if ret_grid_data
199
- md, mmd = modify_grid(h_passed)
209
+ dg = find(dgh["id"])
210
+ md, mmd = modify_grid(h_passed, dg.metadata, dg.data)
200
211
  res["data"] = md
201
212
  res["metadata"] = mmd
202
213
  end
@@ -206,12 +217,26 @@ class Marty::DataGrid < Marty::Base
206
217
  # FIXME: added for Apollo -- not sure where this belongs given that
207
218
  # DGs were moved to marty. Should add documentation about callers
208
219
  # keeping the hash small.
220
+ # DEPRECATED: should use lookup_grid_h instead
209
221
  cached_delorean_fn :lookup_grid, sig: 4 do
210
222
  |pt, dg, h, distinct|
211
223
  raise "bad DataGrid #{dg}" unless Marty::DataGrid === dg
212
224
  raise "non-hash arg #{h}" unless Hash === h
213
225
 
214
- res = dg.plv_lookup_grid_distinct(h, false, distinct)
226
+ warn "DEPRECATED: lookup_grid. Use lookup_grid_h instead"
227
+
228
+ dgh = dg.attributes.slice("id","group_id","created_dt",
229
+ "metadata", "data_type")
230
+ res = plv_lookup_grid_distinct(h, dgh, false, distinct)
231
+ res["result"]
232
+ end
233
+
234
+ cached_delorean_fn :lookup_grid_h, sig: 4 do
235
+ |pt, dgh, h, distinct|
236
+ raise "bad DataGrid #{dgh}" unless Hash === dgh
237
+ raise "non-hash arg #{h}" unless Hash === h
238
+
239
+ res = plv_lookup_grid_distinct(h, dgh, false, distinct)
215
240
  res["result"]
216
241
  end
217
242
 
@@ -227,8 +252,8 @@ class Marty::DataGrid < Marty::Base
227
252
  end
228
253
  end
229
254
 
230
- def lookup_grid_distinct_entry(pt, h, visited=nil, follow=true,
231
- return_grid_data=false)
255
+ delorean_fn :lookup_grid_distinct_entry_h, sig: [3,6] do
256
+ |pt, h, dgh, visited=nil, follow=true, return_grid_data=false|
232
257
 
233
258
  # Perform grid lookup, if result is another data_grid, and follow is true,
234
259
  # then perform lookup on the resulting grid. Allows grids to be nested
@@ -240,33 +265,50 @@ class Marty::DataGrid < Marty::Base
240
265
  # "name" => <grid name>
241
266
  # "data" => <grid's data array>
242
267
  # "metadata" => <grid's metadata (array of hashes)>
268
+ vhash = plv_lookup_grid_distinct(h, dgh, return_grid_data)
243
269
 
244
- vhash = plv_lookup_grid_distinct(h, return_grid_data)
245
-
246
- return vhash if vhash["result"].nil? || !data_type
270
+ next vhash if vhash["result"].nil? || !dgh['data_type']
247
271
 
248
- c_data_type = Marty::DataGrid.convert_data_type(data_type)
272
+ c_data_type = Marty::DataGrid.convert_data_type(dgh['data_type'])
249
273
 
250
- return vhash if String === c_data_type
274
+ next vhash if String === c_data_type
251
275
 
252
276
  res = vhash["result"]
253
277
 
254
- v = Marty::PgEnum === res ?
255
- c_data_type.find_by_name(res) :
256
- Marty::DataConversion.find_row(c_data_type, {"name" => res}, pt)
278
+ v = case
279
+ when Marty::PgEnum === res
280
+ c_data_type.find_by_name(res)
281
+ when Marty::DataGrid == c_data_type
282
+ follow ?
283
+ Marty::DataGrid.lookup_h(pt, res) :
284
+ Marty::DataGrid.lookup(pt, res)
285
+ else
286
+ Marty::DataConversion.find_row(c_data_type, {"name" => res}, pt)
287
+ end
257
288
 
258
- return vhash.merge({"result" => v}) unless (Marty::DataGrid === v && follow)
289
+ next vhash.merge({"result" => v}) unless (Marty::DataGrid == c_data_type &&
290
+ follow)
259
291
 
260
292
  visited ||= []
261
293
 
262
- visited << self.group_id
294
+ visited << dgh['group_id']
263
295
 
264
296
  raise "#{self.class} recursion loop detected -- #{visited}" if
265
- visited.member?(v.group_id)
297
+ visited.member?(v['group_id'])
266
298
 
267
- v.lookup_grid_distinct_entry(pt, h, visited, follow, return_grid_data)
299
+ lookup_grid_distinct_entry_h(pt, h, v, visited, follow, return_grid_data)
268
300
  end
269
301
 
302
+ # DEPRECATED: use lookup_grid_distinct_entry_h instead
303
+ def lookup_grid_distinct_entry(pt, h, visited=nil, follow=true,
304
+ return_grid_data=false)
305
+ warn "DEPRECATED: instance method lookup_grid_distinct_entry. "\
306
+ "Use class method lookup_grid_distinct_entry_h instead"
307
+ dgh = self.attributes.slice("id","group_id","created_dt",
308
+ "metadata", "data_type")
309
+ self.class.lookup_grid_distinct_entry_h(pt, h, dgh, visited, follow,
310
+ return_grid_data)
311
+ end
270
312
  delorean_instance_method :lookup_grid_distinct_entry,
271
313
  [[Date, Time, ActiveSupport::TimeWithZone], Hash]
272
314
 
@@ -580,7 +622,7 @@ class Marty::DataGrid < Marty::Base
580
622
  end
581
623
  end
582
624
 
583
- def modify_grid(params)
625
+ def self.modify_grid(params, metadata, data)
584
626
  removes = ["h", "v"].each_with_object({}) {|dir, hash| hash[dir] = Set.new}
585
627
 
586
628
  metadata_copy, data_copy = metadata.deep_dup, data.deep_dup
@@ -627,13 +669,13 @@ class Marty::DataGrid < Marty::Base
627
669
  end
628
670
 
629
671
  private
630
- def remove_indices(orig_array, inds)
672
+ def self.remove_indices(orig_array, inds)
631
673
  orig_array.each_with_object([]).with_index do |(item, new_array), index|
632
674
  new_array.push(item) unless inds.include?(index)
633
675
  end
634
676
  end
635
677
 
636
- def opposite_sign(op) # toggle sign and inclusivity
678
+ def self.opposite_sign(op) # toggle sign and inclusivity
637
679
  {
638
680
  :< => :>=,
639
681
  :<= => :>,
@@ -642,7 +684,7 @@ class Marty::DataGrid < Marty::Base
642
684
  }[op]
643
685
  end
644
686
 
645
- def compute_numeric_mods(keys, op, val)
687
+ def self.compute_numeric_mods(keys, op, val)
646
688
  @keyhash ||= {}
647
689
  prune_a, rewrite_a = [], []
648
690
 
@@ -695,7 +737,7 @@ class Marty::DataGrid < Marty::Base
695
737
  end
696
738
 
697
739
  # value is a list of what to keep
698
- def compute_set_mods(keys, val)
740
+ def self.compute_set_mods(keys, val)
699
741
  prune_a, rewrite_a, value = [], [], Array(val)
700
742
 
701
743
  keys.each_with_index do |key, index|
@@ -718,7 +760,7 @@ class Marty::DataGrid < Marty::Base
718
760
  [prune_a, rewrite_a]
719
761
  end
720
762
 
721
- def parse_range(key)
763
+ def self.parse_range(key)
722
764
  match = key.match(/\A(\[|\()([0-9\.-]*),([0-9\.-]*)(\]|\))\z/)
723
765
  raise "unrecognized pattern #{key}" unless match
724
766
 
@@ -730,7 +772,7 @@ class Marty::DataGrid < Marty::Base
730
772
  [lboundary == '(' ? :> : :>=, lhv, rhv, rboundary == ')' ? :< : :<=]
731
773
  end
732
774
 
733
- def rewrite_range(lb, lhv, rhv, rb)
775
+ def self.rewrite_range(lb, lhv, rhv, rb)
734
776
  lboundary = lb == :> ? '(' : '['
735
777
 
736
778
  # even though numranges are float type, we don't want to output ".0"
@@ -742,7 +784,7 @@ class Marty::DataGrid < Marty::Base
742
784
  lboundary + lvalue + ',' + rvalue + rboundary
743
785
  end
744
786
 
745
- def parse_bounds(key)
787
+ def self.parse_bounds(key)
746
788
  match = key.match(/\A *(<|>|<=|>=)? *([a-z_]+) *\z/)
747
789
  raise "unrecognized pattern #{key}" unless match
748
790
 
@@ -100,8 +100,9 @@ class Marty::DeloreanRule < Marty::BaseRule
100
100
  grid_results = grids.each_with_object({}) do |(gvar, gname), h|
101
101
  usename = eclass.grid_final_name(gvar)
102
102
  next h[usename] = gres[gname] if gres[gname]
103
- dg = Marty::DataGrid.lookup(pt,gname)
104
- dgr = dg && dg.lookup_grid_distinct_entry(pt, dgparams)
103
+ dg = Marty::DataGrid.lookup_h(pt,gname)
104
+ dgr = dg && Marty::DataGrid.lookup_grid_distinct_entry_h(pt, dgparams,
105
+ dg)
105
106
  h[usename] = gres[gname] = dgr["result"] if dgr
106
107
  end
107
108
  end
@@ -141,8 +141,10 @@ class Marty::Script < Marty::Base
141
141
 
142
142
  engine = Marty::ScriptSet.new(tag).get_engine(script)
143
143
  # IMPORTANT: engine evals (e.g. eval_to_hash) modify the
144
- # params. So, need to clone it.
145
- engine.evaluate(node, attr, params.clone)
144
+ # params, but it is possible that we may be passing in
145
+ # a frozen hash. To avoid performance impacts, we should first check if
146
+ # params is frozen to decide whether to dup (frozen) or clone (not frozen).
147
+ engine.evaluate(node, attr, params.frozen? ? params.dup : params.clone)
146
148
  end
147
149
 
148
150
  delorean_fn :pretty_print, sig: 1 do
@@ -49,12 +49,12 @@ class Marty::RuleScriptSet < Delorean::AbstractContainer
49
49
  else
50
50
  h[dgid] = dgname
51
51
  h["#{dgid}_dg__"] = <<~EOS
52
- Marty::DataGrid.lookup(pt,#{dgid}) ||
52
+ Marty::DataGrid.lookup_h(pt,#{dgid}) ||
53
53
  ERR("grid '#{dgid}' ('%s') not found" % #{dgid})
54
54
  EOS
55
55
  h["#{dgid}_dgp__"] = "dgparams__ + \n" + self.class.indent(paramify_h(h))
56
- lgde = "lookup_grid_distinct_entry"
57
- h["#{dgid}_h__"] = "#{dgid}_dg__.#{lgde}(pt,#{dgid}_dgp__)"
56
+ lgde = "lookup_grid_distinct_entry_h"
57
+ h["#{dgid}_h__"] = "Marty::DataGrid.#{lgde}(pt,#{dgid}_dgp__,#{dgid}_dg__)"
58
58
  h[final_name] = "#{dgid}_h__ && #{dgid}_h__.result"
59
59
  cache[dgname] = final_name
60
60
  end
data/lib/marty/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Marty
2
- VERSION = "1.2.4"
2
+ VERSION = "1.2.5"
3
3
  end
@@ -20,7 +20,6 @@ class Marty::Diagnostic::Aws::Ec2Instance
20
20
  @nodes = get_private_ips
21
21
  end
22
22
 
23
- private
24
23
  def self.get url
25
24
  uri = URI.parse(url)
26
25
  request = Net::HTTP.new(uri.host, uri.port)
@@ -90,11 +89,21 @@ class Marty::Diagnostic::Aws::Ec2Instance
90
89
  end
91
90
 
92
91
  def get_private_ips
93
- get_instances['reservationSet']['item'].map{
94
- |i|
95
- item = i['instancesSet']['item']
96
- item.is_a?(Array) ? item.map{|i| i['privateIpAddress']} :
97
- item['privateIpAddress']
98
- }.flatten
92
+ begin
93
+ reservation_set_item = get_instances['reservationSet']['item']
94
+ reservation_set_item = [reservation_set_item] unless
95
+ reservation_set_item.is_a?(Array)
96
+
97
+ reservation_set_item.map{
98
+ |i|
99
+ instances_set_item = i['instancesSet']['item']
100
+ instances_set_item = [instances_set_item] unless
101
+ instances_set_item.is_a?(Array)
102
+
103
+ instances_set_item.map{|j| j['privateIpAddress']}
104
+ }.flatten
105
+ rescue => e
106
+ raise "Unexpected result came back from AWS. Error: (#{e.message})"
107
+ end
99
108
  end
100
109
  end
@@ -177,8 +177,8 @@ EOS
177
177
  end
178
178
 
179
179
  def lookup_grid_helper(pt, gridname, params, follow=false)
180
- dg=Marty::DataGrid.lookup(pt, gridname)
181
- res=dg.lookup_grid_distinct_entry(pt, params, nil, follow)
180
+ dgh=Marty::DataGrid.lookup_h(pt, gridname)
181
+ res=Marty::DataGrid.lookup_grid_distinct_entry_h(pt, params, dgh, nil, follow)
182
182
  [res["result"], res["name"]]
183
183
  end
184
184
 
@@ -294,80 +294,80 @@ EOS
294
294
  end
295
295
 
296
296
  context "should handle NULL key values" do
297
- let(:dg) { Marty::DataGrid.lookup(pt, "Gf") }
297
+ let(:dgh) { Marty::DataGrid.lookup_h(pt, "Gf") }
298
298
 
299
299
  it 'true returns Y' do
300
- res = Marty::DataGrid.lookup_grid(pt, dg, {"b"=>true}, false)
300
+ res = Marty::DataGrid.lookup_grid_h(pt, dgh, {"b"=>true}, false)
301
301
  expect(res).to eq('Y')
302
302
  end
303
303
 
304
304
  it '13 returns N' do
305
- res = Marty::DataGrid.lookup_grid(pt, dg, {"i"=>13}, true)
305
+ res = Marty::DataGrid.lookup_grid_h(pt, dgh, {"i"=>13}, true)
306
306
  expect(res).to eq('N')
307
307
  end
308
308
 
309
309
  it '13 & numrange 0 returns nil' do
310
- res = Marty::DataGrid.lookup_grid(pt, dg, {"i"=>13, "n"=>0}, true)
310
+ res = Marty::DataGrid.lookup_grid_h(pt, dgh, {"i"=>13, "n"=>0}, true)
311
311
  expect(res).to eq('N')
312
312
  end
313
313
 
314
314
  it '13 & int4range 15 returns N' do
315
- res = Marty::DataGrid.lookup_grid(pt, dg, {"i"=>13, "i4"=>15}, true)
315
+ res = Marty::DataGrid.lookup_grid_h(pt, dgh, {"i"=>13, "i4"=>15}, true)
316
316
  expect(res).to eq('N')
317
317
  end
318
318
 
319
319
  it '13 & int4range 1 returns nil' do
320
- res = Marty::DataGrid.lookup_grid(pt, dg, {"i"=>13, "i4"=>1}, true)
320
+ res = Marty::DataGrid.lookup_grid_h(pt, dgh, {"i"=>13, "i4"=>1}, true)
321
321
  expect(res).to be_nil
322
322
  end
323
323
 
324
324
  it 'false, 3, numrange 15 returns N' do
325
325
  res = Marty::DataGrid.
326
- lookup_grid(pt, dg, {"b"=>false, "i"=>3, "n"=>15}, true)
326
+ lookup_grid_h(pt, dgh, {"b"=>false, "i"=>3, "n"=>15}, true)
327
327
  expect(res).to eq('N')
328
328
  end
329
329
 
330
330
  it '13, numrange 15 returns N' do
331
- res = Marty::DataGrid.lookup_grid(pt, dg, {"i"=>13, "n"=>15}, true)
331
+ res = Marty::DataGrid.lookup_grid_h(pt, dgh, {"i"=>13, "n"=>15}, true)
332
332
  expect(res).to eq('N')
333
333
  end
334
334
  end
335
335
 
336
336
  it "should handle ambiguous lookups" do
337
- dg = Marty::DataGrid.lookup(pt, "Gh")
337
+ dgh = Marty::DataGrid.lookup_h(pt, "Gh")
338
338
 
339
339
  h1 = {
340
340
  "property_state" => "NY",
341
341
  "county_name" => "R",
342
342
  }
343
343
 
344
- res = Marty::DataGrid.lookup_grid(pt, dg, h1, false)
344
+ res = Marty::DataGrid.lookup_grid_h(pt, dgh, h1, false)
345
345
  expect(res).to eq(10)
346
346
  end
347
347
 
348
348
  it "should handle ambiguous lookups (2)" do
349
- dg = Marty::DataGrid.lookup(pt, "Gg")
349
+ dgh = Marty::DataGrid.lookup_h(pt, "Gg")
350
350
  res = Marty::DataGrid.
351
- lookup_grid(pt, dg, {"i1"=>2, "i2"=>1}, false)
351
+ lookup_grid_h(pt, dgh, {"i1"=>2, "i2"=>1}, false)
352
352
  expect(res).to eq(1)
353
353
 
354
354
  res = Marty::DataGrid.
355
- lookup_grid(pt, dg, {"i1"=>3, "i2"=>1}, false)
355
+ lookup_grid_h(pt, dgh, {"i1"=>3, "i2"=>1}, false)
356
356
  expect(res).to eq(1)
357
357
 
358
358
  res = Marty::DataGrid.
359
- lookup_grid(pt, dg, {"i1"=>2, "i2"=>3}, false)
359
+ lookup_grid_h(pt, dgh, {"i1"=>2, "i2"=>3}, false)
360
360
  expect(res).to eq(20)
361
361
  end
362
362
 
363
363
  it "should handle non-distinct lookups" do
364
- dg = Marty::DataGrid.lookup(pt, "Ge")
365
- res = Marty::DataGrid.lookup_grid(pt, dg, {"ltv"=>500}, false)
364
+ dgh = Marty::DataGrid.lookup_h(pt, "Ge")
365
+ res = Marty::DataGrid.lookup_grid_h(pt, dgh, {"ltv"=>500}, false)
366
366
 
367
367
  expect(res).to eq(1.1)
368
368
 
369
369
  expect {
370
- Marty::DataGrid.lookup_grid(pt, dg, {"ltv"=>500}, true)
370
+ Marty::DataGrid.lookup_grid_h(pt, dgh, {"ltv"=>500}, true)
371
371
  }.to raise_error(RuntimeError)
372
372
  end
373
373
 
@@ -376,14 +376,14 @@ EOS
376
376
  "client_id" => 700127,
377
377
  "property_state" => "CA",
378
378
  }
379
- dg = Marty::DataGrid.lookup(pt, "Gj")
380
- res = Marty::DataGrid.lookup_grid(pt, dg, params, false)
379
+ dgh = Marty::DataGrid.lookup_h(pt, "Gj")
380
+ res = Marty::DataGrid.lookup_grid_h(pt, dgh, params, false)
381
381
 
382
382
  # should return the upper left corner match
383
383
  expect(res).to eq(0.25)
384
384
 
385
385
  expect {
386
- Marty::DataGrid.lookup_grid(pt, dg, params, true)
386
+ Marty::DataGrid.lookup_grid_h(pt, dgh, params, true)
387
387
  }.to raise_error(RuntimeError)
388
388
  end
389
389
 
@@ -626,10 +626,10 @@ EOS
626
626
  it "should handle typed (enum) data lookup_grid" do
627
627
  pt = 'infinity'
628
628
  ca = Gemini::State.find_by_name("CA")
629
- dg = Marty::DataGrid.lookup(pt, "Gb")
629
+ dgh = Marty::DataGrid.lookup_h(pt, "Gb")
630
630
 
631
631
  res = Marty::DataGrid.
632
- lookup_grid(pt, dg, {"property_state" => ca}, false)
632
+ lookup_grid_h(pt, dgh, {"property_state" => ca}, false)
633
633
 
634
634
  expect(res).to eq 70
635
635
  end
@@ -654,8 +654,9 @@ EOS
654
654
  "keys"=>["[600,700)", "[700,750)", "[750,]"],
655
655
  "type"=>"numrange"}]
656
656
 
657
- dg = Marty::DataGrid.lookup(pt, 'G2')
658
- res = dg.lookup_grid_distinct_entry(pt, {}, nil, true, true)
657
+ dgh = Marty::DataGrid.lookup_h(pt, 'G2')
658
+ res = Marty::DataGrid.lookup_grid_distinct_entry_h(pt, {}, dgh,
659
+ nil, true, true)
659
660
  expect(res["data"]).to eq (expected_data)
660
661
  expect(res["metadata"]).to eq (expected_metadata)
661
662
  end
@@ -676,9 +677,11 @@ EOS
676
677
  "attr"=>"fico",
677
678
  "keys"=>["[600,700)", "[700,750)", "[750,]"],
678
679
  "type"=>"numrange"}]
679
- dg = Marty::DataGrid.lookup(pt, 'G8')
680
- res = dg.lookup_grid_distinct_entry(pt, { "ltv" => 10,
681
- "state" => "RI" }, nil, true,
680
+ dgh = Marty::DataGrid.lookup_h(pt, 'G8')
681
+ res = Marty::DataGrid.lookup_grid_distinct_entry_h(pt,
682
+ { "ltv" => 10,
683
+ "state" => "RI" },
684
+ dgh, nil, true,
682
685
  true)
683
686
  expect(res["data"]).to eq (expected_data)
684
687
  expect(res["metadata"]).to eq (expected_metadata)
@@ -690,44 +693,47 @@ EOS
690
693
  "attr"=>"ltv",
691
694
  "keys"=>["[,115]", "(115,135]", "(135,140]"],
692
695
  "type"=>"numrange"}]
693
- dg = Marty::DataGrid.lookup(pt, 'G8')
694
- res = dg.lookup_grid_distinct_entry(pt, { "ltv" => 10,
695
- "state" => "RI" }, nil, false,
696
+ dgh = Marty::DataGrid.lookup_h(pt, 'G8')
697
+ res = Marty::DataGrid.lookup_grid_distinct_entry_h(pt,
698
+ { "ltv" => 10,
699
+ "state" => "RI" },
700
+ dgh, nil, false,
696
701
  true)
697
702
  expect(res["data"]).to eq (expected_data)
698
703
  expect(res["metadata"]).to eq (expected_metadata)
699
704
  end
700
705
 
701
706
  it "should handle all characters in grid inputs" do
702
- dg = Marty::DataGrid.lookup(pt, 'G1')
707
+ dgh = Marty::DataGrid.lookup_h(pt, 'G1')
703
708
  5000.times do
704
709
  st = 30.times.map{rand(224)+32}.pack('U*')
705
- res = dg.lookup_grid_distinct_entry(pt, { "ltv" => 10,
706
- "fico" => 690,
707
- "state" => st }, nil,
708
- false, true)
710
+ res = Marty::DataGrid.lookup_grid_distinct_entry_h(pt,
711
+ { "ltv" => 10,
712
+ "fico" => 690,
713
+ "state" => st },
714
+ dgh, nil, false, true)
709
715
  end
710
716
  end
711
717
  it "should handle all quote chars in grid inputs" do
712
- dg = Marty::DataGrid.lookup(pt, 'G1')
718
+ dgh = Marty::DataGrid.lookup_h(pt, 'G1')
713
719
  # single, double, backslash, grave, acute, unicode quotes: left single,
714
720
  # right single, left double, right double
715
721
  quotes = ["'", '"', '\\', '`', "\u00b4", "\u2018", "\u2019",
716
722
  "\u201C", "\u201D"]
717
723
  100.times do
718
724
  st = 30.times.map{quotes[rand(9)]}.join
719
- res = dg.lookup_grid_distinct_entry(pt, { "ltv" => 10,
725
+ res = Marty::DataGrid.lookup_grid_distinct_entry_h(pt, { "ltv" => 10,
720
726
  "fico" => 690,
721
- "state" => st }, nil,
727
+ "state" => st }, dgh, nil,
722
728
  false, true)
723
729
  end
724
730
  end
725
731
  it "should handle quote chars in object name" do
726
- dg = Marty::DataGrid.lookup(pt, 'G1')
732
+ dgh = Marty::DataGrid.lookup_h(pt, 'G1')
727
733
  st = Gemini::State.new(name: "'\\")
728
- res = dg.lookup_grid_distinct_entry(pt, { "ltv" => 10,
734
+ res = Marty::DataGrid.lookup_grid_distinct_entry_h(pt, { "ltv" => 10,
729
735
  "fico" => 690,
730
- "state" => st }, nil,
736
+ "state" => st }, dgh, nil,
731
737
  false, true)
732
738
  end
733
739
  end
@@ -749,17 +755,19 @@ EOS
749
755
  dgb.update_from_import("Gb", Gb.sub(/70/, "333"), '1/1/2015')
750
756
  dgb.update_from_import("Gb", Gb.sub(/70/, "444"), '1/1/2016')
751
757
 
752
- res = dgc.lookup_grid_distinct_entry('2/2/2014',
753
- {"property_state" => "CA"})
758
+ dgch = dgc.attributes.
759
+ slice("id","group_id","created_dt", "metadata", "data_type")
760
+ res = Marty::DataGrid.lookup_grid_distinct_entry_h('2/2/2014',
761
+ {"property_state" => "CA"}, dgch)
754
762
  expect(res["result"]).to eq(70)
755
763
 
756
- res = dgc.lookup_grid_distinct_entry('2/2/2015',
757
- {"property_state" => "CA"})
764
+ res = Marty::DataGrid.lookup_grid_distinct_entry_h('2/2/2015',
765
+ {"property_state" => "CA"}, dgch)
758
766
 
759
767
  expect(res["result"]).to eq(333)
760
768
 
761
- res = dgc.lookup_grid_distinct_entry('2/2/2016',
762
- {"property_state" => "CA"})
769
+ res = Marty::DataGrid.lookup_grid_distinct_entry_h('2/2/2016',
770
+ {"property_state" => "CA"}, dgch)
763
771
 
764
772
  expect(res["result"]).to eq(444)
765
773
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arman Bostani
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2018-02-15 00:00:00.000000000 Z
17
+ date: 2018-02-23 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: pg