summaryrefslogtreecommitdiffstats
path: root/src/world.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-06-04 00:20:19 +0000
committerDavid Robillard <d@drobilla.net>2009-06-04 00:20:19 +0000
commit78ee0c8a610187b149191e175013481a268dec6a (patch)
tree88d996220350c9dfc5c5153a115cafb00efb3857 /src/world.c
parent27751d02ec3acf33169e2f670c39edc95f02cd8d (diff)
downloadlilv-78ee0c8a610187b149191e175013481a268dec6a.tar.gz
lilv-78ee0c8a610187b149191e175013481a268dec6a.tar.bz2
lilv-78ee0c8a610187b149191e175013481a268dec6a.zip
Centralize storage creation and only create SPO and OPS indices (TODO: Add API for user to select, predicate-variable queries will be slow this way).
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2090 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/world.c b/src/world.c
index bd38fd2..f0022ed 100644
--- a/src/world.c
+++ b/src/world.c
@@ -42,14 +42,7 @@ slv2_world_new_internal(SLV2World world)
assert(world);
assert(world->world);
- world->storage = librdf_new_storage(world->world, "trees", NULL, NULL);
- if (!world->storage) {
- SLV2_WARN("Warning: Unable to create \"trees\" RDF storage.\n"
- "Performance can be improved by upgrading librdf.\n");
- world->storage = librdf_new_storage(world->world, "hashes", NULL,
- "hash-type='memory'");
- }
-
+ world->storage = slv2_world_new_storage(world);
if (!world->storage)
goto fail;
@@ -91,6 +84,28 @@ fail:
}
+/* private */
+librdf_storage*
+slv2_world_new_storage(SLV2World world)
+{
+ static bool warned = false;
+ librdf_hash* options = librdf_new_hash_from_string(world->world, NULL,
+ "index-spo='yes',index-ops='yes'");
+ librdf_storage* ret = librdf_new_storage_with_options(
+ world->world, "trees", NULL, options);
+ if (!ret) {
+ warned = true;
+ SLV2_WARN("Warning: Unable to create \"trees\" RDF storage.\n"
+ "Performance can be improved by upgrading librdf.\n");
+ ret = librdf_new_storage(world->world, "hashes", NULL,
+ "hash-type='memory'");
+ }
+
+ librdf_free_hash(options);
+ return ret;
+}
+
+
SLV2World
slv2_world_new()
{
@@ -185,9 +200,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
bundle_uri->val.uri_val, (const unsigned char*)"manifest.ttl");
/* Parse the manifest into a temporary model */
- librdf_storage* manifest_storage = librdf_new_storage(world->world, "trees", NULL, NULL);
- if (manifest_storage == NULL)
- manifest_storage = librdf_new_storage(world->world, "memory", NULL, NULL);
+ librdf_storage* manifest_storage = slv2_world_new_storage(world);
librdf_model* manifest_model = librdf_new_model(world->world,
manifest_storage, NULL);