Hi Huib Yes, I considered, my note about using JAX RX was in fact about using REST. I wonder - is there any way, how to optimize collection by REST after new document is submited? I assume, that for proper performance of XQuery is optimize needed, as adding new document probably breaks previous indices.
And with REST, as I understand, there is no state. Taking into consideration, that to optimize a collection, it has to be first opened, then in next command it can be optimized, there is a problem, that the optimize command has no context of opened collection, as there is no state preserved. Or do I understand something wrong?
I know, I can use PythonAPI for opening the database and running optimize, but I would prefer to keep my solution as simple as possible and using 2 API (REST + Python API) is more complex then one (just REST).
Jan
2011/2/11 Huib Verweij hhv@home.nl
Hi Jan,
Have you considered using the REST interface? Using curl it's easy to add documents from anywhere in the world, post queries and delete documents when you're done. Just start bin/basexrest and you're ready to go.
Huib.
Verstuurd vanaf mijn iPad
Op 11 feb. 2011 om 22:36 heeft Jan Vlčinský (CAD) < jan.vlcinsky@cad-programs.com> het volgende geschreven:
Hi Andreas Thanks for the trick. However, it does not make me very happy, this time.
*A little background* I started running XQuery document in production, but it consumes really a lot of CPU. My need is to take current version of some XML from Internet, run it through XQuery and post the resulting XML out. Currently, I do not store the source document in BaseX but pass it as text parameter into the query, taking advantage of query.bind() in my Python API
declare variable $xmlString external := '<TICELogicalModel/>'; (: just setting some initial content:) let $xml := util:eval($xmlString) (: let $xml := . uncomment this line to test on locally stored XML doc :) let $colOpenLR := collection('__PreLocSet_OpenLRBinaryv3_30610_10_3') let $colPreLoc := collection("__PredefinedLocationSet_30610_02")
let $creationTime := $xml//PayloadPublication/data(@publicationTime) return <Traffic xmlns:openlr=" <http://www.openlr.org/openlr> http://www.openlr.org/openlr" xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance> http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="TTTSP.xsd"> <creationTime>{$creationTime}</creationTime> <provider>CE-Traffic</provider>{
for $rec in $xml//ElaboratedRecord let $recId := $rec/data(@id) ...and go on with actual transformation producing one resulting element for each $rec
My processing can be probably strongly optimized, as there is probably no use of indices for transformed document. The transformation runs few seconds on localy BaseX stored document, but tenth of seconds in real life scenario with XML being passed as value of variable (source XML has about 8 MB in size and there similar processes running concurrently, 2nd and 3rd are a bit smaller, referenced collections have about 10 MB and 800 kB of size).
So I decided to test programatically adding the source XML into BaseX and run the XQuery then.
However, current Python API allows adding documents only by use of add command, and it is forcing me to play special tricks with quotes and double quotes as you advised. There are two reasons, I do not like this - having to fiddle with files, in memory, where I prefer to behave as efficiently as possible; and my previous code was adding documents with older BaseX without troubles, so I have not so strong trust in stability of this solution for future versions.
*Searching for possible solutions*
Ideal solution would be, *if Python API would offer some ADD method*. Or do something like bind() to pass the value in. Using command add with local file is not always an option for me. Another alternative is *using JaxRX* http://docs.basex.org/wiki/JaxRxPOSTAdd http://docs.basex.org/wiki/JaxRxPOSTAdd, but this adds extra layer and some complexity of basic infrastructure and I have to use API to run optimize command anyway.
And there could be extra *trick with modification of already inserted node
- use API to call simple ADD command with the simplest content
ADD as mydoc <root/> 2. Use API, to run XQuery, taking advantage of BIND method passing name of document to modify and real content of the XML. The XQuery would modify the pre-created document to get real full content. 3. Use API to run OPTIMIZE command 4. Finally, process my XQuery, which produces my real result
*Summary of options*
- Use Python API, calling execute with ADD command, properly quoting
inserted XML string 2. Use JAX RX to add the document over wire. Rest of activities done by Python API 3. Use/modify/create/get modified Python API, which offers ADD method for document 4. Use Python API with trick, modifying simple XML doc by XQuery having bound full document into variable
Any comments are welcome.
Jan
2011/2/10 Andreas Weiler < andreas.weiler@uni-konstanz.de andreas.weiler@uni-konstanz.de>
Hi Jan,
use quotes around your xml snippet:
add as doc1 "<root att='att'/>"
Kind regards, Andreas
Am 10.02.2011 um 15:18 schrieb Jan Vlčinský (CAD):
Hi I need to insert documents into BaseX collection. As data are not always available directly as files and as sometime my server is remote to me, I need a method to add documents remotely.
With older BaseX (I think BaseX 6.4) I was able to use add commend in the way
add as doc1 <root/>
This works now. But I am unable to insert anything, what has any attribute in this manner
add as doc1 <root att="att"/>
This keeps complaining and prints back help on the console.
I am using basexclient.bat and Python API.
What am I doing wrong?
Thanks for any advice.
Jan
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.deBaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.deBaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
-- *Ing. Jan Vlčinský* CAD programy Slunečnicová 338/3, 734 01 Karviná Ráj, Czech Republic tel: +420-597 602 024; mob: +420-608 979 040 skype: janvlcinsky; GoogleTalk: jan.vlcinsky@gmail.com jan.vlcinsky@gmail.com http://cz.linkedin.com/in/vlcinskyhttp://cz.linkedin.com/in/vlcinsky
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk