[
https://issues.apache.org/jira/browse/LUCENE-2324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845398#action_12845398
]
Michael Busch commented on LUCENE-2324:
---------------------------------------
{quote}
I think we can do even better, ie, that class wastes RAM for the single posting
case (intStart, byteStart, lastDocID, docFreq, lastDocCode, lastDocPosition are
not needed).
EG we could have a separate class dedicated to the singleton case. When term is
first encountered it's enrolled there. We'd probably need a separate hash to
store these (though not necessarily?). If it's seen again it's switched to the
full posting.
{quote}
Hmm I think we'd need a separate hash. Otherwise you have to subclass
PostingList for the different cases (freq. vs. non-frequent terms) and do
instanceof checks? Or with the parallel arrays idea maybe we could encode more
information in the dense ID? E.g. use one bit to indicate if that term occurred
more than once.
{quote}
I mean instead of allocating an instance per unique term, we assign an integer
ID (dense, ie, 0, 1, 2...).
And then we have an array for each member now in
FreqProxTermsWriter.PostingList, ie int[] docFreqs, int [] lastDocIDs, etc.
Then to look up say the lastDocID for a given postingID you just get
lastDocIDs[postingID]. If we're worried about oversize allocation overhead, we
can make these arrays paged... but that'd slow down each access.
{quote}
Yeah I like that idea. I've done something similar for representing trees - I
had a very compact Node class with no data but such a dense ID, and arrays that
stored the associated data. Very easy to add another data type with no RAM
overhead (you only use the amount of RAM the data needs).
Though, the price you pay is for dereferencing multiple times for each array?
And how much RAM would we safe? The pointer for the PostingList object (4-8
bytes), plus the size of the object header - how much is that in Java?
Seems ilke it's 8 bytes:
http://www.codeinstructions.com/2008/12/java-objects-memory-structure.html
So in a 32Bit JVM we would safe 4 bytes (pointer) + 8 bytes (header) - 4 bytes
(ID) = 8 bytes. For fields with tons of unique terms that might be worth it?
> Per thread DocumentsWriters that write their own private segments
> -----------------------------------------------------------------
>
> Key: LUCENE-2324
> URL: https://issues.apache.org/jira/browse/LUCENE-2324
> Project: Lucene - Java
> Issue Type: Improvement
> Components: Index
> Reporter: Michael Busch
> Assignee: Michael Busch
> Priority: Minor
> Fix For: 3.1
>
>
> See LUCENE-2293 for motivation and more details.
> I'm copying here Mike's summary he posted on 2293:
> Change the approach for how we buffer in RAM to a more isolated
> approach, whereby IW has N fully independent RAM segments
> in-process and when a doc needs to be indexed it's added to one of
> them. Each segment would also write its own doc stores and
> "normal" segment merging (not the inefficient merge we now do on
> flush) would merge them. This should be a good simplification in
> the chain (eg maybe we can remove the *PerThread classes). The
> segments can flush independently, letting us make much better
> concurrent use of IO & CPU.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]