From da40172c68935a363a14770442d2cdad8ed2eaa3 Mon Sep 17 00:00:00 2001 From: vlofgren Date: Mon, 25 Jul 2022 15:05:45 +0200 Subject: [PATCH] Fix madvise code --- .../java/nu/marginalia/util/multimap/MultimapFileLong.java | 6 +++--- .../nu/marginalia/wmsa/edge/index/reader/SearchIndex.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/marginalia_nu/src/main/java/nu/marginalia/util/multimap/MultimapFileLong.java b/marginalia_nu/src/main/java/nu/marginalia/util/multimap/MultimapFileLong.java index 00ccd82c..061c9ed9 100644 --- a/marginalia_nu/src/main/java/nu/marginalia/util/multimap/MultimapFileLong.java +++ b/marginalia_nu/src/main/java/nu/marginalia/util/multimap/MultimapFileLong.java @@ -127,15 +127,15 @@ public class MultimapFileLong implements AutoCloseable, MultimapFileLongSlice { var buff = mappedByteBuffers.get((int)(startLongs / bufferSize)); if ((int)(startLongs / bufferSize) != (int)((endLongs) / bufferSize)) { - logger.warn("Misaligned madvise, skipping"); + logger.debug("Misaligned madvise, skipping"); return; } NativeIO.madviseRange(buff, advice, (startLongs % bufferSize) * WORD_SIZE, (int)(lengthLongs*WORD_SIZE)); } - public void pokeRange(long offset, int length) { - for (int i = 0; i < length; i += 4096/8) { + public void pokeRange(long offset, long length) { + for (long i = 0; i < length; i += 4096/8) { get(offset + i); } } diff --git a/marginalia_nu/src/main/java/nu/marginalia/wmsa/edge/index/reader/SearchIndex.java b/marginalia_nu/src/main/java/nu/marginalia/wmsa/edge/index/reader/SearchIndex.java index 0ab4d80b..b1830ef6 100644 --- a/marginalia_nu/src/main/java/nu/marginalia/wmsa/edge/index/reader/SearchIndex.java +++ b/marginalia_nu/src/main/java/nu/marginalia/wmsa/edge/index/reader/SearchIndex.java @@ -4,9 +4,9 @@ import com.google.inject.Inject; import com.google.inject.name.Named; import com.upserve.uppend.blobs.NativeIO; import io.reactivex.rxjava3.schedulers.Schedulers; -import nu.marginalia.wmsa.edge.index.conversion.SearchIndexConverter; import nu.marginalia.util.btree.BTreeReader; import nu.marginalia.util.multimap.MultimapFileLong; +import nu.marginalia.wmsa.edge.index.conversion.SearchIndexConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,7 +49,7 @@ public class SearchIndex implements AutoCloseable { urls.advice(NativeIO.Advice.Random); words.forEachWordsOffset(offset -> { var h = reader.getHeader(offset); - int length = (int) (h.dataOffsetLongs() - h.indexOffsetLongs()); + long length = h.dataOffsetLongs() - h.indexOffsetLongs(); urls.adviceRange(NativeIO.Advice.Normal, offset, 512);