Am 13.11.2013 um 13:15 schrieb Federico.Balaguer <federico.balag...@gmail.com>:

> Thanks Norbert for your kind reply. 
> 
> My only reminding question is about the input. PetitStream are made from the
> contents of another stream. So, if I have a readStream on a file and I
> convert it to PetitStream, it will end up loading the entire content of the
> file on memory.  
> 
> Could it be possible to use a "LazyPetitStream" that is getting the content
> from the original stream incrementally?
> 
I don’t think so. What I said in my last mail is valid for the input stream as 
well. Parsing is about trying to match some content in multiple ways. This 
implies that you need to check if something matches and if it fails try 
matching something else. That also means you need to backtrack or better you 
need to get back and forth within a stream. This makes streaming less an option 
because you’ll always need to buffer and the buffer is likely to be as big as 
the whole content.
I don’t know what you are trying to achieve but probably there is another 
solution. Your mail sounds as you are concerned about memory consumption. 
Assuming further it is probably not a single entity you try to parse but a list 
of the same entity. In the case you could leave out the outermost star or plus 
parser and use the parser for a single entity until the end of the stream. So 
you would use the parser multiple times producing smaller chunks in memory.

Hope this helps,

Norbert 


Reply via email to