Top Level Namespace

Includes:
OMF::Base::OML

Defined Under Namespace

Modules: OMF, Sequel

Instance Method Summary collapse

Instance Method Details

#on_new_stream(ep) ⇒ Object



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/omf_oml/sql_source.rb', line 241

def on_new_stream(ep)
  ep.on_new_stream() do |s|
    puts ">>>>>>>>>>>> New stream #{s.stream_name}: #{s.schema.names}"
    case s.stream_name
    when 'wimaxmonitor_wimaxstatus'
      select = [:oml_ts_server, :sender_hostname, :frequency, :signal, :rssi, :cinr, :avg_tx_pwr]
    when 'GPSlogger_gps_data'
      select = [:oml_ts_server, :oml_sender_id, :lat, :lon]
    end

    s.on_new_tuple() do |v|
      begin
        puts "New vector(#{s.stream_name}): #{v.select(*select).join('|')}"
      rescue Exception => ex
        puts "ERROR: #{ex}"
        abort
      end
    end
  end
  ep.run()
end

#test_sequel_serverObject



298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# File 'lib/omf_oml/sequel/sequel_server.rb', line 298

def test_sequel_server()

  tests = []

  tests <<  %{
    <query>
      <repository name='test'/>
      <table tname='iperf_TCP_Info'/>
      <project>
        <arg><col name='Bandwidth_avg' table='iperf_TCP_Info'/></arg>
      </project>
    </query>
  }

  tests << %{
    <query>
      <repository name='test'/>
      <table tname='iperf_TCP_Info' talias='t'/>
      <project>
        <arg>
          <col name='oml_sender_id' alias='foo' table='t'/>
        </arg>
        <arg>
          <col name='oml_ts_server' table='t' alias='goo'/>
        </arg>
        <arg><col name='Bandwidth_avg' table='t'/></arg>
      </project>
      <where>
        <arg>
          <col name='oml_sender_id' table='t'/>
          <eq>
            <arg type='decimal'> 2</arg>
          </eq>
        </arg>
      </where>
    </query>
  }

#  mc = repo[:mediacontent]
#  mc2 = mc.alias
#  accessed = mc2.where(mc2[:status].eq('Accessed')).project(:oml_ts_server, :name)
#  q = mc.project(:name).join(accessed).on(mc[:name].eq(mc2[:name]))

#  tests << %{
#    <query>
#      <repository name='prefetching_4'/>
#      <table tname='mediacontent'/>
#      <project>
#        <arg type='string'>name</arg>
#      </project>
#      <join>
#        <arg>
#          <table tname='mediacontent' talias='mediacontent1'/>
#          <where>
#            <arg>
#              <col name='status' table='mediacontent' talias='mediacontent1'/>
#              <eq>
#                <arg type='string'>Accessed</arg>
#              </eq>
#            </arg>
#          </where>
#          <project>
#            <arg type='string'>oml_ts_server</arg>
#            <arg type='string'>name</arg>
#          </project>
#        </arg>
#      </join>
#      <on>
#        <arg>
#          <col name='name' table='mediacontent'/>
#          <eq>
#            <arg>
#              <col name='name' table='mediacontent' talias='mediacontent1'/>
#            </arg>
#          </eq>
#        </arg>
#      </on>
#    </query>
#  }

  factory = OMF::OML::Sequel::Server::RepositoryFactory.new(
              :adapter => 'sqlite',
              :database_prefix => '/Users/max/src/omf_mytestbed_net/omf-common/test/',
              :database_postfix => '.sq3'
            )

  repo = factory.create('test')
  puts repo.tables

  tests.each do |t|
    ds = OMF::OML::Sequel::Server::Query.parse(t, factory)
    puts ds.inspect
    puts ds.columns.inspect
    puts ds.first.inspect
  end

  first = true
  types = []
  ds = OMF::OML::Sequel::Server::Query.parse(tests[1], factory).limit(10)
  ds.each do |r|
    if (first)
      puts ds.row_description(r).inspect
      puts ds.schema_for_row(r).inspect
      #puts (ds.schema_for_row(r).methods - Object.new.methods).sort
#      cols = ds.columns
#      #cols.collect do |c|
#      cols.each do |c|
#        puts "#{c} : #{OML::Sequel::XML::Server::Query::CLASS2TYPE[r[c].class]}"
#      end
      first = false
#      puts types.inspect
    end
    puts r.inspect
  end
  puts "QUERY: done"
end