[ https://issues.apache.org/jira/browse/JCR-1213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12543374 ]
Ard Schrijvers commented on JCR-1213: ------------------------------------- ATM I have been able to change some parts to store in UUIDDocId a reference to the segmentIndexReader the documentNumber was found in. This means that not the entire cache is lost when the multi Index changes, but only those parts that involve a segment change. Now, I am looking at a clean way to recompute the docNumber, because even if the segment index reader did not change, the docNumber might (quite likely) because the multiIndexReader has changed, hence the individual reader offsets as well. I'll try to find time next week for it. Perhaps somebody has an idea how to implement it 'clean', because I do not really like the way I am heading with changing the SingleTermDocs to store the docNumber with offset, and also store the docNumber without, to have the doc number available in the segment. This implies, in DocId I have to cast to SingleTermDocs....etc etc which is not nice. WDOT? Any ideas? Or should we refactor a few parts, to be able to recompute the docNumber? > UUIDDocId cache does not work properly because of weakReferences in > combination with new instance for combined indexreader > --------------------------------------------------------------------------------------------------------------------------- > > Key: JCR-1213 > URL: https://issues.apache.org/jira/browse/JCR-1213 > Project: Jackrabbit > Issue Type: Improvement > Components: query > Affects Versions: 1.3.3 > Reporter: Ard Schrijvers > Fix For: 1.4 > > > Queries that use ChildAxisQuery or DescendantSelfAxisQuery make use of > getParent() functions to know wether the parents are correct and if the > result is allowed. The getParent() is called recursively for every hit, and > can become very expensive. Hence, in DocId.UUIDDocId, the parents are cached. > Currently, docId.UUIDDocId's are cached by having a WeakRefence to the > CombinedIndexReader, but, this CombinedIndexReader is recreated all the time, > implying that a gc() is allowed to remove the 'expensive' cache. > A much better solution is to not have a weakReference to the > CombinedIndexReader, but to a reference of each indexreader segment. This > means, that in getParent(int n) in SearchIndex the return > return id.getDocumentNumber(this) needs to be replaced by return > id.getDocumentNumber(subReaders[i]); and something similar in > CachingMultiReader. > That is all. Obviously, when a node/property is added/removed/changed, some > parts of the cached DocId.UUIDDocId will be invalid, but mainly small indexes > are updated frequently, which obviously are less expensive to recompute. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.