From: Stefano C. <cam...@ya...> - 2004-09-17 07:13:38
|
Laurian Gridinoc wrote: >On Wed, 15 Sep 2004 07:16:15 +0200, Paolo Castagna > > >>>>... we need an unique identifier for a statement >>>>in the index and for reification. >>>> <subject uri> <predicate uri> <object uri> >>>>Is there any problem if we use SHA1? >>>> sha1(<subject uri> <predicate uri> <object uri>)? >>>> >>>> >>>Very OK with me, I mentioned it in a discussion about reification: >>>http://lists.w3.org/Archives/Public/www-rdf-interest/2004Aug/0194.html >>>but no one argued back with me :( >>> >>> >>So, it's decided: we'll use SHA1 ;) >>I don't know how to tell in english... but: >>"chi tace acconsente" :) >> >> Ok, I have added the follow methods in MetaManager class: /* *@return the Triple ID * */ public static String getStmtId(final URI subject, final URI predicate, final URI object) throws NoSuchAlgorithmException { final String tbDigest = subject.toString()+predicate.toString()+object.toString(); byte[] digest = getDigest(tbDigest.getBytes()); Base64 base = new Base64(); byte[] encoded = base.encode(digest); final String result = new String(encoded); return result; } private static byte[] getDigest(byte[] buffer) throws NoSuchAlgorithmException { MessageDigest md5 = MessageDigest.getInstance("SHA1"); md5.update(buffer); return md5.digest(); } So, we can calculate the ID of triples (tbd: literals ). I'd like thinking at the ID as a URI of the triple. In fact, this is what happen during the reification. In Platypus, when we create a refication we put the new resource (the refified triple) in the namespcace "reifications", so the URI is something like this: reifications:_086yskjf (reification+_CRC(s,p,o)). I consider this " reifications:_086yskjf" as the ID/URI of the triple, isn't it? If a triple isn't reificated? what is it's ID/URI? May be: namespace:_SHA1 (subjURI, predicateURI, objectURI/Literal) Or directly SHA1 (subjURI, predicateURI, objectURI/Literal) In my opinion we are creating a new RDF resource naming it, so it could be in a fixed "installation depending" namespace. I need this ID, becouse I use it to "add" or "remove" triples from the Lucene index. Any ideas? |