Restxq and java

Thursday, 21 April 2016 · 4 messages · last reply 22 Apr 2016
M
meumapple21 Apr 2016 23:08 #

Hi,

I have developed a restxq service, which executes a command via the process module. The command is actually java (java -cp ...) which actionates a linguistic parser: unfortunately the time of loading/opening of the java process is quite long (14 sec., also at the command line) even if the actual parsing is very fast. I am looking for a way to keep such a java process "open", so that a user's request can be satisfied much much quickier (while now the java process is opened and then closed for each single request). I am not sure this is a question for Basex users (the problem is only due to java), but I am not a java developer at all and I am trying to understand what can be done in this respect. Thanks!

Joseph

CG
Christian Grün22 Apr 2016 11:03 #

Hi Joseph,

You could try to copy your Java library into the 'lib' directory of BaseX. After that, you can directly access it via XQuery Java Bindings [1].

Hope this helps, Christian

[1] http://docs.basex.org/wiki/Java_Bindings

Quoted text · meumapple · 3 lines
> I have developed a restxq service, which executes a command via the process module. The command is actually java (java -cp ...) which actionates a linguistic parser: unfortunately the time of loading/opening of the java process is quite long (14 sec., also at the command line) even if the actual parsing is very fast. I am looking for a way to keep such a java process "open", so that a user's request can be satisfied much much quickier (while now the java process is opened and then closed for each single request). I am not sure this is a question for Basex users (the problem is only due to java), but I am not a java developer at all and I am trying to understand what can be done in this respect. Thanks! > > Joseph
M
meumapple22 Apr 2016 15:24 #

Hi Christian,

I have put my jar file in lib but I am not sure I am accessing it in the right way. The bash command is "java -cp myparser.jar is.tag.Tagger -model /mymodel -input /myfile.txt -output /result.txt"

How should I translate this via xquery bindings?

Thanks!

Quoted text · Christian Grün · 1 line
Il giorno 22 apr 2016, alle ore 11:03, Christian Grün <christian.gruen at gmail.com> ha scritto:

Hi Joseph,

You could try to copy your Java library into the 'lib' directory of BaseX. After that, you can directly access it via XQuery Java Bindings [1].

Hope this helps, Christian

[1] http://docs.basex.org/wiki/Java_Bindings

Quoted text · Christian Grün · 3 lines
> I have developed a restxq service, which executes a command via the process module. The command is actually java (java -cp ...) which actionates a linguistic parser: unfortunately the time of loading/opening of the java process is quite long (14 sec., also at the command line) even if the actual parsing is very fast. I am looking for a way to keep such a java process "open", so that a user's request can be satisfied much much quickier (while now the java process is opened and then closed for each single request). I am not sure this is a question for Basex users (the problem is only due to java), but I am not a java developer at all and I am trying to understand what can be done in this respect. Thanks! > > Joseph
CG
Christian Grün22 Apr 2016 15:28 #

Hi Joseph,

Quoted text · meumapple · 1 line
> I have put my jar file in lib but I am not sure I am accessing it in the right way. The bash command is "java -cp myparser.jar is.tag.Tagger -model /mymodel -input /myfile.txt -output /result.txt"

There is no need to use the Process Module anymore. Instead, you’ll need to invoke the Tagger method. It could work as follows:

  declare namespace tagger = "is.tag.Tagger";
  tagger:main("-model", "/mymodel", "-input", "/myfile.txt",
"-output", "/result.txt")

If it doesn’t, you should (if possible) have a look at the Java sources and check how to properly invoke or instantiate the Java class.

Cheers, Christian

Quoted text · meumapple · 22 lines
> > How should I translate this via xquery bindings? > > Thanks! > > Il giorno 22 apr 2016, alle ore 11:03, Christian Grün <christian.gruen at gmail.com> ha scritto: > > Hi Joseph, > > You could try to copy your Java library into the 'lib' directory of > BaseX. After that, you can directly access it via XQuery Java Bindings > [1]. > > Hope this helps, > Christian > > [1] http://docs.basex.org/wiki/Java_Bindings > > >> I have developed a restxq service, which executes a command via the process module. The command is actually java (java -cp ...) which actionates a linguistic parser: unfortunately the time of loading/opening of the java process is quite long (14 sec., also at the command line) even if the actual parsing is very fast. I am looking for a way to keep such a java process "open", so that a user's request can be satisfied much much quickier (while now the java process is opened and then closed for each single request). I am not sure this is a question for Basex users (the problem is only due to java), but I am not a java developer at all and I am trying to understand what can be done in this respect. Thanks! >> >> Joseph

⚡Generated with XQuery