Class: RDF::Dataset
- Includes:
- Durable, Enumerable, Queryable
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/dataset.rb
Overview
An RDF Dataset
Datasets are immutable by default. Repository provides an interface for mutable Datasets.
A Dataset functions as an a set of named RDF graphs with a default graph. It implements Enumerable and Queryable over the whole set; if no specific graph name is queried, enumerating and querying takes place over the intersection of all the graphs in the Dataset.
The default graph is named with a constant DEFAULT_GRAPH
.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_GRAPH =
false
- ISOLATION_LEVELS =
[ :read_uncommitted, :read_committed, :repeatable_read, :snapshot, :serializable ].freeze
Instance Attribute Summary
Attributes included from Enumerable
Instance Method Summary collapse
-
#initialize(statements: [], **options) {|dataset| ... } ⇒ Dataset
constructor
A new instance of Dataset.
-
#inspect ⇒ String
Returns a developer-friendly representation of this object.
-
#inspect!
Outputs a developer-friendly representation of this object to
stderr
. -
#isolation_level ⇒ Symbol
:snapshot
, or:serializable
. -
#query_pattern(pattern, **options, &block) ⇒ Object
protected
Implements basic query pattern matching over the Dataset, with handling for a default graph.
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 Util::Aliasing::LateBound
Methods included from Enumerable
add_entailment, #canonicalize, #canonicalize!, #dump, #each_graph, #each_object, #each_predicate, #each_quad, #each_statement, #each_subject, #each_term, #each_triple, #entail, #enum_graph, #enum_object, #enum_predicate, #enum_quad, #enum_statement, #enum_subject, #enum_term, #enum_triple, #graph?, #graph_names, #invalid?, #method_missing, #object?, #objects, #predicate?, #predicates, #project_graph, #quad?, #quads, #respond_to_missing?, #statement?, #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(statements: [], **options) {|dataset| ... } ⇒ Dataset
Returns a new instance of Dataset.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/dataset.rb', line 40 def initialize(statements: [], **, &block) @statements = statements.map do |s| s = s.dup s.graph_name ||= DEFAULT_GRAPH s.freeze end.freeze if block_given? case block.arity when 1 then yield self else instance_eval(&block) end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RDF::Enumerable
Instance Method Details
#inspect ⇒ String
Returns a developer-friendly representation of this object.
81 82 83 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/dataset.rb', line 81 def inspect sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, count.to_s) end |
#inspect!
This method returns an undefined value.
Outputs a developer-friendly representation of this object to
stderr
.
90 91 92 93 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/dataset.rb', line 90 def inspect! each_statement { |statement| statement.inspect! } nil end |
#isolation_level ⇒ Symbol
:snapshot
, or :serializable
.
99 100 101 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/dataset.rb', line 99 def isolation_level :read_committed end |
#query_pattern(pattern, **options, &block) ⇒ Object (protected)
Implements basic query pattern matching over the Dataset, with handling for a default graph.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/dataset.rb', line 117 def query_pattern(pattern, **, &block) return super unless pattern.graph_name == DEFAULT_GRAPH if block_given? pattern = pattern.dup pattern.graph_name = nil each_statement do |statement| yield statement if (statement.graph_name == DEFAULT_GRAPH || statement.graph_name.nil?) && pattern === statement end else enum_for(:query_pattern, pattern, ) end end |