Hey Christian<br><br>Sorry for not getting to it. I'm actually not exactly sure on how to go about it. My approach of using hashes is blatantly wrong and only covers my simplistic test case. The identification should obviously be done in the ResourceIdentifier and then allow the resource merger to merge them. But I'm not sure how I could do the identification.<br>
<br>I think I'll think about it and discuss it with Sebastian. The moment we figure out how to implement it, it shouldn't take more than a couple of hours to implement it (with tests). It would be a nice change than all this studying :/<br>
<br>Sorry about the delay.<br><br><div class="gmail_quote">On Mon, Oct 31, 2011 at 4:42 PM, Sebastian Trüg <span dir="ltr"><<a href="mailto:trueg@kde.org">trueg@kde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Christian,<br>
<br>
let's meet up this week to discuss the problem and hopefully fix it. So<br>
far I stayed clean of the storeResources code but with Vishesh not<br>
having much time I will dive into it.<br>
<br>
Cheers,<br>
<font color="#888888">Sebastian<br>
</font><div><div></div><div class="h5"><br>
On 10/31/2011 12:42 PM, Christian Mollekopf wrote:<br>
> Hey,<br>
><br>
> This issue starts to get pressing, a solution is needed for 4.8.<br>
> Currently the feeders are broken because of that issue.<br>
><br>
> The code in storeResources is beyond me and my attempts to fix it failed so<br>
> far. So if no one fixes it there I'll have to work around the issue in the<br>
> feeder code.<br>
><br>
> I don't mean to push anyone, I'd just like to know if somebody from the<br>
> nepomuk team (yes vishesh I'm looking at you ;-) is going to fix this, or if<br>
> I'm on my own. As said, I do understand if you currently lack the time to make<br>
> this happen, just tell me.<br>
><br>
> Thanks,<br>
> Christian<br>
><br>
> PS: I added the pastes before they are deleted from pastie<br>
><br>
> On Saturday, October 08, 2011 03:12:51 PM Christian Mollekopf wrote:<br>
>> Hi Vishesh,<br>
>><br>
>> The duplicates merging code doesn't cut it for the feeders yet.<br>
>> As far as I could track it down the problem is that I have hierarchies of<br>
>> resources which need to be merged together.<br>
>> I.e. I add a contact with it's email address several times to the graph. The<br>
>> email addresses are now correctly merged, but because the contacts had<br>
>> different email uris in the first hashing run (before they have been<br>
>> merged), the contacts remain duplicated.<br>
>><br>
>> Here is the test which currently fails:<br>
>> <a href="http://paste.kde.org/131371/" target="_blank">http://paste.kde.org/131371/</a><br>
><br>
> void DataManagementModelTest::testStoreResources_duplicates2()<br>
> {<br>
>     SimpleResource contact1;<br>
>     contact1.addType( NCO::Contact() );<br>
>     contact1.addProperty( NCO::fullname(), QLatin1String("Spiderman") );<br>
>     contact1.addProperty( NAO::prefLabel(), QLatin1String("test") );<br>
><br>
>     SimpleResource email1;<br>
>     email1.addType(NCO::EmailAddress());<br>
>     email1.addProperty(NCO::emailAddress(), QLatin1String("<a href="mailto:email@foo.com">email@foo.com</a>"));<br>
>     contact1.addProperty(NCO::hasEmailAddress(), email1.uri());<br>
><br>
>     SimpleResource contact2;<br>
>     contact2.addType( NCO::Contact() );<br>
>     contact2.addProperty( NCO::fullname(), QLatin1String("Spiderman") );<br>
>     contact2.addProperty( NAO::prefLabel(), QLatin1String("test") );<br>
><br>
>     SimpleResource email2;<br>
>     email2.addType(NCO::EmailAddress());<br>
>     email2.addProperty(NCO::emailAddress(), QLatin1String("<a href="mailto:email@foo.com">email@foo.com</a>"));<br>
>     contact2.addProperty(NCO::hasEmailAddress(), email2.uri());<br>
><br>
>     SimpleResourceGraph graph;<br>
>     graph << email1 << contact1 << email2 << contact2;<br>
><br>
>     m_dmModel->storeResources( graph, "appA" );<br>
>     QVERIFY(!m_dmModel->lastError());<br>
><br>
>     int contactCount = m_model->listStatements( Node(), RDF::type(),<br>
> NCO::Contact() ).allStatements().size();<br>
>     QCOMPARE( contactCount, 1 );<br>
><br>
>     int emailCount = m_model->listStatements( Node(), RDF::type(),<br>
> NCO::EmailAddress() ).allStatements().size();<br>
>     QCOMPARE( emailCount, 1 );<br>
><br>
>     QCOMPARE( m_model->listStatements( Node(), NCO::fullname(), Node()<br>
> ).allStatements().size(), 1 );<br>
>     QCOMPARE( m_model->listStatements( Node(), NAO::prefLabel(), Node()<br>
> ).allStatements().size(), 1 );<br>
><br>
>     QVERIFY(!haveTrailingGraphs());<br>
> }<br>
><br>
> add to qtest_dms.cpp:<br>
><br>
>     model.addStatement( NCO::emailAddress(), RDF::type(), RDF::Property(),<br>
> graph );<br>
>     model.addStatement( NCO::emailAddress(), RDFS::range(),<br>
> XMLSchema::string(), graph );<br>
>     model.addStatement( NCO::emailAddress(), RDFS::domain(),<br>
> NCO::EmailAddress(), graph );<br>
><br>
>     model.addStatement( NCO::hasEmailAddress(), RDF::type(), RDF::Property(),<br>
> graph );<br>
>     model.addStatement( NCO::hasEmailAddress(), RDFS::range(),<br>
> NCO::EmailAddress(), graph );<br>
>     model.addStatement( NCO::hasEmailAddress(), RDFS::domain(),<br>
> NCO::Contact(), graph );<br>
><br>
>     model.addStatement( NCO::EmailAddress(), RDF::type(), RDFS::Resource(),<br>
> graph );<br>
>     model.addStatement( NCO::EmailAddress(), RDF::type(), RDFS::Class(), graph<br>
> );<br>
>     model.addStatement( NCO::EmailAddress(), RDFS::subClassOf(),<br>
> NCO::ContactMedium(), graph );<br>
><br>
>><br>
>> And here's an excerpt of the debugging output which shows the problem in the<br>
>> actual feeders:<br>
>> <a href="http://paste.kde.org/131377/" target="_blank">http://paste.kde.org/131377/</a><br>
>><br>
><br>
> nepomukstorage(21806)/nepomuk (storage service)<br>
> Nepomuk::DataManagementModel::storeResources:<br>
> "_:zre""<<a href="http://www.semanticdesktop.org/ontologies/2007/08/15/nao#prefLabel" target="_blank">http://www.semanticdesktop.org/ontologies/2007/08/15/nao#prefLabel</a>>"""Sebastian<br>

> Trueg""<br>
> nepomukstorage(21806)/nepomuk (storage service)<br>
> Nepomuk::DataManagementModel::storeResources:<br>
> "_:zre""<<a href="http://www.w3.org/1999/02/22-rdf-syntax-" target="_blank">http://www.w3.org/1999/02/22-rdf-syntax-</a><br>
> ns#type>""<<a href="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#PersonContact" target="_blank">http://www.semanticdesktop.org/ontologies/2007/03/22/nco#PersonContact</a>>"<br>
> nepomukstorage(21806)/nepomuk (storage service)<br>
> Nepomuk::DataManagementModel::storeResources:<br>
> "_:zre""<<a href="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname" target="_blank">http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname</a>>"""Sebastian<br>

> Trueg"^^<<a href="http://www.w3.org/2001/XMLSchema#string" target="_blank">http://www.w3.org/2001/XMLSchema#string</a>>"<br>
> nepomukstorage(21806)/nepomuk (storage service)<br>
> Nepomuk::DataManagementModel::storeResources:<br>
> "_:zre""<<a href="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasEmailAddress" target="_blank">http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasEmailAddress</a>>""_:gqe"<br>

><br>
> nepomukstorage(21806)/nepomuk (storage service)<br>
> Nepomuk::DataManagementModel::storeResources:<br>
> "_:gqe""<<a href="http://www.w3.org/1999/02/22-rdf-syntax-" target="_blank">http://www.w3.org/1999/02/22-rdf-syntax-</a><br>
> ns#type>""<<a href="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#EmailAddress" target="_blank">http://www.semanticdesktop.org/ontologies/2007/03/22/nco#EmailAddress</a>>"<br>
> nepomukstorage(21806)/nepomuk (storage service)<br>
> Nepomuk::DataManagementModel::storeResources:<br>
> "_:gqe""<<a href="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#emailAddress" target="_blank">http://www.semanticdesktop.org/ontologies/2007/03/22/nco#emailAddress</a>>"""<a href="mailto:sebastian@trueg.de">sebastian@trueg.de</a>"^^<<a href="http://www.w3.org/2001/XMLSchema#string" target="_blank">http://www.w3.org/2001/XMLSchema#string</a>>"<br>

><br>
> nepomukstorage(21806)/nepomuk (storage service)<br>
> Nepomuk::DataManagementModel::storeResources:<br>
> "_:fqe""<<a href="http://www.semanticdesktop.org/ontologies/2007/08/15/nao#prefLabel" target="_blank">http://www.semanticdesktop.org/ontologies/2007/08/15/nao#prefLabel</a>>"""Sebastian<br>

> Trueg""<br>
> nepomukstorage(21806)/nepomuk (storage service)<br>
> Nepomuk::DataManagementModel::storeResources:<br>
> "_:fqe""<<a href="http://www.w3.org/1999/02/22-rdf-syntax-" target="_blank">http://www.w3.org/1999/02/22-rdf-syntax-</a><br>
> ns#type>""<<a href="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#PersonContact" target="_blank">http://www.semanticdesktop.org/ontologies/2007/03/22/nco#PersonContact</a>>"<br>
> nepomukstorage(21806)/nepomuk (storage service)<br>
> Nepomuk::DataManagementModel::storeResources:<br>
> "_:fqe""<<a href="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname" target="_blank">http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname</a>>"""Sebastian<br>

> Trueg"^^<<a href="http://www.w3.org/2001/XMLSchema#string" target="_blank">http://www.w3.org/2001/XMLSchema#string</a>>"<br>
> nepomukstorage(21806)/nepomuk (storage service)<br>
> Nepomuk::DataManagementModel::storeResources:<br>
> "_:fqe""<<a href="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasEmailAddress" target="_blank">http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasEmailAddress</a>>""_:gqe"<br>

><br>
> This is the error returned after the storeResourceCall:<br>
> nepomukstorage(21806)/nepomuk (storage service)<br>
> Nepomuk::DataManagementModel::storeResources: Setting error! "Invalid argument<br>
> (1)": "<a href="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname" target="_blank">http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname</a> has a<br>
> max cardinality of 1. Provided 2 values - "Sebastian<br>
> Trueg"^^<<a href="http://www.w3.org/2001/XMLSchema#string" target="_blank">http://www.w3.org/2001/XMLSchema#string</a>>, "Sebastian<br>
> Trueg"^^<<a href="http://www.w3.org/2001/XMLSchema#string" target="_blank">http://www.w3.org/2001/XMLSchema#string</a>>. Existing -  Affected<br>
> Resource: nepomuk:/res/75164167-3ae0-413f-a991-ed73a08ca9ec, new card: 2, old<br>
> card: 0"<br>
> "/opt/devel/KDE/bin/nepomukservicestub(21806)" Soprano: "Invalid argument<br>
> (1)": "<a href="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname" target="_blank">http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname</a> has a<br>
> max cardinality of 1. Provided 2 values - "Sebastian<br>
> Trueg"^^<<a href="http://www.w3.org/2001/XMLSchema#string" target="_blank">http://www.w3.org/2001/XMLSchema#string</a>>, "Sebastian<br>
> Trueg"^^<<a href="http://www.w3.org/2001/XMLSchema#string" target="_blank">http://www.w3.org/2001/XMLSchema#string</a>>. Existing -  Affected<br>
> Resource: nepomuk:/res/75164167-3ae0-413f-a991-ed73a08ca9ec, new card: 2, old<br>
> card: 0"<br>
><br>
>> As I understand your code you generate a hash of each resource to check if<br>
>> two are exactly the same. That probably works for most use-cases, but I'm<br>
>> not sure if it is the best solution.<br>
>> Given the problem above you'd have to rerun the hashing for the resources<br>
>> which were modified due to a merged resource, so that already complicates<br>
>> matters.<br>
>><br>
>> I thought maybe it would be possible to leave the merging up to the normal<br>
>> resource merger. This would have the effect that not only exactly equal<br>
>> resources would be merged, but all, just as the resource merger would<br>
>> normally merge them.<br>
>> If you think of the SimpleResourceGraph as a tree, a post-order traversal of<br>
>> the tree would allow you to store each resource one by one, starting from<br>
>> the leaves of the branch going to the root. The ResourceMerger would then<br>
>> automatically merge all resources as necessary.<br>
>><br>
>> Do you think that would be a viable option?<br>
>><br>
>> Cheers,<br>
>> Christian<br>
>><br>
>> _______________________________________________<br>
>> Nepomuk mailing list<br>
>> <a href="mailto:Nepomuk@kde.org">Nepomuk@kde.org</a><br>
>> <a href="https://mail.kde.org/mailman/listinfo/nepomuk" target="_blank">https://mail.kde.org/mailman/listinfo/nepomuk</a><br>
> _______________________________________________<br>
> Nepomuk mailing list<br>
> <a href="mailto:Nepomuk@kde.org">Nepomuk@kde.org</a><br>
> <a href="https://mail.kde.org/mailman/listinfo/nepomuk" target="_blank">https://mail.kde.org/mailman/listinfo/nepomuk</a><br>
><br>
_______________________________________________<br>
Nepomuk mailing list<br>
<a href="mailto:Nepomuk@kde.org">Nepomuk@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/nepomuk" target="_blank">https://mail.kde.org/mailman/listinfo/nepomuk</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><font color="#999999">Vishesh Handa</font><br>