I have a very large file and each line can be parsed into a view object. However, I want to return a iterator[A] instead of collection, so it can have better memory characteristics for the large file parsing.
factory.createContainer(line: String): Foo = .......
def parse: Iterator[Foo] = {
io.linesR("src/test/resources/largedummy.txt")
.map(line => factory.createContainer(line))
.to(.......)
// I am not sure how can write it in here to return a Iterator[Foo]
}
Many thanks in advance