Redland RDF Library Manual | ||||
---|---|---|---|---|
Top | Description |
#define LIBRDF_STORAGE_INTERFACE_VERSION #define LIBRDF_STORAGE_MAX_INTERFACE_VERSION #define LIBRDF_STORAGE_MIN_INTERFACE_VERSION typedef librdf_storage; typedef librdf_storage_factory; int librdf_storage_register_factory (librdf_world *world
,const char *name
,const char *label
,void (*factory) (librdf_storage_factory*)
); int librdf_storage_enumerate (librdf_world *world
,const unsigned int counter
,const char **name
,const char **label
); librdf_storage * librdf_new_storage (librdf_world *world
,const char *storage_name
,const char *name
,const char *options_string
); librdf_storage * librdf_new_storage_with_options (librdf_world *world
,const char *storage_name
,const char *name
,librdf_hash *options
); librdf_storage * librdf_new_storage_from_storage (librdf_storage *old_storage
); librdf_storage * librdf_new_storage_from_factory (librdf_world *world
,librdf_storage_factory *factory
,const char *name
,librdf_hash *options
); void librdf_free_storage (librdf_storage *storage
); int librdf_storage_open (librdf_storage *storage
,librdf_model *model
); int librdf_storage_close (librdf_storage *storage
); int librdf_storage_size (librdf_storage *storage
); int librdf_storage_add_statement (librdf_storage *storage
,librdf_statement *statement
); int librdf_storage_add_statements (librdf_storage *storage
,librdf_stream *statement_stream
); int librdf_storage_remove_statement (librdf_storage *storage
,librdf_statement *statement
); int librdf_storage_contains_statement (librdf_storage *storage
,librdf_statement *statement
); librdf_stream * librdf_storage_serialise (librdf_storage *storage
); librdf_stream * librdf_storage_find_statements (librdf_storage *storage
,librdf_statement *statement
); librdf_stream * librdf_storage_find_statements_with_options (librdf_storage *storage
,librdf_statement *statement
,librdf_node *context_node
,librdf_hash *options
); librdf_iterator * librdf_storage_get_sources (librdf_storage *storage
,librdf_node *arc
,librdf_node *target
); librdf_iterator * librdf_storage_get_arcs (librdf_storage *storage
,librdf_node *source
,librdf_node *target
); librdf_iterator * librdf_storage_get_targets (librdf_storage *storage
,librdf_node *source
,librdf_node *arc
); librdf_iterator * librdf_storage_get_arcs_in (librdf_storage *storage
,librdf_node *node
); librdf_iterator * librdf_storage_get_arcs_out (librdf_storage *storage
,librdf_node *node
); int librdf_storage_has_arc_in (librdf_storage *storage
,librdf_node *node
,librdf_node *property
); int librdf_storage_has_arc_out (librdf_storage *storage
,librdf_node *node
,librdf_node *property
); int librdf_storage_context_add_statement (librdf_storage *storage
,librdf_node *context
,librdf_statement *statement
); int librdf_storage_context_add_statements (librdf_storage *storage
,librdf_node *context
,librdf_stream *stream
); int librdf_storage_context_remove_statement (librdf_storage *storage
,librdf_node *context
,librdf_statement *statement
); int librdf_storage_context_remove_statements (librdf_storage *storage
,librdf_node *context
); librdf_stream * librdf_storage_context_as_stream (librdf_storage *storage
,librdf_node *context
); librdf_stream * librdf_storage_context_serialise (librdf_storage *storage
,librdf_node *context
); int librdf_storage_supports_query (librdf_storage *storage
,librdf_query *query
); librdf_query_results * librdf_storage_query_execute (librdf_storage *storage
,librdf_query *query
); int librdf_storage_sync (librdf_storage *storage
); librdf_stream * librdf_storage_find_statements_in_context (librdf_storage *storage
,librdf_statement *statement
,librdf_node *context_node
); librdf_iterator * librdf_storage_get_contexts (librdf_storage *storage
); librdf_node * librdf_storage_get_feature (librdf_storage *storage
,librdf_uri *feature
); int librdf_storage_set_feature (librdf_storage *storage
,librdf_uri *feature
,librdf_node *value
); int librdf_storage_transaction_commit (librdf_storage *storage
); void * librdf_storage_transaction_get_handle (librdf_storage *storage
); int librdf_storage_transaction_rollback (librdf_storage *storage
); int librdf_storage_transaction_start (librdf_storage *storage
); int librdf_storage_transaction_start_with_handle (librdf_storage *storage
,void *handle
); void librdf_storage_add_reference (librdf_storage *storage
); void librdf_storage_remove_reference (librdf_storage *storage
); typedef librdf_storage_instance; librdf_storage_instance librdf_storage_get_instance (librdf_storage *storage
); void librdf_storage_set_instance (librdf_storage *storage
,librdf_storage_instance instance
); librdf_world * librdf_storage_get_world (librdf_storage *storage
); void (*librdf_storage_module_register_function) (librdf_world *world
);
Provides classes to create triple stores to back the RDF graph interface (librdf_model). Most of the methods are for implementing the RDF model API and have the same name.
#define LIBRDF_STORAGE_INTERFACE_VERSION LIBRDF_STORAGE_MAX_INTERFACE_VERSION
Default librdf storage module interface version.
#define LIBRDF_STORAGE_MAX_INTERFACE_VERSION 1
Newest supported librdf storage module interface version.
#define LIBRDF_STORAGE_MIN_INTERFACE_VERSION 1
Oldest support librdf storage module interface version.
typedef struct librdf_storage_factory_s librdf_storage_factory;
A Storage Factory
int librdf_storage_register_factory (librdf_world *world
,const char *name
,const char *label
,void (*factory) (librdf_storage_factory*)
);
Register a storage factory.
Registration will fail if any of the parameters or NULL, if the factory API version is out of the known range or if out of memory.
|
redland world object |
|
the storage factory name |
|
the storage factory label |
|
pointer to function to call to register the factory |
Returns : |
non-0 on failure |
int librdf_storage_enumerate (librdf_world *world
,const unsigned int counter
,const char **name
,const char **label
);
Get information on storages.
|
redland world object |
|
index into the list of storages |
|
pointer to store the name of the storage (or NULL) |
|
pointer to store syntax readable label (or NULL) |
Returns : |
non 0 on failure of if counter is out of range |
librdf_storage * librdf_new_storage (librdf_world *world
,const char *storage_name
,const char *name
,const char *options_string
);
Constructor - create a new librdf_storage object.
The options are encoded as described in librdf_hash_from_string()
and can be NULL if none are required.
|
redland world object |
|
the storage factory name |
|
an identifier for the storage |
|
options to initialise storage |
Returns : |
a new librdf_storage object or NULL on failure |
librdf_storage * librdf_new_storage_with_options (librdf_world *world
,const char *storage_name
,const char *name
,librdf_hash *options
);
Constructor - create a new librdf_storage object.
The options can be NULL if none are required.
|
redland world object |
|
the storage factory name |
|
an identifier for the storage |
|
librdf_hash of options to use |
Returns : |
a new librdf_storage object or NULL on failure |
librdf_storage * librdf_new_storage_from_storage (librdf_storage *old_storage
);
Copy constructor - create a new librdf_storage object from an existing one
Should create a new storage in the same context as the existing one as appropriate for the storage. For example, in a RDBMS storage it would be a new database, or in on disk it would be a new set of files. This will mean automatically generating a new identifier for the storage, maybe based on the existing storage identifier.
|
the existing storage librdf_storage to use |
Returns : |
a new librdf_storage object or NULL on failure |
librdf_storage * librdf_new_storage_from_factory (librdf_world *world
,librdf_storage_factory *factory
,const char *name
,librdf_hash *options
);
Constructor - create a new librdf_storage object.
If the options are present, they become owned by the storage and should no longer be used.
|
redland world object |
|
the factory to use to construct the storage |
|
name to use for storage |
|
librdf_hash of options to initialise storage |
Returns : |
a new librdf_storage object or NULL on failure |
void librdf_free_storage (librdf_storage *storage
);
Destructor - destroy a librdf_storage object.
|
librdf_storage object |
int librdf_storage_open (librdf_storage *storage
,librdf_model *model
);
Start a model / storage association.
This is ended with librdf_storage_close()
|
librdf_storage object |
|
model stored |
Returns : |
non 0 on failure |
int librdf_storage_close (librdf_storage *storage
);
End a model / storage association.
|
librdf_storage object |
Returns : |
non 0 on failure |
int librdf_storage_size (librdf_storage *storage
);
Get the number of statements stored.
|
librdf_storage object |
Returns : |
The number of statements or < 0 if cannot be determined |
int librdf_storage_add_statement (librdf_storage *storage
,librdf_statement *statement
);
Add a statement to a storage.
The passed-in statement is copied when added to the store, not shared with the store.
If the statement already exists in the store, it is not added unless Redland contexts are being used.
Enforces that the statement is legal for RDF - URI or blank subject, URI predicate and URI or blank or literal object (i.e. anything).
|
librdf_storage object |
|
librdf_statement statement to add |
Returns : |
non 0 on failure, <0 on error, >0 if statement was illegal |
int librdf_storage_add_statements (librdf_storage *storage
,librdf_stream *statement_stream
);
Add a stream of statements to the storage.
If any of the statements already exists in the store, they are not added unless Redland contexts are being used.
|
librdf_storage object |
|
librdf_stream of statements |
Returns : |
non 0 on failure |
int librdf_storage_remove_statement (librdf_storage *storage
,librdf_statement *statement
);
Remove a statement from the storage.
|
librdf_storage object |
|
librdf_statement statement to remove |
Returns : |
non 0 on failure |
int librdf_storage_contains_statement (librdf_storage *storage
,librdf_statement *statement
);
Test if a given statement is present in the storage.
|
librdf_storage object |
|
librdf_statement statement to check |
Returns : |
non 0 if the storage contains the statement (>0 if illegal statement) |
librdf_stream * librdf_storage_serialise (librdf_storage *storage
);
Serialise the storage as a librdf_stream of statemetns.
|
librdf_storage object |
Returns : |
librdf_stream of statements or NULL on failure |
librdf_stream * librdf_storage_find_statements (librdf_storage *storage
,librdf_statement *statement
);
Search the storage for matching statements.
Searches the storage for a (partial) statement as described in
librdf_statement_match()
and returns a librdf_stream of
matching librdf_statement objects.
|
librdf_storage object |
|
librdf_statement partial statement to find |
Returns : |
librdf_stream of matching statements (may be empty) or NULL on failure |
librdf_stream * librdf_storage_find_statements_with_options (librdf_storage *storage
,librdf_statement *statement
,librdf_node *context_node
,librdf_hash *options
);
Search the storage for matching statements with match options.
Searches the storage for a (partial) statement as described in
librdf_statement_match()
and returns a librdf_stream of
matching librdf_statement objects.
If options is given then the match is made according to the given options. If options is NULL, this is equivalent to librdf_storage_find_statements_in_context.
|
librdf_storage object |
|
librdf_statement partial statement to find |
|
librdf_node context node or NULL. |
|
librdf_hash of matching options or NULL |
Returns : |
librdf_stream of matching statements (may be empty) or NULL on failure |
librdf_iterator * librdf_storage_get_sources (librdf_storage *storage
,librdf_node *arc
,librdf_node *target
);
Return the sources (subjects) of arc in an RDF graph given arc (predicate) and target (object).
Searches the storage for arcs matching the given arc and target and returns a list of the source librdf_node objects as an iterator
|
librdf_storage object |
|
librdf_node arc |
|
librdf_node target |
Returns : |
librdf_iterator of librdf_node objects (may be empty) or NULL on failure |
librdf_iterator * librdf_storage_get_arcs (librdf_storage *storage
,librdf_node *source
,librdf_node *target
);
Return the arcs (predicates) of an arc in an RDF graph given source (subject) and target (object).
Searches the storage for arcs matching the given source and target and returns a list of the arc librdf_node objects as an iterator
|
librdf_storage object |
|
librdf_node source |
|
librdf_node target |
Returns : |
librdf_iterator of librdf_node objects (may be empty) or NULL on failure |
librdf_iterator * librdf_storage_get_targets (librdf_storage *storage
,librdf_node *source
,librdf_node *arc
);
Return the targets (objects) of an arc in an RDF graph given source (subject) and arc (predicate).
Searches the storage for targets matching the given source and arc and returns a list of the source librdf_node objects as an iterator
|
librdf_storage object |
|
librdf_node source |
|
librdf_node arc |
Returns : |
librdf_iterator of librdf_node objects (may be empty) or NULL on failure |
librdf_iterator * librdf_storage_get_arcs_in (librdf_storage *storage
,librdf_node *node
);
Return the properties pointing to the given resource.
|
librdf_storage object |
|
librdf_node resource node |
Returns : |
librdf_iterator of librdf_node objects (may be empty) or NULL on failure |
librdf_iterator * librdf_storage_get_arcs_out (librdf_storage *storage
,librdf_node *node
);
Return the properties pointing from the given resource.
|
librdf_storage object |
|
librdf_node resource node |
Returns : |
librdf_iterator of librdf_node objects (may be empty) or NULL on failure |
int librdf_storage_has_arc_in (librdf_storage *storage
,librdf_node *node
,librdf_node *property
);
Check if a node has a given property pointing to it.
|
librdf_storage object |
|
librdf_node resource node |
|
librdf_node property node |
Returns : |
non 0 if arc property does point to the resource node |
int librdf_storage_has_arc_out (librdf_storage *storage
,librdf_node *node
,librdf_node *property
);
Check if a node has a given property pointing from it.
|
librdf_storage object |
|
librdf_node resource node |
|
librdf_node property node |
Returns : |
non 0 if arc property does point from the resource node |
int librdf_storage_context_add_statement (librdf_storage *storage
,librdf_node *context
,librdf_statement *statement
);
Add a statement to a storage in a context.
If context
is NULL, this is equivalent to librdf_storage_add_statement
|
librdf_storage object |
|
librdf_node context node |
|
librdf_statement statement to add |
Returns : |
non 0 on failure |
int librdf_storage_context_add_statements (librdf_storage *storage
,librdf_node *context
,librdf_stream *stream
);
Add statements to a storage with a context.
If context
is NULL, this is equivalent to librdf_storage_add_statements
|
librdf_storage object |
|
librdf_node context |
|
librdf_stream stream object |
Returns : |
Non 0 on failure |
int librdf_storage_context_remove_statement (librdf_storage *storage
,librdf_node *context
,librdf_statement *statement
);
Remove a statement from a storage in a context.
If context
is NULL, this is equivalent to librdf_storage_remove_statement
|
librdf_storage object |
|
librdf_node context node |
|
librdf_statement statement to remove |
Returns : |
non 0 on failure |
int librdf_storage_context_remove_statements (librdf_storage *storage
,librdf_node *context
);
Remove statements from a storage with the given context.
|
librdf_storage object |
|
librdf_uri context |
Returns : |
Non 0 on failure |
librdf_stream * librdf_storage_context_as_stream (librdf_storage *storage
,librdf_node *context
);
List all statements in a storage context.
|
librdf_storage object |
|
librdf_node context node |
Returns : |
librdf_stream of statements or NULL on failure or context is empty |
librdf_stream * librdf_storage_context_serialise (librdf_storage *storage
,librdf_node *context
);
List all statements in a storage context (DEPRECATED).
DEPRECATED to reduce confusion with the librdf_serializer class. Please use librdf_storage_context_as_stream.
|
librdf_storage object |
|
librdf_node context node |
Returns : |
librdf_stream of statements or NULL on failure or context is empty |
int librdf_storage_supports_query (librdf_storage *storage
,librdf_query *query
);
Check if a storage system supports a query language.
|
librdf_storage object |
|
librdf_query query object |
Returns : |
non-0 if the query is supported. |
librdf_query_results * librdf_storage_query_execute (librdf_storage *storage
,librdf_query *query
);
Run the given query against the storage.
Not implemented.
|
librdf_storage object |
|
librdf_query query object |
Returns : |
librdf_query_results or NULL on failure |
int librdf_storage_sync (librdf_storage *storage
);
Synchronise the storage to the storage implementation.
|
librdf_storage object |
Returns : |
non-0 on failure |
librdf_stream * librdf_storage_find_statements_in_context (librdf_storage *storage
,librdf_statement *statement
,librdf_node *context_node
);
Search the storage for matching statements in a given context.
Searches the storage for a (partial) statement as described in
librdf_statement_match()
in the given context and returns a
librdf_stream of matching librdf_statement objects. If
context is NULL, this is equivalent to librdf_storage_find_statements.
|
librdf_storage object |
|
librdf_statement partial statement to find |
|
context librdf_node (or NULL) |
Returns : |
librdf_stream of matching statements (may be empty) or NULL on failure |
librdf_iterator * librdf_storage_get_contexts (librdf_storage *storage
);
Return the list of contexts in the store.
Returns an iterator of librdf_node context nodes for each context in the store.
|
librdf_storage object |
Returns : |
librdf_iterator of context nodes or NULL on failure or if contexts are not supported |
librdf_node * librdf_storage_get_feature (librdf_storage *storage
,librdf_uri *feature
);
Get the value of a storage feature.
|
librdf_storage object |
|
librdf_uri feature property |
Returns : |
new librdf_node feature value or NULL if no such feature exists or the value is empty. |
int librdf_storage_set_feature (librdf_storage *storage
,librdf_uri *feature
,librdf_node *value
);
Set the value of a storage feature.
|
librdf_storage object |
|
librdf_uri feature property |
|
librdf_node feature property value |
Returns : |
non 0 on failure (negative if no such feature) |
int librdf_storage_transaction_commit (librdf_storage *storage
);
Commit a transaction.
|
the storage object |
Returns : |
non-0 on failure |
void * librdf_storage_transaction_get_handle
(librdf_storage *storage
);
Get the current transaction handle.
|
the storage object |
Returns : |
non-0 on failure |
int librdf_storage_transaction_rollback (librdf_storage *storage
);
Rollback a transaction.
|
the storage object |
Returns : |
non-0 on failure |
int librdf_storage_transaction_start (librdf_storage *storage
);
Start a transaction
|
the storage object |
Returns : |
non-0 on failure |
int librdf_storage_transaction_start_with_handle (librdf_storage *storage
,void *handle
);
Start a transaction using an existing external transaction object.
|
the storage object |
|
the transaction object |
Returns : |
non-0 on failure |
void librdf_storage_add_reference (librdf_storage *storage
);
Increment storage reference count by one.
This function is intended to be internal to librdf storage modules.
|
librdf_storage object |
void librdf_storage_remove_reference (librdf_storage *storage
);
Decrement storage reference count by one and free the storage if reference count becomes zero.
This function is intended to be internal to librdf storage modules.
|
librdf_storage object |
typedef void* librdf_storage_instance;
Opaque storage module instance handle.
For use with a storage module and the librdf_storage_get_instance()
and librdf_storage_set_instance()
functions. The instance handle
should be set in the librdf_storage_factory init factory method.
librdf_storage_instance librdf_storage_get_instance (librdf_storage *storage
);
Get instance data for this storage
|
librdf_storage object |
Returns : |
opaque instance data for this storage |
void librdf_storage_set_instance (librdf_storage *storage
,librdf_storage_instance instance
);
Set the instance data for this storage.
This function is intended for use by the 'init' method of storage
implementations to set instance data which can be retrived with
librdf_storage_get_instance()
and used in other methods of that
storage.
The instance is completely opaque to librdf, including allocation and deallocation.
|
librdf_storage object |
|
Opaque instance pointer |
librdf_world * librdf_storage_get_world (librdf_storage *storage
);
Get the librdf_world object associated with this storage.
|
librdf_storage object |
Returns : |
world object for this storage |
void (*librdf_storage_module_register_function)
(librdf_world *world
);
Registration function for storage
A storage module must define and export a function named of this type with function name "librdf_storage_module_register_factory".
This function will be called by Redland and must call
librdf_storage_register_factory()
to register whatever storage
backends are implemented in the module.
|
world object |