[tracker/quad] Quadstore work in progress
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/quad] Quadstore work in progress
- Date: Fri, 17 Jul 2009 12:40:00 +0000 (UTC)
commit d064f1dc08544078682ff3c8ebd4e20d18026b1b
Author: Jürg Billeter <j bitron ch>
Date: Fri Jul 17 13:39:03 2009 +0200
Quadstore work in progress
src/libtracker-data/tracker-data-manager.c | 37 ++++++++++-------
src/libtracker-data/tracker-data-query.c | 20 +++++-----
src/libtracker-data/tracker-data-update.c | 53 +++++++++++++++++++------
src/libtracker-data/tracker-sparql-query.vala | 22 +++++-----
src/libtracker-db/tracker-db-manager.c | 35 +++++++++++++++-
src/libtracker-db/tracker-db-manager.h | 1 +
6 files changed, 118 insertions(+), 50 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index a0c26df..7021601 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -289,9 +289,9 @@ class_add_super_classes_from_db (TrackerDBInterface *iface, TrackerClass *class)
TrackerDBResultSet *result_set;
stmt = tracker_db_interface_create_statement (iface,
- "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdfs:subClassOf\") "
+ "SELECT (SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"rdfs:subClassOf\") "
"FROM \"rdfs:Class_rdfs:subClassOf\" "
- "WHERE ID = (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?)");
+ "WHERE ID = (SELECT ID FROM \"quad\".\"uri\" WHERE Uri = ?)");
tracker_db_statement_bind_text (stmt, 0, tracker_class_get_uri (class));
result_set = tracker_db_statement_execute (stmt, NULL);
g_object_unref (stmt);
@@ -323,9 +323,9 @@ property_add_super_properties_from_db (TrackerDBInterface *iface, TrackerPropert
TrackerDBResultSet *result_set;
stmt = tracker_db_interface_create_statement (iface,
- "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdfs:subPropertyOf\") "
+ "SELECT (SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"rdfs:subPropertyOf\") "
"FROM \"rdf:Property_rdfs:subPropertyOf\" "
- "WHERE ID = (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?)");
+ "WHERE ID = (SELECT ID FROM \"quad\".\"uri\" WHERE Uri = ?)");
tracker_db_statement_bind_text (stmt, 0, tracker_property_get_uri (property));
result_set = tracker_db_statement_execute (stmt, NULL);
g_object_unref (stmt);
@@ -357,7 +357,7 @@ db_get_static_data (TrackerDBInterface *iface)
TrackerDBResultSet *result_set;
stmt = tracker_db_interface_create_statement (iface,
- "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"tracker:Namespace\".ID), "
+ "SELECT (SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"tracker:Namespace\".ID), "
"\"tracker:prefix\" "
"FROM \"tracker:Namespace\"");
result_set = tracker_db_statement_execute (stmt, NULL);
@@ -392,7 +392,7 @@ db_get_static_data (TrackerDBInterface *iface)
}
stmt = tracker_db_interface_create_statement (iface,
- "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdfs:Class\".ID) "
+ "SELECT (SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"rdfs:Class\".ID) "
"FROM \"rdfs:Class\" ORDER BY ID");
result_set = tracker_db_statement_execute (stmt, NULL);
g_object_unref (stmt);
@@ -424,9 +424,9 @@ db_get_static_data (TrackerDBInterface *iface)
}
stmt = tracker_db_interface_create_statement (iface,
- "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdf:Property\".ID), "
- "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdfs:domain\"), "
- "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdfs:range\"), "
+ "SELECT (SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"rdf:Property\".ID), "
+ "(SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"rdfs:domain\"), "
+ "(SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"rdfs:range\"), "
"\"nrl:maxCardinality\", "
"\"tracker:indexed\", "
"\"tracker:fulltextIndexed\", "
@@ -615,7 +615,7 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
sql = g_string_new ("");
g_string_append_printf (sql, "CREATE TABLE \"%s\" (ID INTEGER NOT NULL PRIMARY KEY", service_name);
if (main_class) {
- g_string_append (sql, ", Uri TEXT NOT NULL, Available INTEGER NOT NULL");
+ g_string_append (sql, ", Available INTEGER NOT NULL");
}
properties = tracker_ontology_get_properties ();
@@ -640,9 +640,6 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
}
}
- if (main_class) {
- g_string_append (sql, ", UNIQUE (Uri)");
- }
g_string_append (sql, ")");
tracker_db_interface_execute_query (iface, NULL, "%s", sql->str);
@@ -675,10 +672,16 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
TrackerDBStatement *stmt;
stmt = tracker_db_interface_create_statement (iface,
- "INSERT OR IGNORE INTO \"rdfs:Resource\" (ID, Uri, \"tracker:modified\") VALUES (?, ?, ?)");
+ "INSERT OR IGNORE INTO \"quad\".\"uri\" (ID, Uri) VALUES (?, ?)");
tracker_db_statement_bind_int (stmt, 0, ++(*max_id));
tracker_db_statement_bind_text (stmt, 1, tracker_class_get_uri (service));
- tracker_db_statement_bind_int64 (stmt, 2, (gint64) time (NULL));
+ tracker_db_statement_execute (stmt, NULL);
+ g_object_unref (stmt);
+
+ stmt = tracker_db_interface_create_statement (iface,
+ "INSERT OR IGNORE INTO \"rdfs:Resource\" (ID, \"tracker:modified\") VALUES (?, ?)");
+ tracker_db_statement_bind_int (stmt, 0, max_id);
+ tracker_db_statement_bind_int64 (stmt, 1, (gint64) time (NULL));
tracker_db_statement_execute (stmt, NULL);
g_object_unref (stmt);
}
@@ -826,6 +829,10 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
tracker_data_begin_transaction ();
+ tracker_db_interface_execute_query (iface, NULL, "CREATE TABLE quad.uri (ID INTEGER NOT NULL PRIMARY KEY, Uri TEXT NOT NULL, UNIQUE (Uri))");
+ tracker_db_interface_execute_query (iface, NULL, "CREATE TABLE quad.statement_uri (subject INTEGER NOT NULL, predicate INTEGER NOT NULL, object INTEGER NOT NULL, graph INTEGER)");
+ tracker_db_interface_execute_query (iface, NULL, "CREATE TABLE quad.statement_string (subject INTEGER NOT NULL, predicate INTEGER NOT NULL, object TEXT NOT NULL, graph INTEGER)");
+
/* create tables */
for (cl = classes; *cl; cl++) {
create_decomposed_metadata_tables (iface, *cl, &max_id);
diff --git a/src/libtracker-data/tracker-data-query.c b/src/libtracker-data/tracker-data-query.c
index 8adcc78..b84732b 100644
--- a/src/libtracker-data/tracker-data-query.c
+++ b/src/libtracker-data/tracker-data-query.c
@@ -76,7 +76,7 @@ tracker_data_query_all_metadata (guint32 resource_id)
properties = tracker_ontology_get_properties ();
- stmt = tracker_db_interface_create_statement (iface, "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
+ stmt = tracker_db_interface_create_statement (iface, "SELECT (SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
tracker_db_statement_bind_int (stmt, 0, resource_id);
result_set = tracker_db_statement_execute (stmt, NULL);
g_object_unref (stmt);
@@ -106,7 +106,7 @@ tracker_data_query_all_metadata (guint32 resource_id)
first = FALSE;
if (tracker_property_get_data_type (*property) == TRACKER_PROPERTY_TYPE_RESOURCE) {
- g_string_append_printf (sql, "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"%s\")", tracker_property_get_name (*property));
+ g_string_append_printf (sql, "(SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"%s\")", tracker_property_get_name (*property));
} else {
g_string_append_printf (sql, "\"%s\"", tracker_property_get_name (*property));
}
@@ -154,7 +154,7 @@ tracker_data_query_all_metadata (guint32 resource_id)
sql = g_string_new ("SELECT ");
if (tracker_property_get_data_type (*property) == TRACKER_PROPERTY_TYPE_RESOURCE) {
- g_string_append_printf (sql, "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"%s\")", tracker_property_get_name (*property));
+ g_string_append_printf (sql, "(SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"%s\")", tracker_property_get_name (*property));
} else {
g_string_append_printf (sql, "\"%s\"", tracker_property_get_name (*property));
}
@@ -219,10 +219,10 @@ tracker_data_query_rdf_type (guint32 id)
iface = tracker_db_manager_get_db_interface ();
stmt = tracker_db_interface_create_statement (iface,
- "SELECT \"rdfs:Resource\".\"Uri\" "
+ "SELECT \"quad\".\"uri\".\"Uri\" "
"FROM \"rdfs:Resource_rdf:type\" "
- "INNER JOIN \"rdfs:Resource\" "
- "ON \"rdfs:Resource_rdf:type\".\"rdf:type\" = \"rdfs:Resource\".\"ID\" "
+ "INNER JOIN \"quad\".\"uri\" "
+ "ON \"rdfs:Resource_rdf:type\".\"rdf:type\" = \"quad\".\"uri\".\"ID\" "
"WHERE \"rdfs:Resource_rdf:type\".\"ID\" = ?");
tracker_db_statement_bind_int (stmt, 0, id);
@@ -262,7 +262,7 @@ tracker_data_query_resource_id (const gchar *uri)
iface = tracker_db_manager_get_db_interface ();
stmt = tracker_db_interface_create_statement (iface,
- "SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?");
+ "SELECT ID FROM \"quad\".\"uri\" WHERE Uri = ?");
tracker_db_statement_bind_text (stmt, 0, uri);
result_set = tracker_db_statement_execute (stmt, NULL);
g_object_unref (stmt);
@@ -290,7 +290,7 @@ tracker_data_query_resource_exists (const gchar *uri,
iface = tracker_db_manager_get_db_interface ();
stmt = tracker_db_interface_create_statement (iface,
- "SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?");
+ "SELECT ID FROM \"quad\".\"uri\" WHERE Uri = ?");
tracker_db_statement_bind_text (stmt, 0, uri);
result_set = tracker_db_statement_execute (stmt, NULL);
g_object_unref (stmt);
@@ -358,7 +358,7 @@ tracker_data_query_property_value (const gchar *subject,
/* retrieve object URI */
stmt = tracker_db_interface_create_statement (iface,
"SELECT "
- "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"%s\") "
+ "(SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"%s\") "
"FROM \"%s\" WHERE ID = ?",
field_name, table_name);
} else {
@@ -421,7 +421,7 @@ tracker_data_query_property_values (const gchar *subject,
/* retrieve object URI */
stmt = tracker_db_interface_create_statement (iface,
"SELECT "
- "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"%s\") "
+ "(SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"%s\") "
"FROM \"%s\" WHERE ID = ?",
field_name, table_name);
} else {
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 0cad1bb..4a2e6e2 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -132,7 +132,7 @@ tracker_data_update_get_new_service_id (TrackerDBInterface *iface)
temp_iface = tracker_db_manager_get_db_interface ();
result_set = tracker_db_interface_execute_query (temp_iface, NULL,
- "SELECT MAX(ID) AS A FROM \"rdfs:Resource\"");
+ "SELECT MAX(ID) AS A FROM \"quad\".\"uri\"");
if (result_set) {
GValue val = {0, };
@@ -253,10 +253,16 @@ ensure_resource_id (const gchar *uri)
iface = tracker_db_manager_get_db_interface ();
id = tracker_data_update_get_new_service_id (common);
- stmt = tracker_db_interface_create_statement (iface, "INSERT INTO \"rdfs:Resource\" (ID, Uri, \"tracker:modified\", Available) VALUES (?, ?, ?, 1)");
+
+ stmt = tracker_db_interface_create_statement (iface, "INSERT INTO \"quad\".\"uri\" (ID, Uri) VALUES (?, ?)");
tracker_db_statement_bind_int (stmt, 0, id);
tracker_db_statement_bind_text (stmt, 1, uri);
- tracker_db_statement_bind_int64 (stmt, 2, (gint64) time(NULL));
+ tracker_db_statement_execute (stmt, NULL);
+ g_object_unref (stmt);
+
+ stmt = tracker_db_interface_create_statement (iface, "INSERT INTO \"rdfs:Resource\" (ID, \"tracker:modified\", Available) VALUES (?, ?, 1)");
+ tracker_db_statement_bind_int (stmt, 0, id);
+ tracker_db_statement_bind_int64 (stmt, 1, (gint64) time(NULL));
tracker_db_statement_execute (stmt, NULL);
g_object_unref (stmt);
@@ -312,7 +318,7 @@ tracker_data_update_buffer_flush (void)
if (update_buffer.new_subject != NULL) {
// change uri of resource
stmt = tracker_db_interface_create_statement (iface,
- "UPDATE \"rdfs:Resource\" SET Uri = ? WHERE ID = ?");
+ "UPDATE \"quad\".\"uri\" SET Uri = ? WHERE ID = ?");
tracker_db_statement_bind_text (stmt, 0, update_buffer.new_subject);
tracker_db_statement_bind_int (stmt, 1, update_buffer.id);
tracker_db_statement_execute (stmt, NULL);
@@ -387,6 +393,7 @@ tracker_data_update_buffer_flush (void)
* replace should happen as a delete/insert pair */
for (i = 0; i < table->properties->len; i++) {
property = &g_array_index (table->properties, TrackerDataUpdateBufferProperty, i);
+
if (property->fts) {
if (fts_index > 0) {
g_string_append (fts_sql, ", ");
@@ -546,7 +553,7 @@ tracker_data_update_resource_uri (const gchar *old_uri,
/* update URI in rdfs:Resource table */
- stmt = tracker_db_interface_create_statement (iface, "UPDATE \"rdfs:Resource\" SET Uri = ? WHERE ID = ?");
+ stmt = tracker_db_interface_create_statement (iface, "UPDATE \"quad\".\"uri\" SET Uri = ? WHERE ID = ?");
tracker_db_statement_bind_text (stmt, 0, new_uri);
tracker_db_statement_bind_int (stmt, 1, resource_id);
tracker_db_statement_execute (stmt, NULL);
@@ -749,9 +756,9 @@ tracker_data_delete_statement (const gchar *subject,
/* retrieve all subclasses we need to remove from the subject
* before we can remove the class specified as object of the statement */
stmt = tracker_db_interface_create_statement (iface,
- "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdfs:Class_rdfs:subClassOf\".ID) "
+ "SELECT (SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"rdfs:Class_rdfs:subClassOf\".ID) "
"FROM \"rdfs:Resource_rdf:type\" INNER JOIN \"rdfs:Class_rdfs:subClassOf\" ON (\"rdf:type\" = \"rdfs:Class_rdfs:subClassOf\".ID) "
- "WHERE \"rdfs:Resource_rdf:type\".ID = ? AND \"rdfs:subClassOf\" = (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?)");
+ "WHERE \"rdfs:Resource_rdf:type\".ID = ? AND \"rdfs:subClassOf\" = (SELECT ID FROM \"quad\".\"uri\" WHERE Uri = ?)");
tracker_db_statement_bind_int (stmt, 0, subject_id);
tracker_db_statement_bind_text (stmt, 1, object);
result_set = tracker_db_statement_execute (stmt, NULL);
@@ -937,6 +944,8 @@ tracker_data_insert_statement_with_uri (const gchar *subject,
{
TrackerClass *class;
TrackerProperty *property;
+ TrackerDBInterface *iface;
+ TrackerDBStatement *stmt;
g_return_if_fail (subject != NULL);
g_return_if_fail (predicate != NULL);
@@ -1011,6 +1020,15 @@ tracker_data_insert_statement_with_uri (const gchar *subject,
cache_set_metadata_decomposed (property, object);
}
+ iface = tracker_db_manager_get_db_interface ();
+ stmt = tracker_db_interface_create_statement (iface,
+ "INSERT OR IGNORE INTO \"quad\".\"statement_uri\" (subject, predicate, object) VALUES (?, (SELECT ID FROM \"quad\".\"uri\" WHERE Uri = ?), (SELECT ID FROM \"quad\".\"uri\" WHERE Uri = ?))");
+ tracker_db_statement_bind_int (stmt, 0, update_buffer.id);
+ tracker_db_statement_bind_text (stmt, 1, predicate);
+ tracker_db_statement_bind_text (stmt, 2, object);
+ tracker_db_statement_execute (stmt, NULL);
+ g_object_unref (stmt);
+
if (insert_callback) {
insert_callback (subject, predicate, object, update_buffer.types, insert_data);
}
@@ -1025,6 +1043,8 @@ tracker_data_insert_statement_with_string (const gchar *subject,
GError **error)
{
TrackerProperty *property;
+ TrackerDBInterface *iface;
+ TrackerDBStatement *stmt;
g_return_if_fail (subject != NULL);
g_return_if_fail (predicate != NULL);
@@ -1051,6 +1071,15 @@ tracker_data_insert_statement_with_string (const gchar *subject,
/* add value to metadata database */
cache_set_metadata_decomposed (property, object);
+ iface = tracker_db_manager_get_db_interface ();
+ stmt = tracker_db_interface_create_statement (iface,
+ "INSERT OR IGNORE INTO \"quad\".\"statement_string\" (subject, predicate, object) VALUES (?, (SELECT ID FROM \"quad\".\"uri\" WHERE Uri = ?), ?)");
+ tracker_db_statement_bind_int (stmt, 0, update_buffer.id);
+ tracker_db_statement_bind_text (stmt, 1, predicate);
+ tracker_db_statement_bind_text (stmt, 2, object);
+ tracker_db_statement_execute (stmt, NULL);
+ g_object_unref (stmt);
+
if (insert_callback) {
insert_callback (subject, predicate, object, update_buffer.types, insert_data);
}
@@ -1075,7 +1104,7 @@ db_set_volume_available (const gchar *uri,
iface = tracker_db_manager_get_db_interface ();
- stmt = tracker_db_interface_create_statement (iface, "UPDATE \"rdfs:Resource\" SET Available = ? WHERE ID IN (SELECT ID FROM \"nie:DataObject\" WHERE \"nie:dataSource\" IN (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?))");
+ stmt = tracker_db_interface_create_statement (iface, "UPDATE \"rdfs:Resource\" SET Available = ? WHERE ID IN (SELECT ID FROM \"nie:DataObject\" WHERE \"nie:dataSource\" IN (SELECT ID FROM \"quad\".\"uri\" WHERE Uri = ?))");
tracker_db_statement_bind_int (stmt, 0, available ? 1 : 0);
tracker_db_statement_bind_text (stmt, 1, uri);
tracker_db_statement_execute (stmt, NULL);
@@ -1246,7 +1275,7 @@ tracker_data_update_disable_all_volumes (void)
"WHERE ID IN ("
"SELECT ID FROM \"nie:DataObject\" "
"WHERE \"nie:dataSource\" IN ("
- "SELECT ID FROM \"rdfs:Resource\" WHERE Uri != ?"
+ "SELECT ID FROM \"quad\".\"uri\" WHERE Uri != ?"
")"
")");
tracker_db_statement_bind_text (stmt, 0, TRACKER_NON_REMOVABLE_MEDIA_DATASOURCE_URN);
@@ -1358,7 +1387,7 @@ tracker_data_delete_resource_description (const gchar *uri)
properties = tracker_ontology_get_properties ();
- stmt = tracker_db_interface_create_statement (iface, "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
+ stmt = tracker_db_interface_create_statement (iface, "SELECT (SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
tracker_db_statement_bind_int (stmt, 0, resource_id);
result_set = tracker_db_statement_execute (stmt, NULL);
g_object_unref (stmt);
@@ -1392,7 +1421,7 @@ tracker_data_delete_resource_description (const gchar *uri)
first = FALSE;
if (tracker_property_get_data_type (*property) == TRACKER_PROPERTY_TYPE_RESOURCE) {
- g_string_append_printf (sql, "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"%s\")", tracker_property_get_name (*property));
+ g_string_append_printf (sql, "(SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"%s\")", tracker_property_get_name (*property));
} else {
g_string_append_printf (sql, "\"%s\"", tracker_property_get_name (*property));
}
@@ -1446,7 +1475,7 @@ tracker_data_delete_resource_description (const gchar *uri)
sql = g_string_new ("SELECT ");
if (tracker_property_get_data_type (*property) == TRACKER_PROPERTY_TYPE_RESOURCE) {
- g_string_append_printf (sql, "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"%s\")", tracker_property_get_name (*property));
+ g_string_append_printf (sql, "(SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"%s\")", tracker_property_get_name (*property));
} else {
g_string_append_printf (sql, "\"%s\"", tracker_property_get_name (*property));
}
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 52ef798..479380d 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -76,7 +76,7 @@ public class Tracker.SparqlQuery : Object {
DBResultSet result_set = null;
if (subject_id > 0) {
var iface = DBManager.get_db_interface ();
- var stmt = iface.create_statement ("SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
+ var stmt = iface.create_statement ("SELECT (SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
stmt.bind_int (0, subject_id);
result_set = stmt.execute ();
}
@@ -95,10 +95,10 @@ public class Tracker.SparqlQuery : Object {
} else {
sql.append (" UNION ");
}
- sql.append_printf ("SELECT ID, (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = '%s') AS \"predicate\", ", prop.uri);
+ sql.append_printf ("SELECT ID, (SELECT ID FROM \"quad\".\"uri\" WHERE Uri = '%s') AS \"predicate\", ", prop.uri);
if (prop.data_type == PropertyType.RESOURCE) {
- sql.append_printf ("(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"%s\")", prop.name);
+ sql.append_printf ("(SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"%s\")", prop.name);
} else if (prop.data_type == PropertyType.INTEGER || prop.data_type == PropertyType.DOUBLE) {
sql.append_printf ("CAST (\"%s\" AS TEXT)", prop.name);
} else if (prop.data_type == PropertyType.BOOLEAN) {
@@ -129,7 +129,7 @@ public class Tracker.SparqlQuery : Object {
var object_id = Data.query_resource_id (object);
var iface = DBManager.get_db_interface ();
- var stmt = iface.create_statement ("SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
+ var stmt = iface.create_statement ("SELECT (SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
stmt.bind_int (0, object_id);
var result_set = stmt.execute ();
@@ -147,10 +147,10 @@ public class Tracker.SparqlQuery : Object {
} else {
sql.append (" UNION ");
}
- sql.append_printf ("SELECT ID, (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = '%s') AS \"predicate\", ", prop.uri);
+ sql.append_printf ("SELECT ID, (SELECT ID FROM \"quad\".\"uri\" WHERE Uri = '%s') AS \"predicate\", ", prop.uri);
if (prop.data_type == PropertyType.RESOURCE) {
- sql.append_printf ("(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"%s\")", prop.name);
+ sql.append_printf ("(SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"%s\")", prop.name);
} else if (prop.data_type == PropertyType.INTEGER || prop.data_type == PropertyType.DOUBLE) {
sql.append_printf ("CAST (\"%s\" AS TEXT)", prop.name);
} else if (prop.data_type == PropertyType.BOOLEAN) {
@@ -184,10 +184,10 @@ public class Tracker.SparqlQuery : Object {
} else {
sql.append (" UNION ");
}
- sql.append_printf ("SELECT ID, (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = '%s') AS \"predicate\", ", prop.uri);
+ sql.append_printf ("SELECT ID, (SELECT ID FROM \"quad\".\"uri\" WHERE Uri = '%s') AS \"predicate\", ", prop.uri);
if (prop.data_type == PropertyType.RESOURCE) {
- sql.append_printf ("(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"%s\")", prop.name);
+ sql.append_printf ("(SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"%s\")", prop.name);
} else if (prop.data_type == PropertyType.INTEGER || prop.data_type == PropertyType.DOUBLE) {
sql.append_printf ("CAST (\"%s\" AS TEXT)", prop.name);
} else if (prop.data_type == PropertyType.BOOLEAN) {
@@ -373,7 +373,7 @@ public class Tracker.SparqlQuery : Object {
var binding = var_map.lookup (variable_name);
assert (binding != null);
if (binding.is_uri) {
- return "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"%s_u\")".printf (variable_name);
+ return "(SELECT Uri FROM \"quad\".\"uri\" WHERE ID = \"%s_u\")".printf (variable_name);
} else if (binding.is_boolean) {
return "(CASE \"%s_u\" WHEN 1 THEN 'true' WHEN 0 THEN 'false' ELSE NULL END)".printf (variable_name);
} else if (binding.is_datetime) {
@@ -712,7 +712,7 @@ public class Tracker.SparqlQuery : Object {
} else {
pattern_sql.append (" = ");
if (binding.is_uri) {
- pattern_sql.append ("(SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?)");
+ pattern_sql.append ("(SELECT ID FROM \"quad\".\"uri\" WHERE Uri = ?)");
} else {
pattern_sql.append ("?");
}
@@ -1136,7 +1136,7 @@ public class Tracker.SparqlQuery : Object {
pattern_sql.append_printf ("\"%s_u\"", variable_name);
} else {
if (expr.literal.type == Rasqal.Literal.Type.URI) {
- pattern_sql.append ("(SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?)");
+ pattern_sql.append ("(SELECT ID FROM \"quad\".\"uri\" WHERE Uri = ?)");
} else {
pattern_sql.append ("?");
}
diff --git a/src/libtracker-db/tracker-db-manager.c b/src/libtracker-db/tracker-db-manager.c
index edda959..e3fc313 100644
--- a/src/libtracker-db/tracker-db-manager.c
+++ b/src/libtracker-db/tracker-db-manager.c
@@ -110,6 +110,18 @@ static TrackerDBDefinition dbs[] = {
FALSE,
FALSE,
0 },
+ { TRACKER_DB_QUAD,
+ TRACKER_DB_LOCATION_USER_DATA_DIR,
+ NULL,
+ "quad.db",
+ "quad",
+ NULL,
+ 2000,
+ TRACKER_DB_PAGE_SIZE_DONT_SET,
+ FALSE,
+ FALSE,
+ FALSE,
+ 0 },
{ TRACKER_DB_METADATA,
TRACKER_DB_LOCATION_DATA_DIR,
NULL,
@@ -821,6 +833,17 @@ db_interface_get_contents (void)
}
+static TrackerDBInterface *
+db_interface_get_quad (void)
+{
+ TrackerDBInterface *iface;
+ gboolean create;
+
+ iface = db_interface_get (TRACKER_DB_QUAD, &create);
+
+ return iface;
+}
+
static TrackerDBInterface *
db_interface_get_metadata (void)
@@ -843,6 +866,9 @@ db_interface_create (TrackerDB db)
case TRACKER_DB_COMMON:
return db_interface_get_common ();
+ case TRACKER_DB_QUAD:
+ return db_interface_get_quad ();
+
case TRACKER_DB_METADATA:
return db_interface_get_metadata ();
@@ -966,6 +992,9 @@ tracker_db_get_type (void)
{ TRACKER_DB_COMMON,
"TRACKER_DB_COMMON",
"common" },
+ { TRACKER_DB_QUAD,
+ "TRACKER_DB_QUAD",
+ "quad" },
{ TRACKER_DB_METADATA,
"TRACKER_DB_METADATA",
"metadata" },
@@ -1205,16 +1234,18 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
initialized = TRUE;
if (flags & TRACKER_DB_MANAGER_READONLY) {
- resources_iface = tracker_db_manager_get_db_interfaces_ro (4,
+ resources_iface = tracker_db_manager_get_db_interfaces_ro (5,
TRACKER_DB_METADATA,
TRACKER_DB_FULLTEXT,
TRACKER_DB_CONTENTS,
+ TRACKER_DB_QUAD,
TRACKER_DB_COMMON);
} else {
- resources_iface = tracker_db_manager_get_db_interfaces (4,
+ resources_iface = tracker_db_manager_get_db_interfaces (5,
TRACKER_DB_METADATA,
TRACKER_DB_FULLTEXT,
TRACKER_DB_CONTENTS,
+ TRACKER_DB_QUAD,
TRACKER_DB_COMMON);
}
return TRUE;
diff --git a/src/libtracker-db/tracker-db-manager.h b/src/libtracker-db/tracker-db-manager.h
index 2b639ae..2590f64 100644
--- a/src/libtracker-db/tracker-db-manager.h
+++ b/src/libtracker-db/tracker-db-manager.h
@@ -32,6 +32,7 @@ G_BEGIN_DECLS
typedef enum {
TRACKER_DB_UNKNOWN,
TRACKER_DB_COMMON,
+ TRACKER_DB_QUAD,
TRACKER_DB_METADATA,
TRACKER_DB_CONTENTS,
TRACKER_DB_FULLTEXT,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]