indexed-file-reader
indexed-file-reader copied to clipboard
A question regarding index searching
Hello!
I have a question: why do you use this line
List<Long> positions = new ArrayList<>(index);
in the readLines method? Assume that we are processing a very large file with millions of lines, would not this be problematic?
Cheers
Behrang
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hi, the line converts the SortedSet
into a more operable List
.
Although a new List
instance is created, it is referencing the same elements as the SortedSet
so it won't add as much space as you'd expect. And because the List
is local to the method, it will be marked for garbage collection as soon as the method exits.
how about converting the resulting sortedset from indexing process to an array of doubles in the constructor?
i am not sure about efficiency of casting sortedset to array-list.
On Wednesday, March 16, 2016, Jan Amoyo [email protected] wrote:
Hi, the line converts the SortedSet into a more operable List.
Although a new List instance is created, it is referencing the same elements as the SortedSet so it won't add as much space as you'd expect. And because the List is local to the method, it will be marked for garbage collection as soon as the method exits.
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/jramoyo/indexed-file-reader/issues/1#issuecomment-197192829
that's a good point, we can convert the SortedSet
into a List
from the constructor, so that we don't have to do it every time.
Yeap, I think it is even better to have final arrays, i.e.,
final double[] index
I think that must do the job of unmodifiableList but I am not really sure; you are the expert!
From: Jan Amoyo [mailto:[email protected]] Sent: Wednesday 16 March 2016 11:01 To: jramoyo/indexed-file-reader [email protected] Cc: languagerecipes [email protected] Subject: Re: [indexed-file-reader] A question regarding index searching (#1)
that's a good point, we can convert the SortedSet into a List from the constructor, so that we don't have to do it every time.
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/jramoyo/indexed-file-reader/issues/1#issuecomment-197238131 https://github.com/notifications/beacon/AHuwE22d_meHuLULMNQd8273xfvL-W5Gks5pt9TrgaJpZM4HxTKX.gif