note on BaseXClient.java
Monday, 23 August 2010 · 4 messages
CG
Thanks, and true; I've added a buffer. Note that the example file rather serves as an example how to access BaseX with sockets; this is why you won't find it in the jar file. The real Client/Server API, which is included in the main package, is much more mature; see e.g.:
http://basex.org/code/ServerExample
http://basex.org/code/ServerConcurrencyExample
Christian
Quoted text · Godmar Back · 33 lines
On Mon, Aug 23, 2010 at 4:56 PM, Godmar Back <godmar at gmail.com> wrote: > > Hi, > > The example file BaseXClient uses an unbuffered stream to write to the > socket: > > out = socket.getOutputStream(); > > void send(final String s) throws IOException { > for(final byte t : s.getBytes()) out.write(t); > out.write(0); > } > > This yields extremely bad performance, especially for large queries (every > single call to write will trigger a separate system call to the OS, which in > turn will trigger a separate TCP segment on the wire). On a typical > Ethernet, this means that 100 minimum sized packets are transmitted rather > than a single packet to transmit a 100-byte query. > > On a different note, why is BaseXClient not part of the "official" BaseX > API, or at least provided as part of the distributed .jar files in an > org.basex.* package? > > - Godmar > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
GB
Godmar Back23 Aug 2010 18:55 #
Hi,
The example file BaseXClient uses an unbuffered stream to write to the socket:
out = socket.getOutputStream();
void send(final String s) throws IOException {
for(final byte t : s.getBytes()) out.write(t);
out.write(0);
}This yields extremely bad performance, especially for large queries (every single call to write will trigger a separate system call to the OS, which in turn will trigger a separate TCP segment on the wire). On a typical Ethernet, this means that 100 minimum sized packets are transmitted rather than a single packet to transmit a 100-byte query.
On a different note, why is BaseXClient not part of the "official" BaseX API, or at least provided as part of the distributed .jar files in an org.basex.* package?
- Godmar
AW
Quoted text · Godmar Back · 5 lines
> On a related note, I can't make sense of this figure: > http://www.inf.uni-konstanz.de/dbis/basex/gfx/comm.png > In particular, "Handle Results" has no incident edges; and it's not > clear why after continuing in iterative mode I would end up stuck in > "standard mode" with no outgoing edges.
The figure shows that you have the choice between executing a query/command in the standard version or
execute a query in the iterative version. After that the server executes and returns an exception or result.
The client decides if it is a result or exception.
After that you have the choice to continue, execute....like the start...or just exit the client.
I guess there could be more edges, but the description on the bottom of the page
should be provide enough explanation.
Quoted text · Godmar Back · 89 lines
Godmar Back schrieb: > On Mon, Aug 23, 2010 at 12:22 PM, Christian Grün > <christian.gruen at gmail.com <mailto:christian.gruen at gmail.com>> wrote: > > Thanks, and true; I've added a buffer. Note that the example file > rather serves as an example how to access BaseX with sockets; this is > why you won't find it in the jar file. The real Client/Server API, > which is included in the main package, is much more mature; see e.g.: > > http://basex.org/code/ServerExample > http://basex.org/code/ServerConcurrencyExample > > > Could you elaborate? > > Why is there a "real" API and an example? > > The ServerExample link above doesn't appear to use the iterative > protocol, using 'execute' instead. In what sense is this "more mature" > than the BaseXClient.java file that supports this protocol? > > I'd much rather use a single, officially sanctioned API to access a > BaseX server from a Java client and have a robust way to iterate > through multiple query results. > > On a related note, I can't make sense of this figure: > http://www.inf.uni-konstanz.de/dbis/basex/gfx/comm.png > In particular, "Handle Results" has no incident edges; and it's not > clear why after continuing in iterative mode I would end up stuck in > "standard mode" with no outgoing edges. > > - Godmar > > > > > Christian > > > On Mon, Aug 23, 2010 at 4:56 PM, Godmar Back <godmar at gmail.com > <mailto:godmar at gmail.com>> wrote: > > > > Hi, > > > > The example file BaseXClient uses an unbuffered stream to write > to the > > socket: > > > > out = socket.getOutputStream(); > > > > void send(final String s) throws IOException { > > for(final byte t : s.getBytes()) out.write(t); > > out.write(0); > > } > > > > This yields extremely bad performance, especially for large > queries (every > > single call to write will trigger a separate system call to the > OS, which in > > turn will trigger a separate TCP segment on the wire). On a typical > > Ethernet, this means that 100 minimum sized packets are > transmitted rather > > than a single packet to transmit a 100-byte query. > > > > On a different note, why is BaseXClient not part of the > "official" BaseX > > API, or at least provided as part of the distributed .jar files > in an > > org.basex.* package? > > > > - Godmar > > > > > > _______________________________________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-konstanz.de > <mailto:BaseX-Talk at mailman.uni-konstanz.de> > > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
GB
On Mon, Aug 23, 2010 at 12:22 PM, Christian Grün
<christian.gruen at gmail.com>wrote:
Quoted text · Christian Grün · 9 lines
> Thanks, and true; I've added a buffer. Note that the example file > rather serves as an example how to access BaseX with sockets; this is > why you won't find it in the jar file. The real Client/Server API, > which is included in the main package, is much more mature; see e.g.: > > http://basex.org/code/ServerExample > http://basex.org/code/ServerConcurrencyExample > >
Could you elaborate?
Why is there a "real" API and an example?
The ServerExample link above doesn't appear to use the iterative protocol, using 'execute' instead. In what sense is this "more mature" than the BaseXClient.java file that supports this protocol?
I'd much rather use a single, officially sanctioned API to access a BaseX server from a Java client and have a robust way to iterate through multiple query results.
On a related note, I can't make sense of this figure:
http://www.inf.uni-konstanz.de/dbis/basex/gfx/comm.png
In particular, "Handle Results" has no incident edges; and it's not clear why after continuing in iterative mode I would end up stuck in "standard mode" with no outgoing edges.
- Godmar
Quoted text · Christian Grün · 40 lines
> Christian > > > On Mon, Aug 23, 2010 at 4:56 PM, Godmar Back <godmar at gmail.com> wrote: > > > > Hi, > > > > The example file BaseXClient uses an unbuffered stream to write to the > > socket: > > > > out = socket.getOutputStream(); > > > > void send(final String s) throws IOException { > > for(final byte t : s.getBytes()) out.write(t); > > out.write(0); > > } > > > > This yields extremely bad performance, especially for large queries > (every > > single call to write will trigger a separate system call to the OS, which > in > > turn will trigger a separate TCP segment on the wire). On a typical > > Ethernet, this means that 100 minimum sized packets are transmitted > rather > > than a single packet to transmit a 100-byte query. > > > > On a different note, why is BaseXClient not part of the "official" BaseX > > API, or at least provided as part of the distributed .jar files in an > > org.basex.* package? > > > > - Godmar > > > > > > _______________________________________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-konstanz.de > > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > > >
Written for BaseX 6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery