Class: Queris::Query::SortOp
- Inherits:
-
Op
- Object
- Op
- Queris::Query::SortOp
show all
- Defined in:
- lib/queris/query/operations.rb
Constant Summary
collapse
- COMMAND =
:zinterstore
- SYMBOL =
:sortby
Instance Attribute Summary
Attributes inherited from Op
#fragile, #operands
Instance Method Summary
collapse
Methods inherited from Op
#command, #initialize, #keys, #marshal_dump, #notready!, #optimize, #optimized?, #query_run_stage_release, #subqueries, #symbol, #temp_keys, #temp_keys?, #to_s, #weights
Instance Method Details
#json_redis_dump ⇒ Object
365
366
367
368
369
|
# File 'lib/queris/query/operations.rb', line 365
def json_redis_dump
operands.map do |op|
{key: op.index.key, multiplier: op.value}
end
end
|
#operand_key(op) ⇒ Object
379
380
381
|
# File 'lib/queris/query/operations.rb', line 379
def operand_key(op)
op.index.key op.value
end
|
#operand_key_weight(op) ⇒ Object
374
|
# File 'lib/queris/query/operations.rb', line 374
def operand_key_weight(op); op.value; end
|
#prepare ⇒ Object
375
376
377
378
|
# File 'lib/queris/query/operations.rb', line 375
def prepare
super { |op| op.index.key op.value }
end
|
#push(index, reverse = nil) ⇒ Object
370
371
372
|
# File 'lib/queris/query/operations.rb', line 370
def push(index, reverse=nil)
super(index, reverse ? -1 : 1)
end
|
#query_run_stage_inspect(r, q) ⇒ Object
382
383
384
385
386
387
|
# File 'lib/queris/query/operations.rb', line 382
def query_run_stage_inspect(r, q)
operands.each do |op|
op.gather_key_sizes(r)
end
end
|
#run(redis, target, first = false, trace_callback = nil) ⇒ Object
388
389
390
391
392
393
394
395
|
# File 'lib/queris/query/operations.rb', line 388
def run(redis, target, first=false, trace_callback=nil)
sort_keys = keys(target, first)
redis.send self.class::COMMAND, target, sort_keys, :weights => weights(first)
if trace_callback
raise NotImplemented, "Can't trace multi-sorts yet." if sort_keys.count > 2 || operands.count > 1
trace_callback.call(self, operands.first, target)
end
end
|
#target_key_weight ⇒ Object
373
|
# File 'lib/queris/query/operations.rb', line 373
def target_key_weight; 0; end
|