Apparant discrepancy in collection and db:list
Hello all, Thanks for the wonderful support this group provides. Its great! With your help, I'm trying to make my way around the issues that I'm discovering, but unfortunately there still are some more issues. I noticed that collection() returns the nodes in the order in which they were added (which is good). However, db:list() returns them in alphabetical order. Any reason why that is the case? Can I somehow get the list of resources in the order in which they were added? Thanks, Anupam P.S. Jens, thanks for your suggestion, I'll try that if all else fails. Christian, I'll try the server feature in the latest source and send feedback a little later. Thanks for your help and suggestions.
Hi Anupam,
I noticed that collection() returns the nodes in the order in which they were added (which is good). However, db:list() returns them in alphabetical order. Any reason why that is the case?
please note that there's no guarantee that collection() or db:open() will return all documents in the order they have originally been added to the database. Next, future version of BaseX will most probably outlaw the storage of documents with identical names [1], which is why I'd second Jens' proposal to assign different names to your documents. Christian [1] https://github.com/BaseXdb/basex/issues/429
Can I somehow get the list of resources in the order in which they were added?
Thanks, Anupam
P.S. Jens, thanks for your suggestion, I'll try that if all else fails. Christian, I'll try the server feature in the latest source and send feedback a little later. Thanks for your help and suggestions.
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hello Christian, It seems that db:list-details() shows the same "modified-date" attribute for all resources in a database which is same as the last-modified time of any of the paths. Example : db:list-details('project1') <resource raw="false" content-type="application/xml" modified-date="2012-06-03T12:14:06.154Z">RESULT/SOURCEID3/5/filename3</resource> <resource raw="false" content-type="application/xml" modified-date="2012-06-03T12:14:06.154Z">RESULT/SOURCEID1/1/filename1</resource> REPLACE RESULT/SOURCEID1/1/filename1 C:\sample1.xml db:list-details('project1') <resource raw="false" content-type="application/xml" modified-date="2012-06-03T12:34:10.051Z">RESULT/SOURCEID3/5/filename3</resource> <resource raw="false" content-type="application/xml" modified-date="2012-06-03T12:34:10.051Z">RESULT/SOURCEID1/1/filename1</resource> Note that even though RESULT/SOURCEID3/5/filename3 was not replaced, its modified date is same as the file that was replaced. I assume that's a bug. I checked in the issue database, but didn't find any similar bug. Thanks, Anupam ________________________________ From: Christian Grün <christian.gruen@gmail.com> To: Anupam Bakshi <bakshia@yahoo.com> Cc: BaseX <basex-talk@mailman.uni-konstanz.de> Sent: Saturday, June 2, 2012 5:01 PM Subject: Re: [basex-talk] Apparant discrepancy in collection and db:list Hi Anupam,
I noticed that collection() returns the nodes in the order in which they were added (which is good). However, db:list() returns them in alphabetical order. Any reason why that is the case?
please note that there's no guarantee that collection() or db:open() will return all documents in the order they have originally been added to the database. Next, future version of BaseX will most probably outlaw the storage of documents with identical names [1], which is why I'd second Jens' proposal to assign different names to your documents. Christian [1] https://github.com/BaseXdb/basex/issues/429
Can I somehow get the list of resources in the order in which they were added?
Thanks, Anupam
P.S. Jens, thanks for your suggestion, I'll try that if all else fails. Christian, I'll try the server feature in the latest source and send feedback a little later. Thanks for your help and suggestions.
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hi Anupam,
It seems that db:list-details() shows the same "modified-date" attribute for all resources in a database which is same as the last-modified time of any of the paths.
this is because the modification time is currently not stored for each single resource. It may change in a future version (this could be aligned with the constraint that a document with a specific path can only be stored once). Christian
Hello, As a workaround, I'm storing the date in the path itself (4th token). I need to delete some paths based on a condition, however, nothing gets deleted. for $doc in collection('project1') return document-uri($doc) --------------------------------------------- project1/RESULT/SOURCEID2/1000/filename1 project1/RESULT/SOURCEID2/2000/filename1 project1/RESULT/SOURCEID3/3000/filename1 project1/RESULT/SOURCEID3/4000/filename2 project1/RESULT/SOURCEID3/5000/filename3 project1/RESULT/SOURCEID1/1000/filename1 --------------------------------------------- for $doc in collection('project1') let $arr := tokenize(document-uri($doc), '/') where xs:integer($arr[4]) <= 4000 return delete node $doc (: db:delete('project1', document-uri($doc)) :) -------------------------------------------- I tried both "delete node" and "db:delete" but none seem to delete the paths. Can someone give me some pointer about what I might be doing wrong? Thanks, Anupam ________________________________ From: Christian Grün <christian.gruen@gmail.com> To: Anupam Bakshi <bakshia@yahoo.com> Cc: BaseX <basex-talk@mailman.uni-konstanz.de> Sent: Sunday, June 3, 2012 8:48 AM Subject: Re: [basex-talk] Apparant discrepancy in collection and db:list Hi Anupam,
It seems that db:list-details() shows the same "modified-date" attribute for all resources in a database which is same as the last-modified time of any of the paths.
this is because the modification time is currently not stored for each single resource. It may change in a future version (this could be aligned with the constraint that a document with a specific path can only be stored once). Christian
Hi Anupam, here is one way.. let $db := 'project1' for $doc in db:open($db) let $name := replace(document-uri($doc), '^.*?/', '') where xs:integer($arr[4]) <= 4000 return db:delete($db, $name) ..here is another.. for $path in db:list('project1')[tokenize(., '/')[4] <= 4000] return db:delete('project1', $path) Christian ___________________________ On Mon, Jun 4, 2012 at 10:37 AM, Anupam Bakshi <bakshia@yahoo.com> wrote:
Hello, As a workaround, I'm storing the date in the path itself (4th token). I need to delete some paths based on a condition, however, nothing gets deleted.
for $doc in collection('project1') return document-uri($doc) --------------------------------------------- project1/RESULT/SOURCEID2/1000/filename1 project1/RESULT/SOURCEID2/2000/filename1 project1/RESULT/SOURCEID3/3000/filename1 project1/RESULT/SOURCEID3/4000/filename2 project1/RESULT/SOURCEID3/5000/filename3 project1/RESULT/SOURCEID1/1000/filename1 --------------------------------------------- for $doc in collection('project1') let $arr := tokenize(document-uri($doc), '/') where xs:integer($arr[4]) <= 4000 return delete node $doc (: db:delete('project1', document-uri($doc)) :) --------------------------------------------
I tried both "delete node" and "db:delete" but none seem to delete the paths. Can someone give me some pointer about what I might be doing wrong?
Thanks, Anupam
________________________________ From: Christian Grün <christian.gruen@gmail.com> To: Anupam Bakshi <bakshia@yahoo.com> Cc: BaseX <basex-talk@mailman.uni-konstanz.de> Sent: Sunday, June 3, 2012 8:48 AM
Subject: Re: [basex-talk] Apparant discrepancy in collection and db:list
Hi Anupam,
It seems that db:list-details() shows the same "modified-date" attribute for all resources in a database which is same as the last-modified time of any of the paths.
this is because the modification time is currently not stored for each single resource. It may change in a future version (this could be aligned with the constraint that a document with a specific path can only be stored once).
Christian
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
participants (2)
-
Anupam Bakshi -
Christian Grün