Changeset 150

Show
Ignore:
Timestamp:
11/17/08 13:27:55 (5 years ago)
Author:
samuraraujo
Message:
 
Location:
activerdf_sparql-1.3.6/lib/activerdf_sparql
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • activerdf_sparql-1.3.6/lib/activerdf_sparql/sparql.rb

    r145 r150  
    99class SparqlAdapter < ActiveRdfAdapter 
    1010  $activerdflog.info "loading SPARQL adapter" 
    11   ConnectionPool.register_adapter(:sparql, self) 
    12    
     11  ConnectionPool.register_adapter(:sparql, self)   
    1312  attr_reader :engine 
    14   attr_reader :caching 
    15    
    16   @@sparql_cache = {} 
     13  attr_reader :caching   
    1714  def reset_cache()      
    18     @@sparql_cache = {} 
    19   end 
    20   def SparqlAdapter.get_cache 
    21     return @@sparql_cache 
    22   end 
     15    @sparql_cache = {} 
     16  end 
     17#  def SparqlAdapter.get_cache 
     18#    return @sparql_cache 
     19#  end 
    2320   
    2421  # Instantiate the connection with the SPARQL Endpoint. 
     
    3128  def initialize(params = {})    
    3229    super()  
     30    @sparql_cache = {} 
    3331    @reads = true 
    3432    @writes = false 
     
    5654  # may be called with a block 
    5755  def query(query, &block) 
     56     
    5857    qs = Query2SPARQL.translate(query) 
    5958     puts qs.to_s 
     
    109108     
    110109    # we parse content depending on the result format 
     110      
    111111    results = case @result_format 
    112112      when :json  
     
    115115      parse_xml(response) 
    116116    end 
    117      
     117  
    118118    if block_given? 
    119119      results.each do |*clauses| 
     
    131131    unless result.nil? or result.empty? 
    132132      if result == "timeout" 
    133         @@sparql_cache.store(query_string, []) 
     133        @sparql_cache.store(query_string, []) 
    134134      else  
    135135        $activerdflog.debug "adding to sparql cache - query: #{query_string}" 
    136         @@sparql_cache.store(query_string, result)  
     136        @sparql_cache.store(query_string, result)  
    137137      end 
    138138    end 
     
    140140  def query_cache(query_string) 
    141141     
    142     if @@sparql_cache.include?(query_string) 
     142    if @sparql_cache.include?(query_string) 
    143143       
    144       return @@sparql_cache.fetch(query_string) 
     144      return @sparql_cache.fetch(query_string) 
    145145    else 
    146146      return nil 
  • activerdf_sparql-1.3.6/lib/activerdf_sparql/sparql_result_parser.rb

    r27 r150  
    4646    case type 
    4747      when 'uri' 
     48        
    4849      RDFS::Resource.new(value) 
    4950      when 'bnode'