binary-to-string keeps files open

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

binary-to-string keeps files open

Jonathan Rowell

Hi,


in addition to the REST POST problem I have traced the problem down to the following bit of code. This reproduces the error of the file being kept open :-


xquery version "3.0";

declare variable $doc as xs:string := "/db/apps/JonathanTest/test/checker.xql";

         if (util:binary-doc-available($doc)) then
let $script := util:binary-to-string(util:binary-doc($doc))
return $script
         else
            <fail>{$doc}</fail>

whereas this runs correctly :-


xquery version "3.0";

declare variable $doc as xs:string := "/db/apps/JonathanTest/test/checker.xql";

         if (util:binary-doc-available($doc)) then
let $script := util:binary-doc($doc)
return $script
         else
            <fail>{$doc}</fail>

So it is clearly the util:binary-to-string() function which is keeping handles open. Why I don't yet know. It seems rather strange, as I would have thought that binary-doc() would have read the file and produced something in base64 and the function binary-to-string() would have simply decoded it.


regards


Jonathan




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: binary-to-string keeps files open

Adam Retter
Binary documents are actually InputStreams which can be read more than once. The file handle should be released when the query finishes executing.

On 12 Feb 2017 3:06 p.m., "Jonathan Rowell" <[hidden email]> wrote:

Hi,


in addition to the REST POST problem I have traced the problem down to the following bit of code. This reproduces the error of the file being kept open :-


xquery version "3.0";

declare variable $doc as xs:string := "/db/apps/JonathanTest/test/checker.xql";

         if (util:binary-doc-available($doc)) then
let $script := util:binary-to-string(util:binary-doc($doc))
return $script
         else
            <fail>{$doc}</fail>

whereas this runs correctly :-


xquery version "3.0";

declare variable $doc as xs:string := "/db/apps/JonathanTest/test/checker.xql";

         if (util:binary-doc-available($doc)) then
let $script := util:binary-doc($doc)
return $script
         else
            <fail>{$doc}</fail>

So it is clearly the util:binary-to-string() function which is keeping handles open. Why I don't yet know. It seems rather strange, as I would have thought that binary-doc() would have read the file and produced something in base64 and the function binary-to-string() would have simply decoded it.


regards


Jonathan




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: binary-to-string keeps files open

Dannes Wessels-3
Hi Adam,

On 12 Feb 2017, at 18:45 , Adam Retter <[hidden email]> wrote:

Binary documents are actually InputStreams which can be read more than once. The file handle should be released when the query finishes executing.

I remember that you have been working on this subject….. do you remember if it was post eXist 2.2 ?

cheers

Dannes

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open