RQ::Querier (Class)

In: lib/rq-3.0.0/querier.rb
Parent: MainHelper
MainHelper StatusLister Snapshotter ReSubmitter Feeder Deleter Toucher Relayer Executor Submitter Locker IOViewer Backer Cron Configurator Lister Rotater Creator Recoverer Updater Querier ::Hash ConfigFile DRbUndumped JobRunner Main QDB JobQueue JobRunnerDaemon Array SleepCycle Job ArrayFields ::OrderedHash OrderedAutoHash LogMethods Refresher ResourceManager Resource lib/rq-3.0.0/refresher.rb lib/rq-3.0.0/snapshotter.rb lib/rq-3.0.0/deleter.rb lib/rq-3.0.0/feeder.rb lib/rq-3.0.0/configurator.rb lib/rq-3.0.0/cron.rb lib/rq-3.0.0/jobqueue.rb lib/rq-3.0.0/rotater.rb lib/rq-3.0.0/backer.rb lib/rq-3.0.0/toucher.rb lib/rq-3.0.0/qdb.rb lib/rq-3.0.0/configfile.rb lib/rq-3.0.0/mainhelper.rb lib/rq-3.0.0/lister.rb bin/rq.rb lib/rq-3.0.0/statuslister.rb lib/rq-3.0.0/updater.rb lib/rq-3.0.0/jobrunner.rb lib/rq-3.0.0/job.rb lib/rq-3.0.0/creator.rb lib/rq-3.0.0/sleepcycle.rb lib/rq-3.0.0/executor.rb lib/rq-3.0.0/resubmitter.rb lib/rq-3.0.0/orderedautohash.rb lib/rq-3.0.0/resourcemanager.rb lib/rq-3.0.0/resource.rb lib/rq-3.0.0/jobrunnerdaemon.rb lib/rq-3.0.0/recoverer.rb lib/rq-3.0.0/querier.rb lib/rq-3.0.0/ioviewer.rb lib/rq-3.0.0/locker.rb lib/rq-3.0.0/submitter.rb lib/rq-3.0.0/relayer.rb Usage Util LogClassMethods LoggerExt LogMethods Logging RQ Module: RQ

a Querier simply takes an sql where clause (such as ‘jid = 42’) from the command line, queries the queue, and dumps a valid yaml representation of the tuples returned. the output of a Querier can be used as the input to a Deleter or Submitter, etc.

Methods

query   query  

Public Instance methods

[Source]

    # File lib/rq-3.0.0/querier.rb, line 18
18:       def query
19: #--{{{
20:         set_q
21: 
22:         @q.qdb.transaction_retries = 1
23: 
24:         where_clause = @argv.join ' '
25: 
26:         if where_clause.empty? and stdin? 
27:           debug{ "reading where_clause from stdin" }
28:           while((buf = stdin.gets))
29:             buf.strip!
30:             buf.gsub! %/#.*$/o, ''
31:             next if buf.empty?
32:             where_clause << "#{ buf } "
33:           end
34:         end
35: 
36:         @q.query(where_clause, &dumping_yaml_tuples)
37: #--}}}
38:       end

[Source]

    # File lib/rq-3.0.0/querier.rb, line 39
39:       def query
40: #--{{{
41:         set_q
42: 
43:         @q.qdb.transaction_retries = 1
44: 
45:         simple_pat = %/^\s*([^=\s!~]+)(=~|!~|!=|==|=)([^=\s]+)\s*$/ox
46:         simple_query = @argv.select{|arg| arg !~ simple_pat }.empty?
47: 
48:         where_clause = 
49:           if simple_query 
50:             wc = [] 
51: 
52:             @argv.each do |arg|
53:               m = simple_pat.match(arg).to_a[1..-1]
54:               field, op, value = m[0], m[1], m[2..-1].join 
55:               op =
56:                 case op
57:                   when '=', '==' 
58:                     '='
59:                   when '!='
60:                     '!='
61:                   when '=~'
62:                     'like'
63:                   when '!~'
64:                     'not like'
65:                 end
66: 
67:               quoted = (value =~ %/^\s*'.*'\s*$/o)
68:               numeric = begin; Float(value); true; rescue; false; end 
69: 
70:               value = "'#{ value }'" unless quoted or numeric
71: 
72:               wc << "(#{ field } #{ op } #{ value })"
73:             end
74: 
75:             wc.join ' and '
76:           else
77:             @argv.join ' '
78:           end
79: 
80:         if where_clause.strip.empty? and stdin?
81:           debug{ "reading where_clause from stdin" }
82:           while((buf = stdin.gets))
83:             buf.strip!
84:             buf.gsub! %/#.*$/o, ''
85:             next if buf.empty?
86:             where_clause << "#{ buf } "
87:           end
88:         end
89: 
90:         @q.query(where_clause, &dumping_yaml_tuples)
91: #--}}}
92:       end

[Validate]