Class: SPARQL::Algebra::Operator::StrUUID

Inherits:
Nullary show all
Includes:
Evaluatable
Defined in:
lib/sparql/algebra/operator/struuid.rb

Overview

[121] BuiltInCall ::= ... | 'STRUUID' NIL

Examples:

SPARQL Grammar

PREFIX : <http://example.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT (STRLEN(?uuid) AS ?length)
WHERE {
  BIND(STRUUID() AS ?uuid)
  FILTER(ISLITERAL(?uuid) && REGEX(?uuid, "^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$", "i"))
}

SSE

(prefix ((: <http://example.org/>) (xsd: <http://www.w3.org/2001/XMLSchema#>))
 (project (?length)
  (extend ((?length (strlen ?uuid)))
   (filter
    (&&
     (isLiteral ?uuid)
     (regex ?uuid "^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$" "i"))
    (extend ((?uuid (struuid)))
     (bgp))))))

See Also:

Constant Summary collapse

NAME =
:struuid

Constants inherited from Nullary

Nullary::ARITY

Constants inherited from SPARQL::Algebra::Operator

ARITY, IsURI, URI

Constants included from Expression

Expression::PATTERN_PARENTS

Instance Attribute Summary

Attributes inherited from SPARQL::Algebra::Operator

#operands

Instance Method Summary collapse

Methods included from Evaluatable

#evaluate, #memoize, #replace_aggregate!, #replace_vars!

Methods inherited from Nullary

#initialize

Methods inherited from SPARQL::Algebra::Operator

#aggregate?, arity, #base_uri, base_uri, base_uri=, #bind, #boolean, #constant?, #deep_dup, #each_descendant, #eql?, #evaluatable?, evaluate, #executable?, #first_ancestor, for, #initialize, #inspect, #ndvars, #node?, #operand, #optimize, #optimize!, #parent, #parent=, #prefixes, prefixes, prefixes=, #rewrite, #to_binary, to_sparql, #to_sxp, #to_sxp_bin, #validate!, #variable?, #variables, #vars

Methods included from Expression

cast, #constant?, #evaluate, extension, extension?, extensions, for, #invalid?, new, #node?, open, #optimize, #optimize!, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?

Constructor Details

This class inherits a constructor from SPARQL::Algebra::Operator::Nullary

Instance Method Details

#apply(**options) ⇒ RDF::URI

Return a string that is the scheme specific part of UUID. That is, as a simple literal, the result of generating a UUID, converting to a simple literal and removing the initial urn:uuid:.

Returns:

  • (RDF::URI)


38
39
40
# File 'lib/sparql/algebra/operator/struuid.rb', line 38

def apply(**options)
  RDF::Literal(SecureRandom.uuid)
end

#to_sparql(**options) ⇒ String

Returns a partial SPARQL grammar for this operator.

Returns:

  • (String)


47
48
49
# File 'lib/sparql/algebra/operator/struuid.rb', line 47

def to_sparql(**options)
  "STRUUID(" + operands.to_sparql(delimiter: ', ', **options) + ")"
end