OffHeapStore offHeap = new OffHeapStore();
MVStore s = new MVStore.Builder().
fileStore(offHeap).open();
I'm also thinking about combining the LIRS cache with the MVStore, so that you could build an off-heap LIRS cache. It shouldn't be complicated to implement (the cache would simply needs a map factory).
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.
@Override
public ByteBuffer write(ByteBuffer buff, Object obj) {
DataType t = getType(obj);
if (t != this) {
return t.write(buff, obj);
}
buff.put((byte) TYPE_SERIALIZED_OBJECT);
byte[] data = serialize(obj);
DataUtils.writeVarInt(buff, data.length);
int prevbuffremain = buff.remaining();
buff = DataUtils.ensureCapacity(buff, data.length);
try {
buff.put(data);
} catch (BufferOverflowException ex) {
if (obj instanceof Map) {
System.err.println("map.size: " + ((Map) obj).size());
}
System.err.println("data.length: " + data.length);
System.err.println("buff.limit:" + buff.limit());
System.err.println("buff.pos:" +buff.position());
System.err.println("buff.capacity: " +buff.capacity());
System.err.println("buff.remain: " + buff.remaining());
System.err.println("buff.prevbuffremain: " + prevbuffremain);
ex.printStackTrace();
}
return buff;
}
map.size: 84083
data.length: 3424297
buff.limit:4752468
buff.pos:2329143
buff.capacity: 4752468
buff.remain: 2423325
buff.prevbuffremain: 47091
java.nio.BufferOverflowException
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:183)
at java.nio.ByteBuffer.put(ByteBuffer.java:832)
at org.h2.mvstore.type.ObjectDataType$SerializedObjectType.write(ObjectDataType.java:1519)
at org.h2.mvstore.type.ObjectDataType.write(ObjectDataType.java:115)
at org.h2.mvstore.Page.write(Page.java:801)
at org.h2.mvstore.Page.writeUnsavedRecursive(Page.java:862)
at org.h2.mvstore.Page.writeUnsavedRecursive(Page.java:857)
at org.h2.mvstore.Page.writeUnsavedRecursive(Page.java:857)
at org.h2.mvstore.Page.writeUnsavedRecursive(Page.java:857)
at org.h2.mvstore.MVStore.storeNow(MVStore.java:903)
at org.h2.mvstore.MVStore.store(MVStore.java:822)
at org.h2.mvstore.MVStore.store(MVStore.java:791)
Caused by: java.lang.NullPointerException
at org.h2.mvstore.cache.CacheLongKeyLIRS$Segment.pruneStack(CacheLongKeyLIRS.java:824)
at org.h2.mvstore.cache.CacheLongKeyLIRS$Segment.convertOldestHotToCold(CacheLongKeyLIRS.java:815)
at org.h2.mvstore.cache.CacheLongKeyLIRS$Segment.evict(CacheLongKeyLIRS.java:783)
at org.h2.mvstore.cache.CacheLongKeyLIRS$Segment.put(CacheLongKeyLIRS.java:711)
at org.h2.mvstore.cache.CacheLongKeyLIRS.put(CacheLongKeyLIRS.java:162)
at org.h2.mvstore.MVStore.readPage(MVStore.java:1443)
at org.h2.mvstore.MVMap.readPage(MVMap.java:759)
at org.h2.mvstore.Page.getChildPage(Page.java:207)
at org.h2.mvstore.MVMap.binarySearch(MVMap.java:449)
at org.h2.mvstore.MVMap.binarySearch(MVMap.java:450)
at org.h2.mvstore.MVMap.binarySearch(MVMap.java:450)
at org.h2.mvstore.MVMap.get(MVMap.java:431)
Hi,
> DataUtils.ensureCapacity() isn't making a large enough ByteBuffer?
Yes, or maybe the method is not called in some cases where it should. Maybe it's better to wrap the ByteBuffer into a WriteBuffer that internally calls ensureCapacity when required. The current mechanism might be a bit more efficient, but also much more error prone.> CacheLongKeyLIRSYes, this looks like a bug. While there are many test cases for this class, what is not tested is overflow (when using a large cache size). I just found the following code runs into an endless loop after about 54'458'000 entries. This is a really large cache, given that by default there are 16 segments (so it would fail with 16 times that number of entries), but it's still a bug. Strange is that it doesn't always fail at the same entry, so it might be a combination of a JVM bug and a bug in the cache. There might be other overflow problems.int size = 100 * 1024 * 1024;CacheLongKeyLIRS<Integer> test = new CacheLongKeyLIRS<Integer>(size, 1, 1, 0);Integer value = 1;for (int i = 0; i < size; i++) {test.put(i, value);}Regards,ThomasOn Fri, Oct 11, 2013 at 8:33 AM, Noel Grandin <noelg...@gmail.com> wrote:
Hi
I had a quick look at this exception that Brian reported:
Caused by: java.lang.NullPointerException
at
org.h2.mvstore.cache.CacheLongKeyLIRS$Segment.pruneStack(CacheLongKeyLIRS.java:824)
at
org.h2.mvstore.cache.CacheLongKeyLIRS$Segment.convertOldestHotToCold(CacheLongKeyLIRS.java:815)
at
org.h2.mvstore.cache.CacheLongKeyLIRS$Segment.evict(CacheLongKeyLIRS.java:783)
at
org.h2.mvstore.cache.CacheLongKeyLIRS$Segment.put(CacheLongKeyLIRS.java:711)
at
org.h2.mvstore.cache.CacheLongKeyLIRS.put(CacheLongKeyLIRS.java:162)
at org.h2.mvstore.MVStore.readPage(MVStore.java:1443)
at org.h2.mvstore.MVMap.readPage(MVMap.java:759)
at org.h2.mvstore.Page.getChildPage(Page.java:207)
at org.h2.mvstore.MVMap.binarySearch(MVMap.java:449)
at org.h2.mvstore.MVMap.binarySearch(MVMap.java:450)
at org.h2.mvstore.MVMap.binarySearch(MVMap.java:450)
at org.h2.mvstore.MVMap.get(MVMap.java:431)
I suspect that this code in CacheLongKeyLIRS$Segment is the problem:
private void evict(Entry<V> newCold) {
// ensure there are not too many hot entries:
// left shift of 5 is multiplication by 32, that means if there are less
// than 1/32 (3.125%) cold entries, a new hot entry needs to become cold
while ((queueSize << 5) < mapSize) {
convertOldestHotToCold();
}
"queueSize" is an int , and if the queue gets big enough, the "<< 5" will operation will generate a zero because it will run move all of the bits outside the available 32 bits.
I think the code should look like:
while ((((long)queueSize) << 5) < mapSize) {
convertOldestHotToCold();
}
or maybe
while (queueSize < (mapSize >> 5)) {
convertOldestHotToCold();
}
--
You received this message because you are subscribed to a topic in the Google Groups "H2 Database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/h2-database/d5ewTdLDqiw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to h2-database...@googlegroups.com.