mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 04:58:59 +00:00
(index) Slightly reduce alloc churn
This commit is contained in:
parent
03bffa27ac
commit
14372e0ef0
@ -21,9 +21,9 @@ public class SearchResultItem implements Comparable<SearchResultItem> {
|
||||
/** How many other potential results existed in the same domain */
|
||||
public int resultsFromDomain;
|
||||
|
||||
public SearchResultItem(long combinedId) {
|
||||
public SearchResultItem(long combinedId, int scoresCount) {
|
||||
this.combinedId = combinedId;
|
||||
this.keywordScores = new ArrayList<>(16);
|
||||
this.keywordScores = new ArrayList<>(scoresCount);
|
||||
}
|
||||
|
||||
|
||||
|
@ -115,14 +115,8 @@ public class IndexMetadataService {
|
||||
termdocToMeta = new Long2ObjectArrayMap<>(termIdsList.length);
|
||||
|
||||
for (long termId : termIdsList) {
|
||||
var mapForTerm = new Long2LongOpenHashMap(docIdsAll.length);
|
||||
|
||||
var metadata = index.getTermMetadata(termId, docIdsAll);
|
||||
for (int i = 0; i < docIdsAll.length; i++) {
|
||||
mapForTerm.put(docIdsAll[i], metadata[i]);
|
||||
}
|
||||
|
||||
termdocToMeta.put(termId, mapForTerm);
|
||||
termdocToMeta.put(termId, new Long2LongOpenHashMap(docIdsAll, metadata));
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,6 +132,7 @@ public class IndexMetadataService {
|
||||
|
||||
for (var coherenceSet : coherences.words()) {
|
||||
long overlap = 0xFF_FFFF_FFFF_FFFFL;
|
||||
|
||||
for (var word : coherenceSet) {
|
||||
long positions = WordMetadata.decodePositions(getTermMetadata(word, docId));
|
||||
overlap &= positions;
|
||||
|
@ -70,7 +70,8 @@ public class IndexResultValuator {
|
||||
boolean anyAllSynthetic = false;
|
||||
int maxPositionsSet = 0;
|
||||
|
||||
SearchResultItem searchResult = new SearchResultItem(id);
|
||||
SearchResultItem searchResult = new SearchResultItem(id,
|
||||
searchTermVariants.stream().mapToInt(List::size).sum());
|
||||
|
||||
for (int querySetId = 0;
|
||||
querySetId < searchTermVariants.size();
|
||||
|
@ -29,7 +29,7 @@ class IndexResultDomainDeduplicatorTest {
|
||||
}
|
||||
|
||||
SearchResultItem forId(int domain, int ordinal) {
|
||||
return new SearchResultItem(UrlIdCodec.encodeId(domain, ordinal));
|
||||
return new SearchResultItem(UrlIdCodec.encodeId(domain, ordinal), 4);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user