@Test
public void testReindex() {

    ixMap = xodus.createIxMap("testReindex",
            ImmutableMap.of(
                    "len", IxMapTest::stringLen,
                    "lower", s -> Key.keys(Key.of(s.toLowerCase()))),
            CoderFactory.makeCoder(String.class));
    Set<String> dbNames = new HashSet<>(rtx(tx -> xodus.getEnv().getAllStoreNames((Transaction) tx.txn())));
    assertTrue(dbNames.containsAll(Sets.newHashSet("testReindex-idx-lower", "testReindex-idx-len", "testReindex-main")));
    wtx0(tx -> ixMap.put(tx, Key.of(1L), "aa"));
    wtx0(tx -> ixMap.put(tx, Key.of(2L), "aBa"));
    assertEquals(ImmutableMap.of(Key.of(1L), "aa"), xodus.readTx(tx -> ixMap.getByIndex("len", tx, intKey(2))));
    assertEquals(ImmutableMap.of(Key.of(2L), "aBa"), xodus.readTx(tx -> ixMap.getByIndex("len", tx, intKey(3))));
    assertEquals(ImmutableMap.of(Key.of(2L), "aBa"), xodus.readTx(tx -> ixMap.getByIndex("lower", tx, Key.of("aba"))));
    ixMap = xodus.createIxMap("testReindex",
            ImmutableMap.of(
                    "lenPlus1", s -> Key.keys(intKey(s.length() + 1)),
                    "lower", s -> Key.keys(Key.of(s.toLowerCase()))),
            CoderFactory.makeCoder(String.class));
    Set<String> dbNames1 = new HashSet<>(rtx(tx -> xodus.getEnv().getAllStoreNames((Transaction) tx.txn())));
    assertTrue(dbNames1.containsAll(Sets.newHashSet("testReindex-idx-lower", "testReindex-idx-lenPlus1", "testReindex-main")));
    assertFalse(dbNames1.contains("testReindex-idx-len"));
    assertEquals(Optional.of("aa"), xodus.readTx(tx -> ixMap.get(tx, Key.of(1L))));
    assertEquals(Optional.of("aBa"), xodus.readTx(tx -> ixMap.get(tx, Key.of(2L))));
    assertEquals(ImmutableMap.of(), xodus.readTx(tx -> ixMap.getByIndex("len", tx, intKey(2))));
    assertEquals(ImmutableMap.of(Key.of(1L), "aa"), xodus.readTx(tx -> ixMap.getByIndex("lenPlus1", tx, intKey(3))));
    assertEquals(ImmutableMap.of(Key.of(2L), "aBa"), xodus.readTx(tx -> ixMap.getByIndex("lenPlus1", tx, intKey(4))));
    assertEquals(ImmutableMap.of(Key.of(2L), "aBa"), xodus.readTx(tx -> ixMap.getByIndex("lower", tx, Key.of("aba"))));
}