From bfe4693e9a99edd8e6aa60a8002edb74b3f54d24 Mon Sep 17 00:00:00 2001 From: sixcooler Date: Tue, 23 Feb 2010 13:46:56 +0000 Subject: [PATCH] fix for http://forum.yacy-websuche.de/viewtopic.php?f=5&t=2703 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6693 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/net/yacy/kelondro/index/RowCollection.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/net/yacy/kelondro/index/RowCollection.java b/source/net/yacy/kelondro/index/RowCollection.java index ceeb4d6c7..b572dcf64 100644 --- a/source/net/yacy/kelondro/index/RowCollection.java +++ b/source/net/yacy/kelondro/index/RowCollection.java @@ -208,6 +208,11 @@ public class RowCollection implements Iterable { return this.rowdef; } + protected final int maxIntFromLong(long val) { + if (val >= Integer.MAX_VALUE) return Integer.MAX_VALUE; + return (int) val; + } + protected final long neededSpaceForEnsuredSize(final int elements, final boolean forcegc) { assert elements > 0 : "elements = " + elements; final long needed = elements * rowdef.objectsize; @@ -224,12 +229,12 @@ public class RowCollection implements Iterable { protected final void ensureSize(final int elements) throws RowSpaceExceededException { if (elements == 0) return; - final long allocram = neededSpaceForEnsuredSize(elements, true); + final int allocram = maxIntFromLong(neededSpaceForEnsuredSize(elements, true)); if (allocram == 0) return; assert allocram > chunkcache.length : "wrong alloc computation: allocram = " + allocram + ", chunkcache.length = " + chunkcache.length; if (!MemoryControl.request(allocram, true)) throw new RowSpaceExceededException(allocram, "RowCollection grow"); try { - final byte[] newChunkcache = new byte[(int) allocram]; // increase space + final byte[] newChunkcache = new byte[allocram]; // increase space System.arraycopy(chunkcache, 0, newChunkcache, 0, chunkcache.length); chunkcache = newChunkcache; } catch (OutOfMemoryError e) {