Rasqal RDF Query Library Manual | ||||
---|---|---|---|---|
Top | Description |
typedef rasqal_query_results; rasqal_query_results * rasqal_new_query_results (rasqal_world *world
,rasqal_query *query
,rasqal_query_results_type type
,rasqal_variables_table *vars_table
); rasqal_query_results * rasqal_new_query_results2 (rasqal_world *world
,rasqal_query *query
,rasqal_query_results_type type
); rasqal_query_results * rasqal_new_query_results_from_string (rasqal_world *world
,rasqal_query_results_type type
,raptor_uri *base_uri
,const char *string
,size_t string_len
); void rasqal_free_query_results (rasqal_query_results *query_results
); int rasqal_query_results_add_row (rasqal_query_results *query_results
,rasqal_row *row
); int rasqal_query_results_finished (rasqal_query_results *query_results
); const unsigned char * rasqal_query_results_get_binding_name (rasqal_query_results *query_results
,int offset
); rasqal_literal * rasqal_query_results_get_binding_value (rasqal_query_results *query_results
,int offset
); rasqal_literal * rasqal_query_results_get_binding_value_by_name (rasqal_query_results *query_results
,const char *name
); int rasqal_query_results_get_bindings (rasqal_query_results *query_results
,const unsigned char ***names
,rasqal_literal ***values
); int rasqal_query_results_get_bindings_count (rasqal_query_results *query_results
); int rasqal_query_results_get_boolean (rasqal_query_results *query_results
); int rasqal_query_results_get_count (rasqal_query_results *query_results
); rasqal_query * rasqal_query_results_get_query (rasqal_query_results *query_results
); raptor_statement * rasqal_query_results_get_triple (rasqal_query_results *query_results
); rasqal_row * rasqal_query_results_get_row_by_offset (rasqal_query_results *query_results
,int result_offset
); rasqal_query_results_type rasqal_query_results_get_type (rasqal_query_results *query_results
); int rasqal_query_results_is_bindings (rasqal_query_results *query_results
); int rasqal_query_results_is_boolean (rasqal_query_results *query_results
); int rasqal_query_results_is_graph (rasqal_query_results *query_results
); int rasqal_query_results_is_syntax (rasqal_query_results *query_results
); int rasqal_query_results_next (rasqal_query_results *query_results
); int rasqal_query_results_next_triple (rasqal_query_results *query_results
); int rasqal_query_results_read (raptor_iostream *iostr
,rasqal_query_results *results
,const char *name
,const char *mime_type
,raptor_uri *format_uri
,raptor_uri *base_uri
); int rasqal_query_results_write (raptor_iostream *iostr
,rasqal_query_results *results
,const char *name
,const char *mime_type
,raptor_uri *format_uri
,raptor_uri *base_uri
); enum rasqal_query_results_type; const char * rasqal_query_results_type_label (rasqal_query_results_type type
); int rasqal_query_results_rewind (rasqal_query_results *query_results
);
A query results object is only ever constructed by the internal
query engine evaluating a rasqal_query with rasqal_query_execute()
.
It provides interface to the multiple types of result supported.
There are a large set of methods for returning all or parts of a
variable binding query result including the names, values or
individuals. A boolean result is straightforward to get with
rasqal_query_results_get_boolean()
and an RDF graph returns a
sequence of raptor triples than can be easily passed to the Raptor
library for serializing to a syntax.
rasqal_query_results * rasqal_new_query_results (rasqal_world *world
,rasqal_query *query
,rasqal_query_results_type type
,rasqal_variables_table *vars_table
);
Constructor - create a new query results set
Deprecated
for rasqal_new_query_results2()
that loses the unused argument.
The query
may be NULL for result set objects that are standalone
and not attached to any particular query
|
rasqal world object |
|
query object (or NULL) |
|
query results (expected) type |
|
This parameter is *IGNORED* |
Returns : |
a new query result object or NULL on failure |
rasqal_query_results * rasqal_new_query_results2 (rasqal_world *world
,rasqal_query *query
,rasqal_query_results_type type
);
Constructor - create a new query results set
The query
may be NULL for result set objects that are standalone
and not attached to any particular query
|
rasqal world object |
|
query object (or NULL) |
|
query results (expected) type |
Returns : |
a new query result object or NULL on failure |
rasqal_query_results * rasqal_new_query_results_from_string (rasqal_world *world
,rasqal_query_results_type type
,raptor_uri *base_uri
,const char *string
,size_t string_len
);
Constructor - create a new query results set from a results format string
|
rasqal world object |
|
query results (expected) type; typically RASQAL_QUERY_RESULTS_BINDINGS |
|
base URI of query results format (or NULL) |
|
query results string |
|
length of string (or 0 to calculate it here) |
Returns : |
a new query result object or NULL on failure |
void rasqal_free_query_results (rasqal_query_results *query_results
);
Destructor - destroy a rasqal_query_results.
|
rasqal_query_results object |
int rasqal_query_results_add_row (rasqal_query_results *query_results
,rasqal_row *row
);
Add a query result row to the sequence of result rows
|
query results object |
|
query result row |
Returns : |
non-0 on failure |
int rasqal_query_results_finished (rasqal_query_results *query_results
);
Find out if binding results are exhausted.
|
rasqal_query_results query_results |
Returns : |
non-0 if results are finished or query failed |
const unsigned char * rasqal_query_results_get_binding_name (rasqal_query_results *query_results
,int offset
);
Get binding name for the current result.
|
rasqal_query_results query_results |
|
offset of binding name into array of known names |
Returns : |
a pointer to a shared copy of the binding name or NULL on failure |
rasqal_literal * rasqal_query_results_get_binding_value (rasqal_query_results *query_results
,int offset
);
Get one binding value for the current result.
|
rasqal_query_results query_results |
|
offset of binding name into array of known names |
Returns : |
a pointer to a shared rasqal_literal binding value or NULL on failure |
rasqal_literal * rasqal_query_results_get_binding_value_by_name (rasqal_query_results *query_results
,const char *name
);
Get one binding value for a given name in the current result.
|
rasqal_query_results query_results |
|
variable name |
Returns : |
a pointer to a shared rasqal_literal binding value or NULL on failure |
int rasqal_query_results_get_bindings (rasqal_query_results *query_results
,const unsigned char ***names
,rasqal_literal ***values
);
Get all binding names, values for current result.
If names is not NULL, it is set to the address of a shared array of names of the bindings (an output parameter). These names are shared and must not be freed by the caller
If values is not NULL, it is set to the address of a shared array of rasqal_literal* binding values. These values are shaerd and must not be freed by the caller.
|
rasqal_query_results query_results |
|
pointer to an array of binding names (or NULL) |
|
pointer to an array of binding value rasqal_literal (or NULL) |
Returns : |
non-0 if the assignment failed |
int rasqal_query_results_get_bindings_count
(rasqal_query_results *query_results
);
Get the number of bound variables in the result.
|
rasqal_query_results query_results |
Returns : |
<0 if failed or results exhausted |
int rasqal_query_results_get_boolean (rasqal_query_results *query_results
);
Get boolean query result.
The return value is only meaningful if this is a boolean
query result - see rasqal_query_results_is_boolean()
|
rasqal_query_results query_results |
Returns : |
boolean query result - >0 is true, 0 is false, <0 on error |
int rasqal_query_results_get_count (rasqal_query_results *query_results
);
Get number of bindings so far.
|
rasqal_query_results query_results |
Returns : |
number of bindings found so far or < 0 on failure |
rasqal_query * rasqal_query_results_get_query (rasqal_query_results *query_results
);
Get thq query associated with this query result
|
rasqal_query_results object |
Returns : |
shared pointer to query object |
raptor_statement * rasqal_query_results_get_triple (rasqal_query_results *query_results
);
Get the current triple in the result.
The return value is a shared raptor_statement.
|
rasqal_query_results query_results |
Returns : |
raptor_statement or NULL if failed or results exhausted |
rasqal_row * rasqal_query_results_get_row_by_offset (rasqal_query_results *query_results
,int result_offset
);
Get stored result row by an offset
The result_offset index is 0-indexed into the subset of results constrained by any query limit and offset.
|
query result |
|
index into result rows |
Returns : |
row or NULL if result_offset is out of range |
rasqal_query_results_type rasqal_query_results_get_type (rasqal_query_results *query_results
);
Get query results type
|
rasqal_query_results object |
Returns : |
non-0 if true |
int rasqal_query_results_is_bindings (rasqal_query_results *query_results
);
Test if rasqal_query_results is variable bindings format.
|
rasqal_query_results object |
Returns : |
non-0 if true |
int rasqal_query_results_is_boolean (rasqal_query_results *query_results
);
Test if rasqal_query_results is boolean format.
|
rasqal_query_results object |
Returns : |
non-0 if true |
int rasqal_query_results_is_graph (rasqal_query_results *query_results
);
Test if rasqal_query_results is RDF graph format.
|
rasqal_query_results object |
Returns : |
non-0 if true |
int rasqal_query_results_is_syntax (rasqal_query_results *query_results
);
Test if the rasqal_query_results is a syntax.
Many of the query results may be formatted as a syntax using the rasqal_query_formatter class however this function returns true if a syntax result was specifically requested.
|
rasqal_query_results object |
Returns : |
non-0 if true |
int rasqal_query_results_next (rasqal_query_results *query_results
);
Move to the next result.
|
rasqal_query_results query_results |
Returns : |
non-0 if failed or results exhausted |
int rasqal_query_results_next_triple (rasqal_query_results *query_results
);
Move to the next triple result.
|
rasqal_query_results query_results |
Returns : |
non-0 if failed or results exhausted |
int rasqal_query_results_read (raptor_iostream *iostr
,rasqal_query_results *results
,const char *name
,const char *mime_type
,raptor_uri *format_uri
,raptor_uri *base_uri
);
Read the query results from an iostream in a format.
This uses the rasqal_query_results_formatter class
and the rasqal_query_results_formatter_read()
method
to perform the formatting.
See rasqal_world_get_query_results_format_description()
for
obtaining the supported format URIs at run time.
|
raptor_iostream to read the query from |
|
rasqal_query_results query results format |
|
format name (or NULL) |
|
format mime type (or NULL) |
|
raptor_uri describing the format to read (or NULL for default) |
|
raptor_uri base URI of the input format |
Returns : |
non-0 on failure |
int rasqal_query_results_write (raptor_iostream *iostr
,rasqal_query_results *results
,const char *name
,const char *mime_type
,raptor_uri *format_uri
,raptor_uri *base_uri
);
Write the query results to an iostream in a format.
This uses the rasqal_query_results_formatter class and the
rasqal_query_results_formatter_write()
method to perform the
formatting.
Note that after calling this method, the query results will be
empty and rasqal_query_results_finished()
will return true (non-0)
See rasqal_world_get_query_results_format_description()
for obtaining the
supported format names, mime_types and URIs at run time.
|
raptor_iostream to write the query to |
|
rasqal_query_results query results format |
|
format name (or NULL) |
|
format mime type (or NULL) |
|
raptor_uri describing the format to write (or NULL for default) |
|
raptor_uri base URI of the output format |
Returns : |
non-0 on failure |
typedef enum { RASQAL_QUERY_RESULTS_BINDINGS, RASQAL_QUERY_RESULTS_BOOLEAN, RASQAL_QUERY_RESULTS_GRAPH, RASQAL_QUERY_RESULTS_SYNTAX, RASQAL_QUERY_RESULTS_UNKNOWN, RASQAL_QUERY_RESULTS_LAST = RASQAL_QUERY_RESULTS_UNKNOWN } rasqal_query_results_type;
Query result type.
const char * rasqal_query_results_type_label (rasqal_query_results_type type
);
Get a label for a query results type
|
rasqal_query_results_type type |
Returns : |
label or NULL on failure (invalid type) |
int rasqal_query_results_rewind (rasqal_query_results *query_results
);
Rewind stored query results to start
This requires rasqal_query_set_store_results()
to be called before
query execution.
|
rasqal_query_results query_results |
Returns : |
non-0 if rewinding is not available when results are not stored |
Navigation: Redland Home Page