Skip to content

custom key serializer is invalid #1062

@654894017

Description

@654894017

jdk21 mapdb_version: 3.1.0

public class TestSerializerLong extends SerializerLong {
    @Override
    public int compare(Long first, Long second) {
        return Long.compare(second, first);
    }
}
public class MapdbTest {
    public static void main(String[] args) {
        DB db = DBMaker.fileDB("file2.db").checksumHeaderBypass().fileMmapEnable().make();
        BTreeMap<Long, Long> map = db.treeMap("map", new TestSerializerLong(), Serializer.LONG).createOrOpen();
        map.put(2L, 2L);
        map.put(1L, 1L);
        map.put(3L, 3L);
        map.put(4L, 4L);
        map.put(-1L, -1L);
        System.out.println(map.firstEntry()); //actual: -1=-1   expect: 4=4
        System.out.println(map.lastEntry());  //actual: 4=4     expect: -1=-1
        db.close();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions