class BELParser::Resource::EagerSPARQLReader

EagerSPARQLReader

Public Class Methods

new(sparql_endpoint_url, validate_url = true) click to toggle source
Calls superclass method
# File lib/bel_parser/resource/eager_sparql_reader.rb, line 9
def initialize(sparql_endpoint_url, validate_url = true)
  @resources = Concurrent::Hash.new
  @locks     = Concurrent::Hash.new
  super
end

Public Instance Methods

retrieve_resource(resource_identifier) click to toggle source
Calls superclass method
# File lib/bel_parser/resource/eager_sparql_reader.rb, line 15
def retrieve_resource(resource_identifier)
  if @resources.key?(resource_identifier)
    concepts = @resources[resource_identifier]
    concepts[value]
  else
    lock = @locks[resource_identifier] ||= Mutex.new
    if lock.try_lock
      Thread.new do
        concepts = retrieve_values_from_resource(resource_identifier).to_a
        @resources[resource_identifier] = 
          Hash[
            concepts.map do |c|
              [c.name, c]
            end
          ]
        lock.unlock
      end
    end

    super
  end
end
retrieve_value_from_resource(resource_identifier, value) click to toggle source
Calls superclass method
# File lib/bel_parser/resource/eager_sparql_reader.rb, line 38
def retrieve_value_from_resource(resource_identifier, value)
  concepts = @resources[resource_identifier]
  return super unless concepts
  concepts[value]
end
retrieve_values_from_resource(resource_identifier) click to toggle source
Calls superclass method
# File lib/bel_parser/resource/eager_sparql_reader.rb, line 44
def retrieve_values_from_resource(resource_identifier)
  concepts = @resources[resource_identifier]
  return super unless concepts
  concepts
end