Hello,
the Question is:
If I open a connection, send a query and close the connection: What do I get? Just a Copy of the Database which will be stored in the core/main memory or a reference to the DB? Here a Code Example:
let $cid := client:connect("localhost",port,"user","password")
let $query := 'collection("BIG-DB")/*:node'
let $req := client:query($cid,$query)
let $close := client:close($cid)
return $req
If it's just a copy in the main memory than (depends on the size oft he DB) it will cost a lot of performance. We have to use such a workaround with "client:connect" because if we try to access directly the DB more than once it will be blocked. So do you have any experience with the return value of "$req" ? Is it still a reference of the DB or is it stored in the main memory?
Regards,
Sumit Kapoor
------------------------------------------------------- >>> business. people. technology. <<< -------------------------------------------------------
adesso AG mit Sitz in Dortmund Vorstand: Michael Kenfenheuer (Vors.), Christoph Junge, Andreas Prenneis Vorsitzender des Aufsichtsrates: Prof. Dr. Volker Gruhn Amtsgericht Dortmund HRB 20663
I found it is much easier to use the REST API[0] to do anything with the DB data. HTTP module[1] might also come handy. Especially modifying documents is done by GETting the document, doing all the work locally and then PUTting it back, atomically replacing the old document.
IMO, constructing queries using strings is ugly and error prone.
Also, maybe it is better to let us know what you're trying to achieve in order to be able to offer you more specific answers.
[0]: http://docs.basex.org/wiki/REST [1]: http://docs.basex.org/wiki/HTTP_Module
On 17 June 2016 at 16:15, Kapoor, Sumit Sumit.Kapoor@adesso.de wrote:
Hello,
the Question is:
If I open a connection, send a query and close the connection: What do I get? Just a Copy of the Database which will be stored in the core/main memory or a reference to the DB? Here a Code Example:
let $cid := client:connect("localhost",port,"user","password")
let $query := 'collection("BIG-DB")/*:node'
let $req := client:query($cid,$query)
let $close := client:close($cid)
return $req
If it’s just a copy in the main memory than (depends on the size oft he DB) it will cost a lot of performance.
We have to use such a workaround with „client:connect“ because if we try to access directly the DB more than once it will be blocked.
So do you have any experience with the return value of „$req“ ? Is it still a reference of the DB or is it stored in the main memory?
Regards,
Sumit Kapoor
>>> business. people. technology. <<<
adesso AG mit Sitz in Dortmund Vorstand: Michael Kenfenheuer (Vors.), Christoph Junge, Andreas Prenneis Vorsitzender des Aufsichtsrates: Prof. Dr. Volker Gruhn Amtsgericht Dortmund HRB 20663
If I open a connection, send a query and close the connection: What do I get? Just a Copy of the Database which will be stored in the core/main memory or a reference to the DB? Here a Code Example:
You will always get a copy of the database node. As you may have seen in the documentation of the Client Module, you should never use it to address the same BaseX instance, as this can cause deadlocks.
We have to use such a workaround with „client:connect“ because if we try to access directly the DB more than once it will be blocked.
Do you have more details? Christian
I mean if we try to access the DB without "client:connect" e.g. :
if (collection("BIG-DB")/*:node[*:id=3/*:status = 'true') then _:todoFunc("") else ()
That would be an access to the DB without "client:connect" if I code it like that more than once I always get the error: "The Database is already in use". Because they block each other. For example if I add this to it:
let $anotherquery := collection("BIG-DB")/*:node
Regards, Sumit
-----Ursprüngliche Nachricht----- Von: Christian Grün [mailto:christian.gruen@gmail.com] Gesendet: Samstag, 18. Juni 2016 14:40 An: Kapoor, Sumit Sumit.Kapoor@adesso.de Cc: basex-talk@mailman.uni-konstanz.de Betreff: Re: [basex-talk] client:connect reference to DB or storage in RAM (loss in performance?)
If I open a connection, send a query and close the connection: What do I get? Just a Copy of the Database which will be stored in the core/main memory or a reference to the DB? Here a Code Example:
You will always get a copy of the database node. As you may have seen in the documentation of the Client Module, you should never use it to address the same BaseX instance, as this can cause deadlocks.
We have to use such a workaround with „client:connect“ because if we try to access directly the DB more than once it will be blocked.
Do you have more details? Christian
------------------------------------------------------- >>> business. people. technology. <<< -------------------------------------------------------
adesso AG mit Sitz in Dortmund Vorstand: Michael Kenfenheuer (Vors.), Christoph Junge, Andreas Prenneis Vorsitzender des Aufsichtsrates: Prof. Dr. Volker Gruhn Amtsgericht Dortmund HRB 20663
We need more information. Could you please provide us with a full example that demonstrates the problem?
I mean if we try to access the DB without "client:connect" e.g. :
if (collection("BIG-DB")/*:node[*:id=3/*:status = 'true') then _:todoFunc("") else ()
That would be an access to the DB without "client:connect" if I code it like that more than once I always get the error: "The Database is already in use". Because they block each other. For example if I add this to it:
let $anotherquery := collection("BIG-DB")/*:node
Regards, Sumit
-----Ursprüngliche Nachricht----- Von: Christian Grün [mailto:christian.gruen@gmail.com] Gesendet: Samstag, 18. Juni 2016 14:40 An: Kapoor, Sumit Sumit.Kapoor@adesso.de Cc: basex-talk@mailman.uni-konstanz.de Betreff: Re: [basex-talk] client:connect reference to DB or storage in RAM (loss in performance?)
If I open a connection, send a query and close the connection: What do I get? Just a Copy of the Database which will be stored in the core/main memory or a reference to the DB? Here a Code Example:
You will always get a copy of the database node. As you may have seen in the documentation of the Client Module, you should never use it to address the same BaseX instance, as this can cause deadlocks.
We have to use such a workaround with „client:connect“ because if we try to access directly the DB more than once it will be blocked.
Do you have more details? Christian
>>> business. people. technology. <<<
adesso AG mit Sitz in Dortmund Vorstand: Michael Kenfenheuer (Vors.), Christoph Junge, Andreas Prenneis Vorsitzender des Aufsichtsrates: Prof. Dr. Volker Gruhn Amtsgericht Dortmund HRB 20663
basex-talk@mailman.uni-konstanz.de