Compiler
Compiler
SPARQL_Compiler
Bases: Compiler
Abstract base class for SPARQL compilers.
debug
property
Whether debugging is enabled.
default_options
property
The default options of compiler.
omega
property
The maximum number of disjoint queries to generate.
q
property
The current query (top of query stack).
query
property
The current query (top of query stack).
query_stack
property
The compiled query stack.
Query
as_qvar(var)
classmethod
Constructs query variable from variable.
Parameters:
-
var(Variable) –Variable.
Returns:
-
Variable–Query variable.
as_qvars(var, *vars)
classmethod
as_safe_qvar(var)
classmethod
Constructs query variable from variable (safe).
If variable is not of a primitive type, raises an error.
Returns:
-
Variable–Query variable.
as_safe_qvars(var, *vars)
classmethod
bnode()
classmethod
Alias of :meth:Query.bnode.
fresh_data_value_var()
Constructs a fresh data-value variable.
Returns:
-
DataValueVariable–Data-value variable.
fresh_deep_data_value_var()
Constructs a fresh deep data-value variable.
Returns:
-
DeepDataValueVariable–Deep data-value variable.
fresh_entity_var()
Constructs a fresh entity variable.
Returns:
-
EntityVariable–Entity variable.
fresh_external_id_var()
Constructs a fresh external-id variable.
Returns:
-
ExternalIdVariable–External id variable.
fresh_iri_var()
Constructs a fresh IRI variable.
Returns:
-
IRI_Variable–IRI variable.
fresh_item_var()
Constructs a fresh item variable.
Returns:
-
ItemVariable–Item variable.
fresh_lexeme_var()
Constructs a fresh lexeme variable.
Returns:
-
LexemeVariable–Lexeme variable.
fresh_property_var()
Constructs a fresh property variable.
Returns:
-
PropertyVariable–Property variable.
fresh_qualifier_record_var()
Constructs a fresh qualifier record variable.
Returns:
-
QualifierRecordVariable–Qualifier record variable.
fresh_quantity_var()
Constructs a fresh quantity variable.
Returns:
-
QuantityVariable–Quantity variable.
fresh_qvar()
Constructs a fresh query variable.
Returns:
-
Variable–Query variable.
fresh_qvars(n)
Constructs one or more fresh query variables.
Returns:
-
Iterator[Variable]–Iterator of variables.
fresh_rank_var()
Constructs a fresh rank variable.
Returns:
-
RankVariable–Rank variable.
fresh_reference_record_set_var()
Constructs a fresh reference record set variable.
Returns:
-
ReferenceRecordSetVariable–Reference record set variable.
fresh_shallow_data_value_var()
Constructs a fresh shallow data-value variable.
Returns:
-
ShallowDataValueVariable–Shallow data-value variable.
fresh_string_var()
Constructs a fresh string variable.
Returns:
-
StringVariable–String variable.
fresh_text_var()
Constructs a fresh text variable.
Returns:
-
TextVariable–Text variable.
fresh_time_var()
Constructs a fresh time variable.
Returns:
-
TimeVariable–Time variable.
fresh_var(variable_class)
fresh_vars(variable_class, n)
get_debug()
get_default_options(context=None)
Gets the default options of compiler.
Parameters:
-
context(Context | None, default:None) –Context.
Returns:
-
SPARQL_CompilerOptions–Compiler options.
get_omega()
Gets the maximum number of disjoint queries to generate.
Returns:
-
int–Maximum number of disjoint queries.
get_query()
get_query_stack()
literal(content, language=None, datatype=None)
classmethod
Alias of :meth:Query.literal.
pop_query()
push_query(query=None)
Pushes query onto query stack.
If query is None, pushes an empty query.
Returns:
-
Query–The pushed query.
qvar(name)
classmethod
Alias of :meth:Query.var.
qvars(var, *vars)
classmethod
Alias of :meth:Query.vars.
uri(content)
classmethod
Alias of :meth:Query.uri.
SPARQL_FilterCompiler
Bases: SPARQL_Compiler
SPARQL filter compiler
entry
property
The entry associated with current frame.
filter
property
The (normalized) source filter.
frame
property
The current frame.
mapping
property
The SPARQL mapping.
pattern
property
The source pattern.
phase
property
The compilation phase associated with the current frame.
targets
property
The target patterns associated with current frame.
theta
property
The substitution associated with the current frame.
Frame
Bases: TypedDict
Compilation frame (context).
Phase
Projection
build_query(query, projection=None, distinct=None, limit=None, offset=None)
Constructs a filter query.
Parameters:
-
query(Query) –Query.
-
projection(Projection | None, default:None) –Projection mask.
-
distinct(bool | None, default:None) –Whether to enable the distinct modifier.
-
limit(int | None, default:None) –Limit.
-
offset(int | None, default:None) –Offset.
Returns:
-
Query–Filter query.
build_results()
get_entry()
Gets the entry associated with current frame.
Returns:
-
Entry–SPARQL mapping entry.
get_filter()
get_frame()
get_mapping()
get_pattern()
Gets the source pattern.
Returns:
-
Pattern–Pattern.
get_phase()
get_targets()
Gets the target patterns associated with current frame.
Returns:
-
Sequence[EntryPattern]–Sequence of SPARQL mapping entry patterns.
get_theta()
Gets the substitution associated with the current frame.
Returns:
-
Substitution–Substitution.
is_compiling_filter()
Tests whether compiler is in "compiling filter" phase.
Returns:
-
bool–Trueif successful;Falseotherwise.
is_compiling_fingerprint()
Tests whether compiler is in "compiling fingerprint" phase.
Returns:
-
bool–Trueif successful;Falseotherwise.
is_done()
is_ready()
pop_frame()
push_frame(phase, entry=None, theta=None, targets=None)
Pushes a new compilation frame making it the current frame.
phase: Compilation phase. entry: Mapping entry. theta: Substitution. targets: Mapping entry patterns.
Returns:
-
Frame–The pushed frame.
theta_add(variable, value)
Adds variable-value pair to the current substitution.
Parameters:
-
variable(Variable) –Variable.
-
value(T) –Value.
Returns:
-
T–Value.
theta_add_as_qvar(variable)
Adds variable-query variable to the current substitution.
Parameters:
-
variable(Variable) –Variable.
Returns:
-
Variable–Query variable.