Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Meikel Brandmeyer
Hi, and more errata: reading is not thread-safe when the result is -1. Then an unintended switch! might happen. There things have to be packed into a locking together with a second read to verify it's still −1. Details! Details! Kind regards Meikel signature.asc Description: Message signed w

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Meikel Brandmeyer
Hi, Am 13.07.2012 um 23:48 schrieb Kevin Downey: > thank you for responding personally to me, but I sent my message to > clojure google group. > > given the thread has the subject "Concatenating InputStreams" and I > linked javadocs for a standard part of java.io that does exactly that, > I am s

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Alan Malloy
It's a public class in clojure.lang that is not used by any part of the Clojure runtime or standard libraries. I can't think what other reason it would be included for, if not to be used by you. Just like clojure.lang.PersistentQueue - there's no nice Clojure wrapper for it (why on Earth not?),

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Kevin Downey
thank you for responding personally to me, but I sent my message to clojure google group. given the thread has the subject "Concatenating InputStreams" and I linked javadocs for a standard part of java.io that does exactly that, I am surprised that you decided to respond with "tl;dr", but I have n

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Meikel Brandmeyer
Hi, Am 13.07.2012 um 19:25 schrieb Alan Malloy: > (defn coll->enumeration [coll] > (clojure.lang.SeqEnumeration. coll)) Ah. I knew there must be something. But it doesn't seem to be official, public API. Meikel signature.asc Description: Message signed with OpenPGP using GPGMail

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Alan Malloy
(defn coll->enumeration [coll] (clojure.lang.SeqEnumeration. coll)) On Friday, July 13, 2012 7:13:54 AM UTC-7, Meikel Brandmeyer (kotarak) wrote: > > Hi, > > I think you don't handle the switching of streams correctly. You have to > keep track with atoms. But then you run into thread-safety is

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Kevin Downey
http://docs.oracle.com/javase/1.5.0/docs/api/java/io/SequenceInputStream.html On Fri, Jul 13, 2012 at 7:29 AM, Meikel Brandmeyer (kotarak) wrote: > Hi again, > > talking about thread safety. > > Am Freitag, 13. Juli 2012 16:13:54 UTC+2 schrieb Meikel Brandmeyer > (kotarak): >> >> (close >>

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Meikel Brandmeyer (kotarak)
Hi again, talking about thread safety. Am Freitag, 13. Juli 2012 16:13:54 UTC+2 schrieb Meikel Brandmeyer (kotarak): > > (close > [] > (when @is > (.close @is) > (doseq [s @streams] (.close s (close [] (locking this (when @is (.close

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Meikel Brandmeyer (kotarak)
Hi, I think you don't handle the switching of streams correctly. You have to keep track with atoms. But then you run into thread-safety issues. (defn concat-input-stream "Gets one or many input streams and returns a new input stream that concatenates the given streams." [is & streams] (l

Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Wolodja Wentland
On Wed, Jul 11, 2012 at 14:46 +0200, Tassilo Horn wrote: > Hm, probably yes. But you can implement the other arities quiet easily. > So that version also accepts the version that reads into a byte array. > The third version is left as an exercise for the reader. ;-) Thanks, I've done that and had

Re: Parsing SGML

2012-07-11 Thread Tassilo Horn
Wolodja Wentland writes: >> --8<---cut here---start->8--- >> (defn concat-input-stream >> "Gets one or many input streams and returns a new input stream that >> concatenates the given streams." >>^java.io.InputStream [^java.io.InputStream is & more] >>

Re: Parsing SGML

2012-07-11 Thread Wolodja Wentland
On Wed, Jul 11, 2012 at 12:32 +0200, Tassilo Horn wrote: > Wolodja Wentland writes: > > > On Tue, Jul 10, 2012 at 17:16 +0200, Tassilo Horn wrote: > >> I think, I'd simply copy the clojure.xml code and adapt it to my needs. > > > >> Not too pretty, but should be adequate for getting the job done.

Re: Parsing SGML

2012-07-11 Thread Tassilo Horn
Wolodja Wentland writes: > On Tue, Jul 10, 2012 at 17:16 +0200, Tassilo Horn wrote: >> I think, I'd simply copy the clojure.xml code and adapt it to my needs. > >> Not too pretty, but should be adequate for getting the job done. > > I look into that, but it really wouldn't be pretty. I still thin

Re: Parsing SGML

2012-07-11 Thread Wolodja Wentland
On Tue, Jul 10, 2012 at 17:16 +0200, Tassilo Horn wrote: > I think, I'd simply copy the clojure.xml code and adapt it to my needs. > Not too pretty, but should be adequate for getting the job done. I look into that, but it really wouldn't be pretty. I still think that it must be possible to add t

Re: Parsing SGML

2012-07-11 Thread Wolodja Wentland
On Tue, Jul 10, 2012 at 12:06 -0700, Alan Malloy wrote: >Just create a Reader over the file, and do something like (take-while >identity (repeatedly #(read-one-wellformed-xml-tag the-reader))). It needs >some fleshing out for boundary conditions, but I hope you get the general >idea

Re: Parsing SGML

2012-07-10 Thread Alan Malloy
Just create a Reader over the file, and do something like (take-while identity (repeatedly #(read-one-wellformed-xml-tag the-reader))). It needs some fleshing out for boundary conditions, but I hope you get the general idea. On Tuesday, July 10, 2012 6:04:23 AM UTC-7, Wolodja Wentland wrote: >

Re: Parsing SGML

2012-07-10 Thread Tassilo Horn
Wolodja Wentland writes: Hi Wolodja, > valid XML apart from the fact that they lack a root tag. The whole issue is > complicated by the fact that the input files are pretty large (i.e. 9.1 GB > gzipped files) and that I therefore cannot read them completely into > memory. > > I am, however, unsu

Parsing SGML

2012-07-10 Thread Wolodja Wentland
Dear all, I am running into problems when I try to parse SGML documents [0] that are valid XML apart from the fact that they lack a root tag. The whole issue is complicated by the fact that the input files are pretty large (i.e. 9.1 GB gzipped files) and that I therefore cannot read them completel