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
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
On Mon, Aug 23, 2010 at 4:56 PM, Godmar Back godmar@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@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
On Mon, Aug 23, 2010 at 12:22 PM, Christian Grün christian.gruen@gmail.comwrote:
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@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@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
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.
Godmar Back schrieb:
On Mon, Aug 23, 2010 at 12:22 PM, Christian Grün <christian.gruen@gmail.com mailto:christian.gruen@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@gmail.com mailto:godmar@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@mailman.uni-konstanz.de
mailto:BaseX-Talk@mailman.uni-konstanz.de
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de