Hi,

I'm working on migrating from mvstore 1.4.199 to 2.2.224 and have noticed 
that the MVMap.openVersion semantics have changed. The 1.4.199 version 
opens the map with the largest version that is smaller than or equal to the 
requested version while the 2.2.224 version opens the map with the smallest 
version greater than or equal to the requested version.

The change appeared to occur with this commit.
Correct getOldestVersionToKeep() to always honor "versionsToKeep" ยท 
h2database/h2database@cd223d5 (github.com) 
<https://github.com/h2database/h2database/commit/cd223d5308b2ff31e5cf7175acbdc573c774c766>

This change makes things complicated because in order to open multiple maps 
for a specific mvstore version, instead of just passing in the version, I 
need to track the previous version numbers for each map and pass in the 
exact ones I need.

Is this change intentional? If so, is there a recommended way of opening 
all maps that correspond to a specific store version? If you cannot revert 
this behavior, is it possible to add a method to get all available versions 
stored for a map so I don't need to trrack them externally?

You can reproduce with code below.  On 1.4.199, prints:
---
m1.v0=0  1
m1.v1=1  *1*
m1.v2=2  3
---
on 2.2.224
m1.v0=0  1
m1.v1=1  *3*
m1.v2=2  3

Rok
----
package mvstore1;

import org.h2.mvstore.MVMap;
import org.h2.mvstore.MVStore;


public class Mvstore1 {
    public static void main(String[] args) {
        MVStore mvstore=new MVStore.Builder()
                .autoCommitDisabled()
                .open();
        println("mvstore=%d",mvstore.getCurrentVersion());

        MVMap m1=mvstore.openMap("m1");
        m1.put("a",1);
        mvstore.commit();
        println("mvstore=%d 
m1=%d",mvstore.getCurrentVersion(),m1.getVersion());

        MVMap m2=mvstore.openMap("m2");
        m2.put("b",2);
        mvstore.commit();
        println("mvstore=%d m1=%d m2=%d: 
",mvstore.getCurrentVersion(),m1.getVersion(),m2.getVersion());

        m1.put("a",3);
        mvstore.commit();
        println("mvstore=%d m1=%d m2=%d: 
",mvstore.getCurrentVersion(),m1.getVersion(),m2.getVersion());

        printMapVersion(m1,0);
        printMapVersion(m1,1);
        printMapVersion(m1,2);
    }

    private static void println(String m,Object...args) {
        System.out.println(m.formatted(args));
    }

    private static void printMapVersion(MVMap map,long version) {
        MVMap mapv=map.openVersion(version);
        println("m1.v%d=%d  %d",version,mapv.getVersion(),mapv.get("a"));
    }
}

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/4ad75c3c-6b05-41de-9ee2-c2f71da7fd6bn%40googlegroups.com.

Reply via email to