Class: Bud::PushSort

Inherits:
PushStatefulElement show all
Defined in:
lib/bud/executor/elements.rb

Instance Attribute Summary

Attributes inherited from PushElement

#elem_name, #found_delta, #invalidated, #outputs, #pendings, #rescan, #wired_by

Attributes inherited from BudCollection

#accumulate_tick_deltas, #bud_instance, #cols, #invalidated, #is_source, #key_cols, #new_delta, #pending, #rescan, #scanner_cnt, #struct, #tabname, #wired_by

Instance Method Summary collapse

Methods inherited from PushStatefulElement

#add_rescan_invalidate

Methods inherited from PushElement

#*, #<<, #add_rescan_invalidate, #all?, #any?, #argagg, #argmax, #argmin, #check_wiring, #each_with_index, #group, #include?, #inspected, #invalidate_tables, #join, #member?, #merge, #none?, #notin, #on_include?, #one?, #print_wiring, #pro, #push_out, #push_predicate, #reduce, #rescan_at_tick, #set_block, #sort, #stratum_end, #tick, #tick_deltas, #wire_to, #wirings

Methods inherited from BudCollection

#*, #<<, #<=, #[], #add_rescan_invalidate, #argagg, #argmax, #argmin, #bootstrap, #canonicalize_col, #close, #do_insert, #each, #each_delta, #each_raw, #each_tick_delta, #each_with_index, #empty?, #exists?, #flat_map, #flush_deltas, #group, #has_key?, #include?, #init_schema, #inspect, #inspected, #invalidate_at_tick, #keys, #length, #merge, #non_temporal_predecessors, #notin, #null_tuple, #pending_merge, #positive_predecessors, #prep_aggpairs, #pro, #qualified_tabname, #reduce, #register_coll_expr, #rename, #schema, #sort, #tick, #tick_deltas, #tick_metrics, #to_push_elem, #uniquify_tabname, #val_cols, #values

Methods included from Enumerable

#pro

Constructor Details

#initialize(elem_name = nil, bud_instance = nil, collection_name = nil, schema_in = nil, &blk) ⇒ PushSort

Returns a new instance of PushSort.



415
416
417
418
419
420
# File 'lib/bud/executor/elements.rb', line 415

def initialize(elem_name=nil, bud_instance=nil, collection_name=nil,
               schema_in=nil, &blk)
  super(elem_name, bud_instance, collection_name, schema_in, &blk)
  @sortbuf = []
  @seen_new_input = false
end

Instance Method Details

#flushObject



427
428
429
430
431
432
433
434
435
436
# File 'lib/bud/executor/elements.rb', line 427

def flush
  if @seen_new_input || @rescan
    @sortbuf.sort!(&@blk)
    @sortbuf.each do |t|
      push_out(t, false)
    end
    @seen_new_input = false
    @rescan = false
  end
end

#insert(item, source) ⇒ Object



422
423
424
425
# File 'lib/bud/executor/elements.rb', line 422

def insert(item, source)
  @sortbuf << item
  @seen_new_input = true
end

#invalidate_cacheObject



438
439
440
# File 'lib/bud/executor/elements.rb', line 438

def invalidate_cache
  @sortbuf.clear
end