Finalizing Query-Objects
Monday, 3 February 2020 · 3 messages · last reply 4 Feb 2020
BE
Ben Engbers3 Feb 2020 11:01 #
Hi,
The people from CRAN strongly suggested to add tests (comparable to Unit-tests) to my package (RBaseX). Their request led me to take another critical look at my code.
So far the tests do not give an error message. But after completing the last test, 'testthat' reports 1 failure without further explanation. After changing the order in which the tests are executed, the failure is always caused by the last test. Therefore I think that it are not the tests that cause an error, but the finalize-process.
At this moment, my code is based upon 3 classes: 'RBaseXClient' creates a new client-session. This session use 'SocketClass' to communicate with basexserver. When used in query-mode, the session uses 'QueryClass' to create new query-objects. Due to this architecture, it is easy to explicitly close a regular query-object, but (at least in R) it is difficult to close query-objects when finalizing the session-object.
How does the basexserver respond to closing the session without first explicitly closing all open querys? Does this result in an error?
Ben
CG
Christian Grün4 Feb 2020 08:17 #
It makes no difference for the BaseX server if you close the session and have open query objects (query objects exclusively reside in the client).
It can make a difference in client implementations, though. If you have a chance to always close queries after the execution, I think you should do so. I assume your are caching the query results before iterating over them, as it’s some in the other client implementations?
Quoted text · Ben Engbers · 24 lines
Ben Engbers <Ben.Engbers at be-logical.nl> schrieb am Mo., 3. Feb. 2020, 11:01: > Hi, > > The people from CRAN strongly suggested to add tests (comparable to > Unit-tests) to my package (RBaseX). Their request led me to take another > critical look at my code. > So far the tests do not give an error message. But after completing the > last test, 'testthat' reports 1 failure without further explanation. > After changing the order in which the tests are executed, the failure is > always caused by the last test. Therefore I think that it are not the > tests that cause an error, but the finalize-process. > > At this moment, my code is based upon 3 classes: 'RBaseXClient' creates > a new client-session. This session use 'SocketClass' to communicate with > basexserver. When used in query-mode, the session uses 'QueryClass' to > create new query-objects. Due to this architecture, it is easy to > explicitly close a regular query-object, but (at least in R) it is > difficult to close query-objects when finalizing the session-object. > > How does the basexserver respond to closing the session without first > explicitly closing all open querys? Does this result in an error? > > Ben >
BE
Ben Engbers4 Feb 2020 09:27 #
Quoted text · Christian Grün · 8 lines
Op 04-02-2020 om 08:17 schreef Christian Grün: > It makes no difference for the BaseX server if you close the session and > have open query objects (query objects exclusively reside in the client). > > It can make a difference in client implementations, though. If you have > a chance to always close queries after the execution, I think you should > do so. I assume your are caching the query results before iterating over > them, as it’s some in the other client implementations?
Hi Christian,
I used the java-client as example, so yes, I cam caching the query results. I will begin by explicitly closing all the querys, closing the socketconnection and removing the session-objects. Hopefully this will show what's causing the failure.
Ben
(The people from CRAN warned that this can be very difficult and can cause severe headache ;-( )
Written for BaseX 9.3. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery