Class: Bud::ScannerElement

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

Instance Attribute Summary (collapse)

Attributes inherited from PushElement

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

Attributes inherited from BudCollection

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

Instance Method Summary (collapse)

Methods inherited from PushElement

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

Methods inherited from BudCollection

#*, #<<, #<=, #[], #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, #flush_deltas, #group, #has_key?, #include?, #init_schema, #insert, #inspect, #inspected, #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

- (ScannerElement) initialize(elem_name, bud_instance, collection_in, the_schema = collection_in.schema, &blk)



448
449
450
451
452
453
454
455
# File 'lib/bud/executor/elements.rb', line 448

def initialize(elem_name, bud_instance, collection_in,
               the_schema=collection_in.schema, &blk)
  super(elem_name, bud_instance, collection_in.qualified_tabname, the_schema)
  @collection = collection_in
  @rescan_set = []
  @invalidate_set = []
  @force_rescan = false
end

Instance Attribute Details

- (Object) collection (readonly)

Returns the value of attribute collection



444
445
446
# File 'lib/bud/executor/elements.rb', line 444

def collection
  @collection
end

- (Object) force_rescan

Returns the value of attribute force_rescan



446
447
448
# File 'lib/bud/executor/elements.rb', line 446

def force_rescan
  @force_rescan
end

- (Object) invalidate_set (readonly)

Returns the value of attribute invalidate_set



445
446
447
# File 'lib/bud/executor/elements.rb', line 445

def invalidate_set
  @invalidate_set
end

- (Object) rescan_set (readonly)

Returns the value of attribute rescan_set



445
446
447
# File 'lib/bud/executor/elements.rb', line 445

def rescan_set
  @rescan_set
end

Instance Method Details

- (Object) add_rescan_invalidate(rescan, invalidate)



472
473
474
475
476
477
478
479
480
481
482
483
484
# File 'lib/bud/executor/elements.rb', line 472

def add_rescan_invalidate(rescan, invalidate)
  # If the collection is to be invalidated, the scanner needs to be in
  # rescan mode
  rescan << self if invalidate.member? @collection

  # Pass the current state to each output collection and see if they end up
  # marking this node for rescan
  invalidate_tables(rescan, invalidate)

  # Note also that this node can be nominated for rescan by a target node;
  # in other words, a scanner element can be set to rescan even if the
  # collection is not invalidated.
end

- (Object) invalidate_at_tick(rescan, invalidate)

What should be rescanned/invalidated if this scanner's collection were to be invalidated.



467
468
469
470
# File 'lib/bud/executor/elements.rb', line 467

def invalidate_at_tick(rescan, invalidate)
  @rescan_set = rescan
  @invalidate_set = invalidate
end

- (Object) rescan



457
458
459
# File 'lib/bud/executor/elements.rb', line 457

def rescan
  @rescan || @collection.invalidated
end

- (Object) rescan_at_tick



461
462
463
# File 'lib/bud/executor/elements.rb', line 461

def rescan_at_tick
  @collection.invalidate_at_tick # need to scan afresh if collection invalidated.
end

- (Object) scan(first_iter)



486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'lib/bud/executor/elements.rb', line 486

def scan(first_iter)
  if @force_rescan
    @collection.each_raw {|item| push_out(item)}
    @force_rescan = false
  elsif first_iter
    if rescan
      @collection.each_raw {|item| push_out(item)}
    else
      # In the first iteration, tick_delta would be non-null IFF the
      # collection has grown in an earlier stratum
      @collection.each_tick_delta {|item| push_out(item)}
    end
  end

  # send deltas out in all cases
  @collection.each_delta {|item| push_out(item)}
end