Re: [basex-talk] Write output using proc:execute

2020-04-09 Thread Tim Thompson
Ah, of course. Thank you, Liam! That's what I needed.

All best,
Tim


--
Tim A. Thompson
Discovery Metadata Librarian
Yale University Library


On Thu, Apr 9, 2020 at 4:31 PM Liam R. E. Quin 
wrote:

> On Thu, 2020-04-09 at 16:00 -0400, Tim Thompson wrote:
> >
> > proc:execute("echo", ("hello!", "> hello.txt"))
>
> You could run, bash -c 'echo hello > hello.txt'
> instead, maybe?
>
>
> This is assuming you are using Linux or the Linux subsystem on Windows,
> or cygwin, or OS X... so bash is available.
>
> --
> Liam Quin, https://www.delightfulcomputing.com/
> Available for XML/Document/Information Architecture/XSLT/
> XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
> Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org
>
>


Re: [basex-talk] Write output using proc:execute

2020-04-09 Thread Liam R. E. Quin
On Thu, 2020-04-09 at 16:00 -0400, Tim Thompson wrote:
> 
> proc:execute("echo", ("hello!", "> hello.txt"))

You could run, bash -c 'echo hello > hello.txt'
instead, maybe?


This is assuming you are using Linux or the Linux subsystem on Windows,
or cygwin, or OS X... so bash is available.

-- 
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org



[basex-talk] Write output using proc:execute

2020-04-09 Thread Tim Thompson
Hello,

Is it possible to redirect output from a system command within the
proc:execute function?

I would like to do something like:

proc:execute("echo", ("hello!", "> hello.txt"))

but the ">" does not seem to be recognized.

Thanks in advance,
Tim


--
Tim A. Thompson
Discovery Metadata Librarian
Yale University Library


Re: [basex-talk] Memoize

2020-04-09 Thread Liam R. E. Quin
On Thu, 2020-04-09 at 10:08 +0200, Mickael Desfrenes wrote:
> 
> My goal was to get faster results when a query is run multiple times.
> Yes, that's probably premature optimization, but since I do require
> these things in other application stacks I thought I'd ask.

I have a Perl-based framework that kept a cache of results). But, the
time taken to open a cache file and read it is often longer than it
takes BaseX to run the query. The main value is that there are a couple
of queries that are much slower.

I've also used memcached via php in a front end, and that's faster.

One of that hardest things about cache management, though, is
invalidating pages when the data changes. For 
https://www.fromoldbooks.org/Search/ i just blow away the whole cache
and then pre-fetch the 100 or so most common queries, one per second.

But the front page on fromoldbooks.org is not cached and is just about
as fast as a search. The sweet spot for Web back ends is still that you
need a Web page to finish loading in under two seconds to stop Google
from hating you :)

Liam

-- 
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org



Re: [basex-talk] Feature Request: Save untitled, open scripts when exiting GUI

2020-04-09 Thread Christian Grün
Hi Andreas,

A 21-month delivery time may be subject to improvement, but you may be
glad to hear that unnamed GUI editor files will now be remembered and
opened again after a restart [1,2].

Have fun,
Christian

[1] https://github.com/BaseXdb/basex/issues/1598
[2] http://files.basex.org/releases/latest/


On Sun, Jul 29, 2018 at 9:58 PM Andreas Mixich  wrote:
>
> SublimeText has this nifty feature, that it saves all open tabs, even if the 
> have no representation on the filesystem, so one can continue exactly, where 
> one has left off.
>
> I find myself often to have several, unnamed, XQueries open, to test this 
> concept, to compose that function, etc. It would be nice, if one could simply 
> shut off and have them reopened next time without naming a file and saving 
> each item in question.
>
> --
> Minden jót, all the best, Alles Gute,
> Andreas Mixich


Re: [basex-talk] Memoize

2020-04-09 Thread Mickael Desfrenes
Hello,

Thank you for the rewrote of the memoize function, that's very interesting. 
(and the part about the java hashmap will actually find a use for another 
problem I have).

My goal was to get faster results when a query is run multiple times. Yes, 
that's probably premature optimization, but since I do require these things in 
other application stacks I thought I'd ask.

Mickaël

- Mail original -
De: "Christian Grün" 
À: "Andreas Mixich" , "Mickael Desfrenes" 

Cc: "basex-talk" 
Envoyé: Mercredi 8 Avril 2020 11:05:46
Objet: Re: [basex-talk] Memoize

Hi Mickael, hi Andreas,

> It is written in the Marklogic dialect of XQuery. but porting it was a 
> no-brainer, since, AFAIR, only the syntax for maps had to be changed. The 
> Github repo is here.

I see that the code uses MarkLogic’s map module functions, which are
based on an implementation of a classical side-effecting and mutable
hash map. As real XQuery maps are immutable (i.e., once defined, their
contents will never change, see [1]), you may need to use Java
bindings and instantiate a Java HashMap [2]. I have rewritten one of
the proposed memoize functions, it’s attached.

I forgot to mention that BaseX itself uses runtime optimizations to
memoize data as well. Just two examples:

1. If a path expression is requested multiple times, its result will
automatically be cached. In the query below, it’s //name that will
only be evaluated once:

  //city[. = //name]

2. If large sequences are compared, the items to be compared will
incrementally be stored in a hash map. In the query below, it’s the
items of $lines2 that will be put to a hash map:

  let $lines1 := file:read-text-lines('file1.txt')
  let $lines2 := file:read-text-lines('file2.txt')
  return $lines1[. = $lines2]

In both cases, evaluation time can be reduced from a quadratical to a
linear runtime (and the result may be available within milliseconds
instead of seconds or minutes).

@Mickael:

1. Do you try to reduce the runtime of specific queries, or
2. do you want to get faster results if you run the same query multiple times?

Do you possibly have specific use cases or queries which you’d like to
speed up via memoization?

Best,
Christian

[1] http://docs.basex.org/wiki/XQuery_3.1#Maps
[2] http://docs.basex.org/wiki/Java_Bindings