[jdom-interest] Ampersand question
guru at edamame.stinky.com
Thu Jul 13 06:35:08 PDT 2000
All I meant was that java.sql.Blob.getBinaryStream() returns an
InputStream. (I'm not sure how it's implemented behind the scenes by
drivers.) I was imagining XML being stored directly in the DB, since
I think you mentioned blobs at one point.
Without looking in detail at your architecture, I'm not sure how much
it applies, but my main point was, try to eliminate middle steps. If
you have, e.g., code that turns a result set into an XML string, then
more code that turns the XML string into a JDOM tree, then it would be
more efficient to have code that turns the ResultSet into a JDOM tree directly.
Barring that (and I think you did bar that by saying "this is not my
choice"), the next best thing would be to make sure when building your
string to make liberal use of StringBuffer.append rather than making
individual strings and then later StringBuffer.appending them together
(this happens when using +). Each new string gets (a) copied, wasting
time, and (b) abandoned in the heap, wasting a little space, requiring
GC to happen more frequently, and making the heap more fragmented when
GC is done, which increases the memory footprint of the app.
On Thu, Jul 13, 2000 at 03:32:02PM -0400, tsasala at hifusion.com wrote:
> The use of string, unfortunely, is not my choice. This is
> the way "content" is persisted to our database. There little I can
> do to affect that for now.
> I'm curious to know what you mean by "streams" coming
> from the database. JDBC is returning a resultset, not streams.
> The objects within the results are then mapped to objects; in this
> case a stream representing the JDOM object.
> Alex Chaffee wrote:
> > > Also, we are throwing around a combination of strings and JDOM
> > > documents. [...]
> > Your need is clear, and very compelling. One important point I'd like
> > to emphasize:
> > Strings are SLOW.
> > Moreover, they fill up the heap like crazy. The architecture you
> > described will probably be very clean and straightforward to write,
> > and perform very poorly.
> > You might be better advised to use streams and buffers rather than
> > generating a new String for every document.
> > Likewise, when reading a blob from the DB, you get it as a stream; why
> > bother going through the extra step of converting it into a string,
> > then parsing the string, when you can just parse it directly as a
> > stream? Same goes for writing to the DB.
> > - Alex
> > --
> > Alex Chaffee mailto:alex at jguru.com
> > jGuru - Java News and FAQs http://www.jguru.com/alex/
> > Creator of Gamelan http://www.gamelan.com/
> > Founder of Purple Technology http://www.purpletech.com/
> > Curator of Stinky Art Collective http://www.stinky.com/
Alex Chaffee mailto:alex at jguru.com
jGuru - Java News and FAQs http://www.jguru.com/alex/
Creator of Gamelan http://www.gamelan.com/
Founder of Purple Technology http://www.purpletech.com/
Curator of Stinky Art Collective http://www.stinky.com/
More information about the jdom-interest