ELASTICPATHING/SOURCECODE/UbiComp2014/Elastic_Pathing_Code/lib-NodeWay.rb
#A container class for the Way_sql and Way_buffer class
#This class unifies the interface and checks the buffer before the sql. 
A container class for the Way_sql and Way_buffer class
This class unifies the interface and checks the buffer before the sql.
A container class for the Way_sql and Way_buffer class This class unifies the interface and checks the buffer before the sql .
def fill_buffer(tdb)
		tmp = Array.new()
		tdb.results_as_hash = true unless tdb.results_as_hash
		tdb.execute("SELECT * FROM gways"){|r| tmp.push([r['wid'].to_i,r['nid'].to_i])}
		@log.debug("Ways.fill_buffer: extracted\n#{tmp.map{|x| x.join(",")}.join("\n")}")
		wids = tmp.map{|x| x[0]}.uniq
		fill = wids.map{|x| [x,tmp.select{|y| y[0] == x}.map{|y| y[1]}]}
		@log.debug("Ways.fill_buffer: pushing\n#{fill.map{|x| x.join(",")}.join("\n")}")
		@way_buffer.fill_buffer(fill)
	end
def fill_buffer ( tdb ) tmp = Array . new ( ) tdb . results_as_hash = true unless tdb . results_as_hash tdb . execute ( "SELECT * FROM gways" ) { | r | tmp . push ( [ r [ 'wid' ] . to_i , r [ 'nid' ] . to_i ] ) } @log . debug ( "Ways.fill_buffer: extracted\n#{tmp.map{|x| x.join(",")}.join("\n")}" ) wids = tmp . map { | x | x [ 0 ] } . uniq fill = wids . map { | x | [ x , tmp . select { | y | y [ 0 ] == x } . map { | y | y [ 1 ] } ] } @log . debug ( "Ways.fill_buffer: pushing\n#{fill.map{|x| x.join(",")}.join("\n")}" ) @way_buffer . fill_buffer ( fill ) end
A container class for the Way_sql and Way_buffer class
This class unifies the interface and checks the buffer before the sql.
A container class for the Way_sql and Way_buffer class This class unifies the interface and checks the buffer before the sql .
#tdb is a sqllite object (SQLite3::Database.new), populates the buffer with values from the database
tdb