Class: RDF::OrderedRepo
- Inherits:
-
Repository
- Object
- Dataset
- Repository
- RDF::OrderedRepo
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/rdf-ordered-repo-fad0f6c1f768/lib/rdf/ordered_repo.rb
Overview
Sub-class of RDF::Repository with order-preserving properties.
Defined Under Namespace
Modules: VERSION
Constant Summary collapse
- DEFAULT_GRAPH =
false
Constants inherited from Repository
Constants inherited from Dataset
Instance Attribute Summary
Attributes inherited from Repository
Attributes included from Enumerable
Instance Method Summary collapse
- #apply_changeset(changeset) ⇒ Object
- #graph?(*args) ⇒ Object (also: #has_graph?)
-
#initialize(uri: nil, title: nil, transaction_class: RDF::Transaction::SerializedTransaction, **options) {|repository| ... } ⇒ OrderedRepo
constructor
Initializes this repository instance.
- #isolation_level ⇒ Object
-
#snapshot ⇒ Dataset
A readable & queryable snapshot of the repository for isolated reads.
- #statement?(*args) ⇒ Object (also: #has_statement?)
-
#supports?(feature) ⇒ Boolean
Returns
true
if this respository supports the givenfeature
. -
#to_query ⇒ RDF::Query
Creates a query from the statements in this repository, turning blank nodes into non-distinguished variables.
Methods inherited from Repository
Methods included from Transactable
#begin_transaction, #commit_transaction, #rollback_transaction, #transaction
Methods included from Mutable
#<<, add_entailment, #clear, #delete, #delete_insert, #delete_statements, #entail, #entail!, #immutable?, #insert, #load, #method_missing, #mutable?, #respond_to_missing?, #update
Methods included from Util::Aliasing::LateBound
Methods included from Util::Coercions
Methods included from Writable
#<<, #insert, #insert_graph, #insert_reader, #insert_statements, #writable?
Methods included from Readable
Methods inherited from Dataset
Methods included from Queryable
#concise_bounded_description, #first, #first_literal, #first_object, #first_predicate, #first_subject, #first_value, #lint, #query, #query_execute, #query_without_sparql, #to_sparql
Methods included from Durable
Methods included from Enumerable
add_entailment, #canonicalize, #canonicalize!, #dump, #each_object, #each_predicate, #each_quad, #each_subject, #each_term, #each_triple, #entail, #enum_graph, #enum_object, #enum_predicate, #enum_quad, #enum_statement, #enum_subject, #enum_term, #enum_triple, #invalid?, #method_missing, #object?, #objects, #predicate?, #predicates, #project_graph, #quad?, #quads, #respond_to_missing?, #statements, #subject?, #subjects, #term?, #terms, #to_a, #to_h, #to_set, #triple?, #triples, #valid?, #validate!
Methods included from Isomorphic
#bijection_to, #isomorphic_with?
Methods included from Countable
Constructor Details
#initialize(uri: nil, title: nil, transaction_class: RDF::Transaction::SerializedTransaction, **options) {|repository| ... } ⇒ OrderedRepo
Initializes this repository instance.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-ordered-repo-fad0f6c1f768/lib/rdf/ordered_repo.rb', line 24 def initialize(uri: nil, title: nil, transaction_class: RDF::Transaction::SerializedTransaction, **, &block) @data = .delete(:data) || {} super do @tx_class = transaction_class if block_given? case block.arity when 1 then block.call(self) else instance_eval(&block) end end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RDF::Mutable
Instance Method Details
#apply_changeset(changeset) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-ordered-repo-fad0f6c1f768/lib/rdf/ordered_repo.rb', line 151 def apply_changeset(changeset) data = @data changeset.deletes.each do |del| if del.constant? data = delete_from(data, del) else # we need this condition to handle wildcard statements query_pattern(del) { |stmt| data = delete_from(data, stmt) } end end changeset.inserts.each { |ins| data = insert_to(data, ins) } @data = data end |
#graph? ⇒ Boolean #graph?(name) ⇒ Boolean Also known as: has_graph?
85 86 87 88 89 90 91 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-ordered-repo-fad0f6c1f768/lib/rdf/ordered_repo.rb', line 85 def graph?(*args) case args.length when 0 then false when 1 then @data.key?(args.first) else raise ArgumentError("wrong number of arguments (given #{args.length}, expected 0 or 1)") end end |
#isolation_level ⇒ Object
167 168 169 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-ordered-repo-fad0f6c1f768/lib/rdf/ordered_repo.rb', line 167 def isolation_level :snapshot end |
#snapshot ⇒ Dataset
A readable & queryable snapshot of the repository for isolated reads.
178 179 180 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-ordered-repo-fad0f6c1f768/lib/rdf/ordered_repo.rb', line 178 def snapshot self.class.new(data: @data).freeze end |
#statement? ⇒ Boolean #statement?(statement) ⇒ Object Also known as: has_statement?
121 122 123 124 125 126 127 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-ordered-repo-fad0f6c1f768/lib/rdf/ordered_repo.rb', line 121 def statement?(*args) case args.length when 0 then false when 1 then args.first && statement_in?(@data, args.first) else raise ArgumentError("wrong number of arguments (given #{args.length}, expected 0 or 1)") end end |
#supports?(feature) ⇒ Boolean
Returns true
if this respository supports the given feature
.
This repository supports list_terms.
41 42 43 44 45 46 47 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-ordered-repo-fad0f6c1f768/lib/rdf/ordered_repo.rb', line 41 def supports?(feature) case feature.to_sym when :rdfstar then true when :snapshots then true else super end end |
#to_query ⇒ RDF::Query
Creates a query from the statements in this repository, turning blank nodes into non-distinguished variables. This can be used to determine if this repository is logically a subset of another repository.
53 54 55 56 57 58 59 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-ordered-repo-fad0f6c1f768/lib/rdf/ordered_repo.rb', line 53 def to_query RDF::Query.new do |query| each do |statement| query.pattern RDF::Query::Pattern.from(statement, ndvars: true) end end end |