Class: DagMe::Adapters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/dag_me/adapters/base.rb

Overview

The reachability interface. The model layer only talks to this; whether answers come from the materialized closure or a recursive CTE is an adapter concern.

Direct Known Subclasses

PostgresqlClosure, RecursiveCte

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.



11
12
13
# File 'lib/dag_me/adapters/base.rb', line 11

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/dag_me/adapters/base.rb', line 9

def config
  @config
end

Instance Method Details

#ancestors(node) ⇒ Object

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/dag_me/adapters/base.rb', line 19

def ancestors(node)
  raise NotImplementedError
end

#apply_topological_order(relation) ⇒ Object

Orders a relation so ancestors always precede descendants. Both adapters sort by global ancestor count: for any edge u -> v, ancestors(v) ⊇ ancestors(u) ∪ u, so the count strictly increases along every edge - a valid topological order for any sub-relation.

Raises:

  • (NotImplementedError)


50
51
52
# File 'lib/dag_me/adapters/base.rb', line 50

def apply_topological_order(relation)
  raise NotImplementedError
end

#between(ancestor, descendant) ⇒ Object

Nodes on any path from ancestor to descendant, endpoints included: self_and_descendants(ancestor) ∩ self_and_ancestors(descendant).



42
43
44
# File 'lib/dag_me/adapters/base.rb', line 42

def between(ancestor, descendant)
  self_and_descendants(ancestor).and(self_and_ancestors(descendant))
end

#descendants(node) ⇒ Object

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/dag_me/adapters/base.rb', line 23

def descendants(node)
  raise NotImplementedError
end

#modelObject



15
16
17
# File 'lib/dag_me/adapters/base.rb', line 15

def model
  config.model
end

#reachable?(ancestor, descendant) ⇒ Boolean

True when ancestor reaches descendant through one or more edges.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/dag_me/adapters/base.rb', line 36

def reachable?(ancestor, descendant)
  raise NotImplementedError
end

#self_and_ancestors(node) ⇒ Object

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/dag_me/adapters/base.rb', line 27

def self_and_ancestors(node)
  raise NotImplementedError
end

#self_and_descendants(node) ⇒ Object

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/dag_me/adapters/base.rb', line 31

def self_and_descendants(node)
  raise NotImplementedError
end