[tracker/miner-web] Facebook miner : avoid repeated calls to SparqlUpdate
- From: Adrien Bustany <abustany src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/miner-web] Facebook miner : avoid repeated calls to SparqlUpdate
- Date: Thu, 5 Nov 2009 14:16:41 +0000 (UTC)
commit 0160d57665392cae504c408da574e4d5eb38a85c
Author: Adrien Bustany <madcat mymadcat com>
Date: Thu Nov 5 11:14:48 2009 -0300
Facebook miner : avoid repeated calls to SparqlUpdate
src/tracker-miner-facebook/facebook.vala | 52 +++++++++++++++++------------
1 files changed, 30 insertions(+), 22 deletions(-)
---
diff --git a/src/tracker-miner-facebook/facebook.vala b/src/tracker-miner-facebook/facebook.vala
index 549bf41..ea138fb 100644
--- a/src/tracker-miner-facebook/facebook.vala
+++ b/src/tracker-miner-facebook/facebook.vala
@@ -339,17 +339,19 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
string name = current_album.find ("name").content;
if (name != null) {
message ("Will index album %s", name);
- tracker.SparqlUpdate ("insert {<%s> rdfs:label \"%s\"}".printf (urn, escape_string (name)));
+ tracker.BatchSparqlUpdate ("insert {<%s> rdfs:label \"%s\"}".printf (urn, escape_string (name)));
}
string comment = current_album.find ("description").content;
if (comment != null) {
- tracker.SparqlUpdate ("insert {<%s> rdfs:comment \"%s\"}".printf (urn, escape_string (comment)));
+ tracker.BatchSparqlUpdate ("insert {<%s> rdfs:comment \"%s\"}".printf (urn, escape_string (comment)));
}
- tracker.SparqlUpdate ("insert {<%s> nie:contentLastModified '%s'}".printf (urn, timestamp_to_iso8601 (current_album.find ("modified").content)));
-
- tracker.SparqlUpdate ("insert {<%s> nco:creator <%s>}".printf (urn, friend_urn.lookup (current_album.find ("owner").content)));
+ tracker.BatchSparqlUpdate ("insert {<%s> nie:contentLastModified '%s' ; nco:creator <%s>"
+ .printf(urn,
+ timestamp_to_iso8601 (current_album.find ("modified").content),
+ friend_urn.lookup (current_album.find ("owner").content)));
+ tracker.BatchCommit ();
} catch (Error e) {
critical ("Error while contacting Trakcer : %s", e.message);
//error (new MinerWebError.TRACKER (e.message));
@@ -380,20 +382,22 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
try {
string caption = current_photo.find ("caption").content;
if (caption != null) {
- tracker.SparqlUpdate ("insert {<%s> rdfs:label \"%s\"}".printf (urn, escape_string (caption)));
+ tracker.BatchSparqlUpdate ("insert {<%s> rdfs:label \"%s\"}".printf (urn, escape_string (caption)));
}
string date = timestamp_to_iso8601 (current_photo.find ("created").content);
- tracker.SparqlUpdate ("insert {<%s> nie:contentCreated '%s'}".printf (urn, date));
+ tracker.BatchSparqlUpdate ("insert {<%s> nie:contentCreated '%s'}".printf (urn, date));
if (album_urn.lookup (current_photo.find ("aid").content) != null) {
- tracker.SparqlUpdate ("insert {<%s> a nfo:MediaFileListEntry}".printf (urn));
- tracker.SparqlUpdate ("insert {<%s> nfo:mediaListEntry <%s>}".printf (album_urn.lookup (current_photo.find ("aid").content), urn));
+ tracker.BatchSparqlUpdate ("insert {<%s> a nfo:MediaFileListEntry . <%s> nfo:mediaListEntry <%1$s>}"
+ .printf (urn,
+ album_urn.lookup (current_photo.find ("aid").content)));
} else {
warning ("Unknown album for picture %s", uri);
}
- tracker.SparqlUpdate ("insert {<%s> nco:creator <%s>}".printf (urn, friend_urn.lookup (current_photo.find ("owner").content)));
+ tracker.BatchSparqlUpdate ("insert {<%s> nco:creator <%s>}".printf (urn, friend_urn.lookup (current_photo.find ("owner").content)));
+ tracker.BatchCommit ();
} catch (Error e) {
critical ("Error while contacting Tracker : %s", e.message);
//error (new MinerWebError.TRACKER (e.message));
@@ -466,13 +470,14 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
string uri = current.find ("permalink").content;
string urn = get_resource ("mfo:FeedMessage", uri);
- tracker.SparqlUpdate ("insert {<%s> nmo:from <%s>}".printf (urn, authors.lookup (current.find ("actor_id").content)));
-
string date = timestamp_to_iso8601 (current.find ("created_time").content);
- tracker.SparqlUpdate ("insert {<%s> nmo:receivedDate \"%s\"}".printf (urn, date));
+ tracker.BatchSparqlUpdate ("insert {<%s> nmo:from <%s> ; nmo:receivedDate \"%s\"}"
+ .printf (urn,
+ authors.lookup (current.find ("actor_id").content),
+ date));
if (current.find ("message").content != null) {
- tracker.SparqlUpdate ("insert {<%s> nmo:plainTextMessageContent \"%s\"}".printf (urn, escape_string (current.find ("message").content)));
+ tracker.BatchSparqlUpdate ("insert {<%s> nmo:plainTextMessageContent \"%s\"}".printf (urn, escape_string (current.find ("message").content)));
}
// Deal with any attachment we might have
@@ -520,9 +525,10 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
var picture_uri = current_photo.find ("src_big").content;
var enclosure_urn = get_resource ("nmm:Photo", picture_uri);
- tracker.SparqlUpdate ("insert {<%s> a mfo:Enclosure}".printf (enclosure_urn));
- tracker.SparqlUpdate ("insert {<%s> mfo:remoteLink <%s>}".printf (enclosure_urn, picture_uri));
- tracker.SparqlUpdate ("insert {<%s> mfo:enclosureList <%s>}".printf (urn, enclosure_urn));
+ tracker.BatchSparqlUpdate ("insert {<%s> a mfo:Enclosure ; mfo:remoteLink <%s> . <%s> mfo:enclosureList <%1$s>}"
+ .printf (enclosure_urn,
+ picture_uri,
+ urn));
// The rest of the photo indexing will be done by pull_photos_cb
@@ -530,6 +536,8 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
}
}
}
+
+ tracker.BatchCommit ();
} catch (Error e) {
critical ("Error while inserting data into Tracker : %s", e.message);
//error (new MinerWebError.TRACKER (e.message));
@@ -615,9 +623,10 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
switch (results.length) {
case 0:
string urn = "urn:uuid:%s".printf (uuid_generate_string ());
- tracker.SparqlUpdate ("insert {<%s> a %s}".printf (urn, klass));
- tracker.SparqlUpdate ("insert {<%s> a nfo:RemoteDataObject}".printf (stored_as));
- tracker.SparqlUpdate ("insert {<%s> nie:isStoredAs <%s>}".printf (urn, stored_as));
+ tracker.SparqlUpdate ("insert {<%s> a nfo:RemoteDataObject . <%s> a %s ; nie:isStoredAs <%1$s>}"
+ .printf (stored_as,
+ urn,
+ klass));
return urn;
case 1:
return results[0][0];
@@ -643,8 +652,7 @@ public class FacebookMiner : Tracker.Miner, Tracker.MinerWeb {
switch (results.length) {
case 0:
string urn = "urn:uuid:%s".printf (uuid_generate_string ());
- tracker.SparqlUpdate ("insert {<%s> a nco:Contact}".printf (urn));
- tracker.SparqlUpdate ("insert {<%s> nco:fullname \"%s\"}".printf (urn, escaped_fullname));
+ tracker.SparqlUpdate ("insert {<%s> a nco:Contact ; nco:fullname \"%s\"}".printf (urn, escaped_fullname));
return urn;
case 1:
return results[0][0];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]