![]() |
![]() |
![]() |
Rasqal RDF Query Library Manual | ![]() |
---|---|---|---|---|
Top | Description |
typedef rasqal_expression; enum rasqal_expression_flags; enum rasqal_op; enum rasqal_compare_flags; enum rasqal_pattern_flags; rasqal_expression* rasqal_new_0op_expression (rasqal_world *world
,rasqal_op op
); rasqal_expression* rasqal_new_1op_expression (rasqal_world *world
,rasqal_op op
,rasqal_expression *arg
); rasqal_expression* rasqal_new_2op_expression (rasqal_world *world
,rasqal_op op
,rasqal_expression *arg1
,rasqal_expression *arg2
); rasqal_expression* rasqal_new_3op_expression (rasqal_world *world
,rasqal_op op
,rasqal_expression *arg1
,rasqal_expression *arg2
,rasqal_expression *arg3
); rasqal_expression* rasqal_new_aggregate_function_expression (rasqal_world *world
,rasqal_op op
,rasqal_expression *arg1
,raptor_sequence *params
,unsigned int flags
); rasqal_expression* rasqal_new_cast_expression (rasqal_world *world
,raptor_uri *name
,rasqal_expression *value
); rasqal_expression* rasqal_new_coalesce_expression (rasqal_world *world
,raptor_sequence *args
); rasqal_expression* rasqal_new_function_expression (rasqal_world *world
,raptor_uri *name
,raptor_sequence *args
); rasqal_expression* rasqal_new_function_expression2 (rasqal_world *world
,raptor_uri *name
,raptor_sequence *args
,raptor_sequence *params
,unsigned int flags
); rasqal_expression* rasqal_new_group_concat_expression (rasqal_world *world
,int flags
,raptor_sequence *args
,rasqal_literal *separator
); rasqal_expression* rasqal_new_literal_expression (rasqal_world *world
,rasqal_literal *literal
); rasqal_expression* rasqal_new_set_expression (rasqal_world *world
,rasqal_op op
,rasqal_expression *arg1
,raptor_sequence *args
); rasqal_expression* rasqal_new_string_op_expression (rasqal_world *world
,rasqal_op op
,rasqal_expression *arg1
,rasqal_literal *literal
); rasqal_expression* rasqal_new_expression_from_expression (rasqal_expression *e
); void rasqal_free_expression (rasqal_expression *e
); rasqal_literal* rasqal_expression_evaluate (rasqal_world *world
,raptor_locator *locator
,rasqal_expression *e
,int flags
); int rasqal_expression_print (rasqal_expression *e
,FILE *fh
); void rasqal_expression_print_op (rasqal_expression *e
,FILE *fh
); int (*rasqal_expression_visit_fn) (void *user_data
,rasqal_expression *e
); int rasqal_expression_visit (rasqal_expression *e
,rasqal_expression_visit_fn fn
,void *user_data
);
Expressions form an expression tree that can be evaluated using
rasqal_expression_evaluate()
over rasqal_op operators, rasqal_literal
constants and rasqal_variable values bound in some
rasqal_query_result. The result is a rasqal_literal value.
typedef enum { RASQAL_EXPR_FLAG_DISTINCT = 1, RASQAL_EXPR_FLAG_AGGREGATE = 2 } rasqal_expression_flags;
Flags for expressions.
typedef enum { /* internal */ RASQAL_EXPR_UNKNOWN, RASQAL_EXPR_AND, RASQAL_EXPR_OR, RASQAL_EXPR_EQ, RASQAL_EXPR_NEQ, RASQAL_EXPR_LT, RASQAL_EXPR_GT, RASQAL_EXPR_LE, RASQAL_EXPR_GE, RASQAL_EXPR_UMINUS, RASQAL_EXPR_PLUS, RASQAL_EXPR_MINUS, RASQAL_EXPR_STAR, RASQAL_EXPR_SLASH, RASQAL_EXPR_REM, RASQAL_EXPR_STR_EQ, RASQAL_EXPR_STR_NEQ, RASQAL_EXPR_STR_MATCH, RASQAL_EXPR_STR_NMATCH, RASQAL_EXPR_TILDE, RASQAL_EXPR_BANG, RASQAL_EXPR_LITERAL, RASQAL_EXPR_FUNCTION, RASQAL_EXPR_BOUND, RASQAL_EXPR_STR, RASQAL_EXPR_LANG, RASQAL_EXPR_DATATYPE, RASQAL_EXPR_ISURI, RASQAL_EXPR_ISBLANK, RASQAL_EXPR_ISLITERAL, RASQAL_EXPR_CAST, RASQAL_EXPR_ORDER_COND_ASC, RASQAL_EXPR_ORDER_COND_DESC, RASQAL_EXPR_LANGMATCHES, RASQAL_EXPR_REGEX, RASQAL_EXPR_GROUP_COND_ASC, RASQAL_EXPR_GROUP_COND_DESC, RASQAL_EXPR_COUNT, RASQAL_EXPR_VARSTAR, RASQAL_EXPR_SAMETERM, RASQAL_EXPR_SUM, RASQAL_EXPR_AVG, RASQAL_EXPR_MIN, RASQAL_EXPR_MAX, RASQAL_EXPR_COALESCE, RASQAL_EXPR_IF, RASQAL_EXPR_URI, RASQAL_EXPR_IRI, RASQAL_EXPR_STRLANG, RASQAL_EXPR_STRDT, RASQAL_EXPR_BNODE, RASQAL_EXPR_GROUP_CONCAT, RASQAL_EXPR_SAMPLE, RASQAL_EXPR_IN, RASQAL_EXPR_NOT_IN, /* internal */ RASQAL_EXPR_LAST= RASQAL_EXPR_NOT_IN } rasqal_op;
Rasqal expression operators. A mixture of unary, binary and tertiary operators (string matches). Also includes casting and two ordering operators from ORDER BY in SPARQL.
Internal | |
Expression for AND(A, B) | |
Expression for OR(A, B) | |
Expression for A equals B | |
Expression for A not equals B. | |
Expression for A less than B. | |
Expression for A greather than B. | |
Expression for A less than or equal to B. | |
Expression for A greater than or equal to B. | |
Expression for -A. | |
Expression for +A. | |
Expression for A-B. | |
Expression for A*B. | |
Expression for A/B. | |
Expression for A/B remainder. | |
Expression for A string equals B. | |
Expression for A string not-equals B. | |
Expression for string A matches literal regex B with flags. | |
Expression for string A not-matches literal regex B with flags. | |
Expression for binary not A. | |
Expression for logical not A. | |
Expression for a rasqal_literal. | |
Expression for a function A with arguments (B...). | |
Expression for SPARQL ISBOUND(A). | |
Expression for SPARQL STR(A). | |
Expression for SPARQL LANG(A). | |
Expression for SPARQL DATATYPE(A). | |
Expression for SPARQL ISURI(A). | |
Expression for SPARQL ISBLANK(A). | |
Expression for SPARQL ISLITERAL(A). | |
Expression for cast literal A to type B. | |
Expression for SPARQL order condition ascending. | |
Expression for SPARQL order condition descending. | |
Expression for SPARQL LANGMATCHES(A, B). | |
Expression for string A matches expression regex B with flags. | |
Obsolete - not used | |
Obsolete - not used | |
Expression for LAQRS select COUNT() aggregate function
|
|
Expression for LAQRS select Variable * | |
Expression for SPARQL sameTerm | |
Expression for LAQRS select SUM() aggregate function
|
|
Expression for LAQRS select AVG() aggregate function
|
|
Expression for LAQRS select MIN() aggregate function
|
|
Expression for LAQRS select MAX() aggregate function
|
|
Expression for LAQRS COALESCE(Expr+) | |
Expression for LAQRS IF(expr, expr, expr) | |
Expression for LAQRS URI(expr) | |
Expression for LAQRS IRI(expr) | |
Expression for LAQRS STRLANG(expr, expr) | |
Expression for LAQRS STRDT(expr, expr) | |
Expression for LAQRS BNODE(expr) | |
Expression for LAQRS GROUP_CONCAT(arglist) aggregate function | |
Expression for LAQRS SAMPLE(expr) aggregate function | |
Expression for LAQRS expr IN ( list of expr ) | |
Expression for LAQRS expr NOT IN ( list of expr ) | |
Internal |
typedef enum { RASQAL_COMPARE_NOCASE = 1, RASQAL_COMPARE_XQUERY = 2, RASQAL_COMPARE_RDF = 4, RASQAL_COMPARE_URI = 8, RASQAL_COMPARE_SAMETERM = 16 } rasqal_compare_flags;
Flags for rasqal_expression_evaluate()
, rasqal_literal_compare()
or
rasqal_literal_as_string_flags()
String comparisons are case independent. | |
XQuery comparsion rules apply. | |
RDF Term comparsion rules apply. | |
Allow comparison of URIs and allow strings to have a boolean value (for RDQL) | |
SPARQL sameTerm() builtin rules apply.
|
typedef enum { RASQAL_PATTERN_FLAGS_OPTIONAL=1, RASQAL_PATTERN_FLAGS_LAST=RASQAL_PATTERN_FLAGS_OPTIONAL } rasqal_pattern_flags;
Flags for rasqal_graph_pattern.
rasqal_expression* rasqal_new_0op_expression (rasqal_world *world
,rasqal_op op
);
Constructor - create a new 0-operand (constant) expression.
The operators are:
RASQAL_EXPR_VARSTAR
The only operator here is the '*' in COUNT(*) as used by LAQRS.
|
rasqal_world object |
|
Expression operator |
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_1op_expression (rasqal_world *world
,rasqal_op op
,rasqal_expression *arg
);
Constructor - create a new 1-operand expression. Takes ownership of the operand expression.
The operators are:
RASQAL_EXPR_TILDE
RASQAL_EXPR_BANG
RASQAL_EXPR_UMINUS
RASQAL_EXPR_BOUND
RASQAL_EXPR_STR
RASQAL_EXPR_LANG
RASQAL_EXPR_LANGMATCHES
RASQAL_EXPR_DATATYPE
RASQAL_EXPR_ISURI
RASQAL_EXPR_ISBLANK
RASQAL_EXPR_ISLITERAL
RASQAL_EXPR_ORDER_COND_ASC
RASQAL_EXPR_ORDER_COND_DESC
RASQAL_EXPR_COUNT
RASQAL_EXPR_SUM
RASQAL_EXPR_AVG
RASQAL_EXPR_MIN
RASQAL_EXPR_MAX
RASQAL_EXPR_BANG
and RASQAL_EXPR_UMINUS
are used by RDQL and
SPARQL. RASQAL_EXPR_TILDE
by RDQL only. The rest by SPARQL
only.
|
rasqal_world object |
|
Expression operator |
|
Operand 1 |
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_2op_expression (rasqal_world *world
,rasqal_op op
,rasqal_expression *arg1
,rasqal_expression *arg2
);
Constructor - create a new 2-operand expression. Takes ownership of the operand expressions.
The operators are:
RASQAL_EXPR_AND
RASQAL_EXPR_OR
RASQAL_EXPR_EQ
RASQAL_EXPR_NEQ
RASQAL_EXPR_LT
RASQAL_EXPR_GT
RASQAL_EXPR_LE
RASQAL_EXPR_GE
RASQAL_EXPR_PLUS
RASQAL_EXPR_MINUS
RASQAL_EXPR_STAR
RASQAL_EXPR_SLASH
RASQAL_EXPR_REM
RASQAL_EXPR_STR_EQ
RASQAL_EXPR_STR_NEQ
RASQAL_EXPR_REM
RASQAL_EXPR_STR_EQ
and RASQAL_EXPR_STR_NEQ
are
not used by SPARQL. RASQAL_EXPR_REM
is used by RDQL.
|
rasqal_world object |
|
Expression operator |
|
Operand 1 |
|
Operand 2 |
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_3op_expression (rasqal_world *world
,rasqal_op op
,rasqal_expression *arg1
,rasqal_expression *arg2
,rasqal_expression *arg3
);
Constructor - create a new 3-operand expression. Takes ownership of the operands.
The only operator is:
RASQAL_EXPR_REGEX
|
rasqal_world object |
|
Expression operator |
|
Operand 1 |
|
Operand 2 |
|
Operand 3 (may be NULL) |
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_aggregate_function_expression (rasqal_world *world
,rasqal_op op
,rasqal_expression *arg1
,raptor_sequence *params
,unsigned int flags
);
Constructor - create a new 1-arg aggregate function expression for a builtin aggregate function
Takes ownership of the args
and params
|
rasqal_world object |
|
built-in aggregate function expression operator |
|
rasqal_expression argument to aggregate function |
|
sequence of rasqal_expression function parameters (or NULL) |
|
extension function bitflags |
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_cast_expression (rasqal_world *world
,raptor_uri *name
,rasqal_expression *value
);
Constructor - create a new expression for casting and expression to a datatype. Takes ownership of the datatype uri and expression value.
|
rasqal_world object |
|
cast datatype URI |
|
expression value to cast to datatype type
|
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_coalesce_expression (rasqal_world *world
,raptor_sequence *args
);
Constructor - create a new COALESCE()
with expression arguments.
Takes ownership of the args
|
rasqal_world object |
|
sequence of rasqal_expression coalesce arguments |
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_function_expression (rasqal_world *world
,raptor_uri *name
,raptor_sequence *args
);
Constructor - create a new expression for a function with expression arguments.
Takes ownership of the name
and args
Deprecated
: use rasqal_new_function_expression2()
with extra args
|
rasqal_world object |
|
function name |
|
arguments |
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_function_expression2 (rasqal_world *world
,raptor_uri *name
,raptor_sequence *args
,raptor_sequence *params
,unsigned int flags
);
Constructor - create a new expression for a URI-named function with arguments and optional parameters.
Takes ownership of the name
, args
and params
arguments.
|
rasqal_world object |
|
function name |
|
sequence of rasqal_expression function arguments |
|
sequence of rasqal_expression function parameters (or NULL) |
|
extension function bitflags |
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_group_concat_expression (rasqal_world *world
,int flags
,raptor_sequence *args
,rasqal_literal *separator
);
Constructor - create a new SPARQL group concat expression
Takes an optional distinct flag, a list of expressions and an optional separator string.
Takes ownership of the args
and separator
|
rasqal_world object |
|
bitset of flags. Only RASQAL_EXPR_FLAG_DISTINCT is defined |
|
sequence of rasqal_expression list arguments |
|
SEPARATOR string literal or NULL |
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_literal_expression (rasqal_world *world
,rasqal_literal *literal
);
Constructor - create a new expression for a rasqal_literal Takes ownership of the operand literal.
|
rasqal_world object |
|
Literal operand 1 |
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_set_expression (rasqal_world *world
,rasqal_op op
,rasqal_expression *arg1
,raptor_sequence *args
);
Constructor - create a new set IN/NOT IN operation with expression arguments.
Takes ownership of the arg1
and args
|
rasqal_world object |
|
list operation |
|
expression to look for in list |
|
sequence of rasqal_expression list arguments |
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_string_op_expression (rasqal_world *world
,rasqal_op op
,rasqal_expression *arg1
,rasqal_literal *literal
);
Constructor - create a new expression with one expression and one string operand. Takes ownership of the operands.
The operators are:
RASQAL_EXPR_STR_MATCH
(RDQL, SPARQL) and
RASQAL_EXPR_STR_NMATCH
(RDQL)
|
rasqal_world object |
|
Expression operator |
|
Operand 1 |
|
Literal operand 2 |
Returns : |
a new rasqal_expression object or NULL on failure |
rasqal_expression* rasqal_new_expression_from_expression
(rasqal_expression *e
);
Copy Constructor - create a new rasqal_expression object from an existing rasqal_expression object.
|
rasqal_expression object to copy or NULL |
Returns : |
a new rasqal_expression object or NULL if e is NULL
|
void rasqal_free_expression (rasqal_expression *e
);
Destructor - destroy a rasqal_expression object.
|
rasqal_expression object |
rasqal_literal* rasqal_expression_evaluate (rasqal_world *world
,raptor_locator *locator
,rasqal_expression *e
,int flags
);
Evaluate a rasqal_expression tree to give a rasqal_literal result or error.
|
rasqal_world |
|
error locator (or NULL) |
|
The expression to evaluate. |
|
Flags for rasqal_literal_compare() and RASQAL_COMPARE_NOCASE for string matches.
|
Returns : |
a rasqal_literal value or NULL on failure. |
int rasqal_expression_print (rasqal_expression *e
,FILE *fh
);
Print a Rasqal expression in a debug format.
The print debug format may change in any release.
|
rasqal_expression object. |
|
The FILE* handle to print to. |
Returns : |
non-0 on failure |
void rasqal_expression_print_op (rasqal_expression *e
,FILE *fh
);
Print a rasqal expression operator in a debug format.
The print debug format may change in any release.
|
the rasqal_expression object |
|
the FILE* handle to print to |
int (*rasqal_expression_visit_fn) (void *user_data
,rasqal_expression *e
);
User function to visit an expression and operate on it with
rasqal_expression_visit()
|
user data passed in with rasqal_expression_visit()
|
|
current expression |
Returns : |
non-0 to truncate the visit |
int rasqal_expression_visit (rasqal_expression *e
,rasqal_expression_visit_fn fn
,void *user_data
);
Visit a user function over a rasqal_expression
If the user function fn
returns non-0, the visit is truncated
and the value is returned.
|
rasqal_expression to visit |
|
visit function |
|
user data to pass to visit function |
Returns : |
non-0 if the visit was truncated. |