Bugs item #2141000, was opened at 2008-10-01 22:05
Message generated for change (Settings changed) made by stmane
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=2141000&group_id=56967

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: XML
Group: Pathfinder 0.24
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Loredana Afanasiev (lafanasi)
Assigned to: Nobody/Anonymous (nobody)
>Summary: XQ: fn:collection() broken in MPS back-end

Initial Comment:
Hi,

Deleting a document from a collection seems to be buggy, see the following 
sequence of steps:

bulk-loading a collection
xquery$
for $d in doc("/scratch/PolitiekeData/MotiesTweedeKamer/xq/dir.xml")//doc
return
pf:add-doc(fn:concat("/scratch/PolitiekeData/MotiesTweedeKamer/XML/",$d/@name), 
fn:string($d/@name), "MotiesTweedeKamer", 0)

adding a document to the collection, by mistake
xquery$
pf:add-doc(fn:concat("/scratch/PolitiekeData/MotiesTweedeKamer/","allemoties.xml"),"MotiesTweedeKamer")

noticed the mistake
xquery$ pf:collections()
<collection updatable="false" size="217 MiB" 
numDocs="27947">MotiesTweedeKamer</collection>,

delete the document from the collection
xquery$ pf:del-doc("MotiesTweedeKamer")

now, is this doc deleted? The number of document in the collection indeed 
decreased with one, but then the size of the collection is the same.
xquery$ pf:collections()
<collection updatable="false" size="217 MiB" 
numDocs="27946">MotiesTweedeKamer</collection>,

lets' test it again. oops.
xquery$ fn:count(fn:collection("MotiesTweedeKamer")//document)
55892

:) I am sure there is a quicker way to getting this bug.

cheers,
l.

----------------------------------------------------------------------

Comment By: Stefan Manegold (stmane)
Date: 2008-10-03 19:01

Message:
While fn:collection() in the (old and deprecated) MPS back-end indeed seems
to be broken (fn:collection() is not yet available in the new ALGebra
back-end),
pf:collection() appears to be working correctly in both the MPS and the
ALGebra back-end:

$ mclient -lx -s'pf:collections()'

$ cat /tmp/x.xml 
<a>
<b/>
</a>
$ mclient -lx -s'pf:add-doc("/tmp/x.xml","MyDoc1","MyColl")'
$ mclient -lx -s'pf:collections()'
<collection updatable="false" size="100 KiB"
numDocs="1">MyColl</collection>
$ mclient -lx -s'pf:add-doc("/tmp/x.xml","MyDoc2","MyColl")'
$ mclient -lx -s'pf:collections()'
<collection updatable="false" size="100 KiB"
numDocs="2">MyColl</collection>
$ mclient -lx -s'pf:add-doc("/tmp/x.xml","MyDoc3","MyColl")'
$ mclient -lx -s'pf:collections()'
<collection updatable="false" size="100 KiB"
numDocs="3">MyColl</collection>
$ mclient -lx -g -s'fn:count(fn:collection("MyColl")//a)'
3
$ mclient -lx -g -s'fn:count(fn:collection("MyColl")//b)'
3
$ mclient -lx -g -s'fn:count(pf:collection("MyColl")//a)'
3
$ mclient -lx -g -s'fn:count(pf:collection("MyColl")//b)'
3
$ mclient -lx -s'fn:count(pf:collection("MyColl")//a)'
3
$ mclient -lx -s'fn:count(pf:collection("MyColl")//b)'
3
$ mclient -lx -s'pf:del-doc("MyDoc3")'
$ mclient -lx -s'pf:collections()'
<collection updatable="false" size="100 KiB"
numDocs="2">MyColl</collection>
$ mclient -lx -g -s'fn:count(fn:collection("MyColl")//a)'
3 ! WRONG -> Should be 2 !
$ mclient -lx -g -s'fn:count(fn:collection("MyColl")//b)'
3 ! WRONG -> Should be 2 !
$ mclient -lx -s'fn:count(pf:collection("MyColl")//a)'
2
$ mclient -lx -s'fn:count(pf:collection("MyColl")//b)'
2
$ mclient -lx -g -s'fn:count(pf:collection("MyColl")//a)'
2
$ mclient -lx -g -s'fn:count(pf:collection("MyColl")//b)'
2

Hence, for now, simply use pf:collection().
For details, see also
http://monetdb.cwi.nl/projects/monetdb/Development/Releases/Version4.24/index.html#XQuery
http://monetdb.cwi.nl/projects/monetdb/XQuery/QuickTour/DOCMGT/index.html#openall
http://monetdb.cwi.nl/projects/monetdb/XQuery/Documentation/Separate-Documents-vs-Document-Collections.html
http://monetdb.cwi.nl/projects/monetdb/XQuery/Documentation/Metadata-Functions.html
http://monetdb.cwi.nl/projects/monetdb/XQuery/Documentation/The-Collection-Node.html


----------------------------------------------------------------------

Comment By: Loredana Afanasiev (lafanasi)
Date: 2008-10-03 18:41

Message:
Hi Stefan,

thanks for the reply.

> Not knowing your collection I cannot interpret what you last query is
supposed to show --- I only see that 55892 = 2 * 27946 ...
Right. My collection contains 27946 documents each having "document" as
root. I created one big document that lists all these docs under a new root
"moties" and added it to the initial collection. Now there are 55892
"document" elements in the collection. Then I delete the big document.
There should be 27946 "document" elements in the collection, but there are
still 55892 "document" elements. 

> Moreover which version of MonetDB/XQuery (resp. Pathfinder) are you
using? You did not indicate that via the "Group:" selection in the header
of this
bug report.
done.





----------------------------------------------------------------------

Comment By: Loredana Afanasiev (lafanasi)
Date: 2008-10-02 12:37

Message:
Forgot to say:
# Installation packadge: MonetDB-Aug2008-SuperBall.tar.bz2


----------------------------------------------------------------------

Comment By: Stefan Manegold (stmane)
Date: 2008-10-01 22:56

Message:
Loredana,

the (physical) size of the collection remains the same after deleting a
single document as it would be too expensive to "clean-up" the physical
storage, which would require copying the whole collection.

The deleted document should (logically) not be visible anymore, though,
and that seems to be correct given the values of the "numDoc" attribute in
the results of both pf:collections() calls.

Not knowing your collection I cannot interpret what you last query is
supposed to show --- I only see that 55892 = 2 * 27946 ...

Moreover which version of MonetDB/XQuery (resp. Pathfinder) are you
using?
You did not indicate that via the "Group:" selection in the header of this
bug report.

Stefan


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=2141000&group_id=56967

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Monetdb-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-bugs

Reply via email to