From 78ee0c8a610187b149191e175013481a268dec6a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 4 Jun 2009 00:20:19 +0000 Subject: 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 --- src/world.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'src/world.c') 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); -- cgit v1.2.1