class Twb::JoinTree

Attributes

datasource[R]
maxdepth[R]
root[R]
tables[R]

Public Class Methods

new(datasource) click to toggle source
# File lib/twb/datasource.rb, line 662
def initialize  datasource
  @datasource = datasource
  @root       = nil
  @maxdepth   = 0
  @tables     = {}
end

Public Instance Methods

add(host, dest) click to toggle source
# File lib/twb/datasource.rb, line 669
def add host, dest
  # puts  "\nJT add() host: #{host}"
  # puts  "           dest: #{dest}"
  from = @tables[host.name].nil? ? host : @tables[host.name]
  to   = @tables[dest.name].nil? ? dest : @tables[dest.name]
  from.addChild(to)
  @tables[from.name] = from
  @tables[to.name]   = to
  if @root.nil?  || @root.name.eql?(to.name)
    @root = from
  end
  setDepth(@root,1)
end
disp(table) click to toggle source
# File lib/twb/datasource.rb, line 698
def disp table
  # puts  "%s %s %s  (%d)" % [' ' * table.depth, '-' * table.depth, table.name, table.depth]
  table.children.each { |n,c| disp c}
end
iterate() click to toggle source
# File lib/twb/datasource.rb, line 703
def iterate
  disp @root
end
setDepth(table, depth) click to toggle source
# File lib/twb/datasource.rb, line 687
def setDepth table, depth
  # puts  "-- setDepth(#{table.class}[#{table.name}] \t, #{depth})"
  @tables[table.name].depth = depth
  childrenDepth = depth+1
  table.children.each { |n,c| setDepth(c,childrenDepth)}
end
table(tableName) click to toggle source
# File lib/twb/datasource.rb, line 683
def table tableName
  @tables[tableName]
end
tableDepth(tableName) click to toggle source
# File lib/twb/datasource.rb, line 694
def tableDepth tableName
  @tables[tableName].nil? ? 0 : @tables[tableName].depth
end
to_s() click to toggle source
# File lib/twb/datasource.rb, line 707
def to_s
  str = "root: #{@root}\ntables"
  @tables.each do |t| 
    str << " tbl:: #{t}"
  end
  return str
end