mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 21:18:58 +00:00
(forward-index) Don't leak off heap memory
This commit is contained in:
parent
08e8fc6736
commit
e498c6907a
@ -53,14 +53,14 @@ public class ForwardIndexReader {
|
||||
}
|
||||
|
||||
private static TLongIntHashMap loadIds(Path idsFile) throws IOException {
|
||||
var idsArray = LongArrayFactory.mmapForReadingShared(idsFile);
|
||||
try (var idsArray = LongArrayFactory.mmapForReadingShared(idsFile)) {
|
||||
var ids = new TLongIntHashMap((int) idsArray.size(), 0.5f, -1, -1);
|
||||
// This hash table should be of the same size as the number of documents, so typically less than 1 Gb
|
||||
idsArray.forEach(0, idsArray.size(), (pos, val) -> ids.put(val, (int) pos));
|
||||
return ids;
|
||||
}
|
||||
|
||||
var ids = new TLongIntHashMap((int) idsArray.size(), 0.5f, -1, -1);
|
||||
|
||||
// This hash table should be of the same size as the number of documents, so typically less than 1 Gb
|
||||
idsArray.forEach(0, idsArray.size(), (pos, val) -> ids.put(val, (int) pos));
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
private static LongArray loadData(Path dataFile) throws IOException {
|
||||
|
Loading…
Reference in New Issue
Block a user