(index) Slightly reduce alloc churn

This commit is contained in:
Viktor Lofgren 2023-09-24 19:35:15 +02:00
parent 03bffa27ac
commit 14372e0ef0
4 changed files with 7 additions and 11 deletions

View File

@ -21,9 +21,9 @@ public class SearchResultItem implements Comparable<SearchResultItem> {
/** How many other potential results existed in the same domain */ /** How many other potential results existed in the same domain */
public int resultsFromDomain; public int resultsFromDomain;
public SearchResultItem(long combinedId) { public SearchResultItem(long combinedId, int scoresCount) {
this.combinedId = combinedId; this.combinedId = combinedId;
this.keywordScores = new ArrayList<>(16); this.keywordScores = new ArrayList<>(scoresCount);
} }

View File

@ -115,14 +115,8 @@ public class IndexMetadataService {
termdocToMeta = new Long2ObjectArrayMap<>(termIdsList.length); termdocToMeta = new Long2ObjectArrayMap<>(termIdsList.length);
for (long termId : termIdsList) { for (long termId : termIdsList) {
var mapForTerm = new Long2LongOpenHashMap(docIdsAll.length);
var metadata = index.getTermMetadata(termId, docIdsAll); var metadata = index.getTermMetadata(termId, docIdsAll);
for (int i = 0; i < docIdsAll.length; i++) { termdocToMeta.put(termId, new Long2LongOpenHashMap(docIdsAll, metadata));
mapForTerm.put(docIdsAll[i], metadata[i]);
}
termdocToMeta.put(termId, mapForTerm);
} }
} }
@ -138,6 +132,7 @@ public class IndexMetadataService {
for (var coherenceSet : coherences.words()) { for (var coherenceSet : coherences.words()) {
long overlap = 0xFF_FFFF_FFFF_FFFFL; long overlap = 0xFF_FFFF_FFFF_FFFFL;
for (var word : coherenceSet) { for (var word : coherenceSet) {
long positions = WordMetadata.decodePositions(getTermMetadata(word, docId)); long positions = WordMetadata.decodePositions(getTermMetadata(word, docId));
overlap &= positions; overlap &= positions;

View File

@ -70,7 +70,8 @@ public class IndexResultValuator {
boolean anyAllSynthetic = false; boolean anyAllSynthetic = false;
int maxPositionsSet = 0; int maxPositionsSet = 0;
SearchResultItem searchResult = new SearchResultItem(id); SearchResultItem searchResult = new SearchResultItem(id,
searchTermVariants.stream().mapToInt(List::size).sum());
for (int querySetId = 0; for (int querySetId = 0;
querySetId < searchTermVariants.size(); querySetId < searchTermVariants.size();

View File

@ -29,7 +29,7 @@ class IndexResultDomainDeduplicatorTest {
} }
SearchResultItem forId(int domain, int ordinal) { SearchResultItem forId(int domain, int ordinal) {
return new SearchResultItem(UrlIdCodec.encodeId(domain, ordinal)); return new SearchResultItem(UrlIdCodec.encodeId(domain, ordinal), 4);
} }
} }