Graph patterns

Graph patterns — Collections of triple patterns, sub-graph patterns with operators.

Synopsis

typedef             rasqal_graph_pattern;
int                 rasqal_graph_pattern_add_sub_graph_pattern
                                                        (rasqal_graph_pattern *graph_pattern,
                                                         rasqal_graph_pattern *sub_graph_pattern);
rasqal_expression * rasqal_graph_pattern_get_filter_expression
                                                        (rasqal_graph_pattern *gp);
int                 rasqal_graph_pattern_set_filter_expression
                                                        (rasqal_graph_pattern *gp,
                                                         rasqal_expression *expr);
raptor_sequence *   rasqal_graph_pattern_get_flattened_triples
                                                        (rasqal_query *query,
                                                         rasqal_graph_pattern *graph_pattern);
int                 rasqal_graph_pattern_get_index      (rasqal_graph_pattern *gp);
rasqal_graph_pattern_operator rasqal_graph_pattern_get_operator
                                                        (rasqal_graph_pattern *graph_pattern);
rasqal_literal *    rasqal_graph_pattern_get_origin     (rasqal_graph_pattern *graph_pattern);
rasqal_graph_pattern * rasqal_graph_pattern_get_sub_graph_pattern
                                                        (rasqal_graph_pattern *graph_pattern,
                                                         int idx);
raptor_sequence *   rasqal_graph_pattern_get_sub_graph_pattern_sequence
                                                        (rasqal_graph_pattern *graph_pattern);
rasqal_triple *     rasqal_graph_pattern_get_triple     (rasqal_graph_pattern *graph_pattern,
                                                         int idx);
raptor_sequence *   rasqal_graph_pattern_get_triples    (rasqal_query *query,
                                                         rasqal_graph_pattern *graph_pattern);
rasqal_literal *    rasqal_graph_pattern_get_service    (rasqal_graph_pattern *graph_pattern);
rasqal_variable *   rasqal_graph_pattern_get_variable   (rasqal_graph_pattern *graph_pattern);
enum                rasqal_graph_pattern_operator;
const char *        rasqal_graph_pattern_operator_as_string
                                                        (rasqal_graph_pattern_operator op);
int                 rasqal_graph_pattern_print          (rasqal_graph_pattern *gp,
                                                         FILE *fh);
int                 rasqal_graph_pattern_variable_bound_in
                                                        (rasqal_graph_pattern *gp,
                                                         rasqal_variable *v);
int                 (*rasqal_graph_pattern_visit_fn)    (rasqal_query *query,
                                                         rasqal_graph_pattern *gp,
                                                         void *user_data);
int                 rasqal_graph_pattern_visit          (rasqal_query *query,
                                                         rasqal_graph_pattern *gp,
                                                         rasqal_graph_pattern_visit_fn fn,
                                                         void *user_data);

Description

Graph patterns form a a tree structure that build a rasqal_query top-level graph pattern (see rasqal_query_get_query_graph_pattern()) which may have sub-graph patterns. Graph patterns at the leaf of the tree operate over triple patterns (rasqal_triple) matching the RDF triples in the data sources for RASQAL_GRAPH_PATTERN_OPERATOR_BASIC or RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL. Other graph patterns operators operate over sub graph patterns and group them, union them or apply a GRAPH matching keyword (RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH).

Details

rasqal_graph_pattern

rasqal_graph_pattern* graph_pattern;

Rasqal graph pattern class.


rasqal_graph_pattern_add_sub_graph_pattern ()

int                 rasqal_graph_pattern_add_sub_graph_pattern
                                                        (rasqal_graph_pattern *graph_pattern,
                                                         rasqal_graph_pattern *sub_graph_pattern);

Add a sub graph pattern to a graph pattern.

graph_pattern :

graph pattern to add to

sub_graph_pattern :

graph pattern to add inside

Returns :

non-0 on failure

rasqal_graph_pattern_get_filter_expression ()

rasqal_expression * rasqal_graph_pattern_get_filter_expression
                                                        (rasqal_graph_pattern *gp);

Get a filter graph pattern's constraint expression

gp :

rasqal_graph_pattern query object

Returns :

expression or NULL on failure

rasqal_graph_pattern_set_filter_expression ()

int                 rasqal_graph_pattern_set_filter_expression
                                                        (rasqal_graph_pattern *gp,
                                                         rasqal_expression *expr);

Set a filter graph pattern constraint expression

gp :

rasqal_graph_pattern query object

expr :

rasqal_expression expr - ownership taken

Returns :

non-0 on failure

rasqal_graph_pattern_get_flattened_triples ()

raptor_sequence *   rasqal_graph_pattern_get_flattened_triples
                                                        (rasqal_query *query,
                                                         rasqal_graph_pattern *graph_pattern);

Get the triples inside a tree of graph patterns (BASIC + GRAPH) as a single sequence with GRAPHs turned into triple origin.

The returned sequence and all the rasqal_triple in it are owned by the caller (hold references).

query :

query

graph_pattern :

graph pattern

Returns :

new sequence of raptor_triple or NULL on failure

rasqal_graph_pattern_get_index ()

int                 rasqal_graph_pattern_get_index      (rasqal_graph_pattern *gp);

Get the graph pattern absolute index in the array of graph patterns.

The graph pattern index is assigned when rasqal_query_prepare() is run on a query containing a graph pattern.

gp :

rasqal_graph_pattern graph pattern

Returns :

index or <0 if no index has been assigned yet

rasqal_graph_pattern_get_operator ()

rasqal_graph_pattern_operator rasqal_graph_pattern_get_operator
                                                        (rasqal_graph_pattern *graph_pattern);

Get the graph pattern operator .

The operator for the given graph pattern. See also rasqal_graph_pattern_operator_as_string().

graph_pattern :

rasqal_graph_pattern graph pattern object

Returns :

graph pattern operator

rasqal_graph_pattern_get_origin ()

rasqal_literal *    rasqal_graph_pattern_get_origin     (rasqal_graph_pattern *graph_pattern);

Get the graph pattern literal for RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH graph pattern

graph_pattern :

rasqal_graph_pattern graph pattern object

Returns :

graph literal parameter or NULL if wrong graph pattern type or not defined

rasqal_graph_pattern_get_sub_graph_pattern ()

rasqal_graph_pattern * rasqal_graph_pattern_get_sub_graph_pattern
                                                        (rasqal_graph_pattern *graph_pattern,
                                                         int idx);

Get a sub-graph pattern inside a graph pattern.

graph_pattern :

rasqal_graph_pattern graph pattern object

idx :

index into the sequence of sub graph_patterns in the graph pattern

Returns :

rasqal_graph_pattern or NULL if out of range

rasqal_graph_pattern_get_sub_graph_pattern_sequence ()

raptor_sequence *   rasqal_graph_pattern_get_sub_graph_pattern_sequence
                                                        (rasqal_graph_pattern *graph_pattern);

Get the sequence of graph patterns inside a graph pattern .

graph_pattern :

rasqal_graph_pattern graph pattern object

Returns :

a raptor_sequence of rasqal_graph_pattern pointers.

rasqal_graph_pattern_get_triple ()

rasqal_triple *     rasqal_graph_pattern_get_triple     (rasqal_graph_pattern *graph_pattern,
                                                         int idx);

Get a triple inside a graph pattern.

graph_pattern :

rasqal_graph_pattern graph pattern object

idx :

index into the sequence of triples in the graph pattern

Returns :

rasqal_triple or NULL if out of range

rasqal_graph_pattern_get_triples ()

raptor_sequence *   rasqal_graph_pattern_get_triples    (rasqal_query *query,
                                                         rasqal_graph_pattern *graph_pattern);

Get the triples inside this graph pattern (if any).

The returned sequence and all the rasqal_triple in it are owned by the caller (hold references).

query :

query

graph_pattern :

graph pattern

Returns :

new sequence of raptor_triple or NULL on failure or no triples

rasqal_graph_pattern_get_service ()

rasqal_literal *    rasqal_graph_pattern_get_service    (rasqal_graph_pattern *graph_pattern);

Get the literal for RASQAL_GRAPH_PATTERN_OPERATOR_SERVICE graph pattern

graph_pattern :

rasqal_graph_pattern graph pattern object

Returns :

graph variable or NULL if wrong graph pattern or not defined

rasqal_graph_pattern_get_variable ()

rasqal_variable *   rasqal_graph_pattern_get_variable   (rasqal_graph_pattern *graph_pattern);

Get the variable for RASQAL_GRAPH_PATTERN_OPERATOR_LET graph pattern

graph_pattern :

rasqal_graph_pattern graph pattern object

Returns :

graph variable or NULL if wrong graph pattern or not defined

enum rasqal_graph_pattern_operator

typedef enum {
  RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN   = 0,
  RASQAL_GRAPH_PATTERN_OPERATOR_BASIC     = 1,
  RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL  = 2,
  RASQAL_GRAPH_PATTERN_OPERATOR_UNION     = 3,
  RASQAL_GRAPH_PATTERN_OPERATOR_GROUP     = 4,
  RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH     = 5,
  RASQAL_GRAPH_PATTERN_OPERATOR_FILTER    = 6,
  RASQAL_GRAPH_PATTERN_OPERATOR_LET       = 7,
  RASQAL_GRAPH_PATTERN_OPERATOR_SELECT    = 8,
  RASQAL_GRAPH_PATTERN_OPERATOR_SERVICE   = 9,
  RASQAL_GRAPH_PATTERN_OPERATOR_MINUS     = 10,
  RASQAL_GRAPH_PATTERN_OPERATOR_VALUES    = 11,

  RASQAL_GRAPH_PATTERN_OPERATOR_LAST = RASQAL_GRAPH_PATTERN_OPERATOR_VALUES
} rasqal_graph_pattern_operator;

Graph pattern operators

RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN

Internal.

RASQAL_GRAPH_PATTERN_OPERATOR_BASIC

Just triple patterns and constraints.

RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL

Set of graph patterns (ANDed) and constraints.

RASQAL_GRAPH_PATTERN_OPERATOR_UNION

Set of graph patterns (UNIONed) and constraints.

RASQAL_GRAPH_PATTERN_OPERATOR_GROUP

Set of graph patterns (ANDed) and constraints.

RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH

A graph term + a graph pattern and constraints.

RASQAL_GRAPH_PATTERN_OPERATOR_FILTER

A filter graph pattern with an expression

RASQAL_GRAPH_PATTERN_OPERATOR_LET

LET ?var := Expression (LAQRS)

RASQAL_GRAPH_PATTERN_OPERATOR_SELECT

SELECT graph pattern

RASQAL_GRAPH_PATTERN_OPERATOR_SERVICE

SERVICE graph pattern

RASQAL_GRAPH_PATTERN_OPERATOR_MINUS

MINUS graph pattern

RASQAL_GRAPH_PATTERN_OPERATOR_VALUES

VALUES graph pattern

RASQAL_GRAPH_PATTERN_OPERATOR_LAST

Internal.

rasqal_graph_pattern_operator_as_string ()

const char *        rasqal_graph_pattern_operator_as_string
                                                        (rasqal_graph_pattern_operator op);

Get a string for the query verb.

op :

the rasqal_graph_pattern_operator verb of the query

Returns :

pointer to a shared string label for the query verb

rasqal_graph_pattern_print ()

int                 rasqal_graph_pattern_print          (rasqal_graph_pattern *gp,
                                                         FILE *fh);

Print a rasqal_graph_pattern in a debug format.

The print debug format may change in any release.

gp :

the rasqal_graph_pattern object

fh :

the FILE* handle to print to

Returns :

non-0 on failure

rasqal_graph_pattern_variable_bound_in ()

int                 rasqal_graph_pattern_variable_bound_in
                                                        (rasqal_graph_pattern *gp,
                                                         rasqal_variable *v);

Is the variable bound in this graph pattern (not including children)?

gp :

graph pattern

v :

variable

Returns :

non-0 if variable is bound in the given graph pattern.

rasqal_graph_pattern_visit_fn ()

int                 (*rasqal_graph_pattern_visit_fn)    (rasqal_query *query,
                                                         rasqal_graph_pattern *gp,
                                                         void *user_data);

User function to visit an graph_pattern and operate on it with rasqal_graph_pattern_visit() or rasqal_query_graph_pattern_visit()

query :

rasqal_query containing the graph pattern

gp :

current graph_pattern

user_data :

user data passed in

Returns :

non-0 to truncate the visit

rasqal_graph_pattern_visit ()

int                 rasqal_graph_pattern_visit          (rasqal_query *query,
                                                         rasqal_graph_pattern *gp,
                                                         rasqal_graph_pattern_visit_fn fn,
                                                         void *user_data);

Visit a user function over a rasqal_graph_pattern

If the user function fn returns 0, the visit is truncated.

query :

rasqal_query to operate on

gp :

rasqal_graph_pattern graph pattern

fn :

pointer to function to apply that takes user data and graph pattern parameters

user_data :

user data for applied function

Returns :

0 if the visit was truncated.


Navigation: Redland Home Page

Copyright 2000-2023 Dave Beckett