title: Why won't MapDB work when re-openning database?
body: <p>So I created a database that worked like this:</p>
  
  <pre><code>static class Record implements Serializable
  {
      final String action;
      final String categoryOfAction;
      final String personWhoPerformedAction;
      final Long timeOfOccurrence;
  
      public record(String actn, String cat, String person, Long time)
      {
          action = actn;
          categoryOfAction = cat;
          personWhoPerformedAction = person;
          timeOfOccurence = time;
      }
  
  }
  
  static void main(String[] args)
  {
      DB thedb = DBMaker.newFileDB(new File("D:\\thedb.db")
              .compressionEnable()
              .closeOnJvmShutdown()
              .mmapFileEnableIfSupported()
              .transactionDisable()
              .asyncWriteEnable()
              .make();
  
      //primaryMap maps each record to a unique ID
      BTreeMap&lt;Integer,Record&gt; primaryMap = thedb.createTreeMap("pri")
                                          .keySerializer(BTreeKeySerializer.INTEGER)
                                          .makeOrGet();;
  
      //this map holds the unique ID of every record in primaryMap with a common action
      NavigableSet&lt;Object[]&gt; map_commonAction = thedb.createTreeSet("com_a")
                                          .comparator(Fun.COMPARABLE_ARRAY_COMPARATOR)
                                          .makeOrGet();
  
      //this map holds the unique ID of every record in primaryMap with a common person
      NavigableSet&lt;Object[]&gt; map_commonPerson = thedb.createTreeSet("com_p")
                                          .comparator(Fun.COMPARABLE_ARRAY_COMPARATOR)
                                          .makeOrGet();
  
      //binding map_commonAction to primaryMap so it is updated with primary
      Bind.secondaryKey(primaryMap, map_commonAction, new Fun.Function2&lt;String, Integer, Record&gt;() {
          @Override
          public String run(Integer recordID, Record r) {
              return r.action;
          }
      });
  
      //binding map_commonPerson to primaryMap so it is updated with primary
      Bind.secondaryKey(primaryMap, map_commonPerson, new Fun.Function2&lt;String, Integer, Record&gt;() {
          @Override
          public String run(Integer recordID, Record r) {
              return r.personWhoPerformedAction;
          }
      });
  
  
      //method used to attain all records with some action
      for (Object[] k : Fun.filter(map_commonAction, "someAction"))
      {
          Record obtainedRecord = primary.get(k[1]);
  
      }
  
      //method used to attain all records with some person
      for (Object[] k : Fun.filter(map_commonPerson, "somePerson"))
      {
          Record obtainedRecord = primary.get(k[1]);
  
      }
  
  }
  </code></pre>
  
  <p>After I created it, I inserted 19 billion items. The methods for attaining all records with some action or person worked perfectly. I closed the database, and then I tried running it again, except this time the database was already built and had all the items inserted, so there was no need to insert the 19 billion items. Once I called one of the methods for attaining all records with some action or person, I get this error:</p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.Comparable
      at org.mapdb.Fun$1.compare(Fun.java:31)
      at org.mapdb.BTreeKeySerializer$BasicKeySerializer.compare(BTreeKeySerializer.java:206)
      at org.mapdb.BTreeKeySerializer$BasicKeySerializer.compare(BTreeKeySerializer.java:156)
      at org.mapdb.BTreeKeySerializer.compareIsSmaller(BTreeKeySerializer.java:48)
      at org.mapdb.BTreeKeySerializer.findChildren(BTreeKeySerializer.java:89)
      at org.mapdb.BTreeMap.nextDir(BTreeMap.java:843)
      at org.mapdb.BTreeMap.findLargerNode(BTreeMap.java:1673)
      at org.mapdb.BTreeMap$BTreeIterator.&lt;init&gt;(BTreeMap.java:1068)
      at org.mapdb.BTreeMap$BTreeKeyIterator.&lt;init&gt;(BTreeMap.java:1323)
      at org.mapdb.BTreeMap$SubMap.keyIterator(BTreeMap.java:2483)
      at org.mapdb.BTreeMap$KeySet.iterator(BTreeMap.java:1900)
      at org.mapdb.Fun$12.iterator(Fun.java:369)
      at test.main(test.java:187)
  </code></pre>
  
  <p>So then checked the size of each map</p>
  
  <pre><code>    System.out.println(map_commonAction.size()); //returned correct size: 19billion
      System.out.println(map_commonPerson.size()); //returned correct size: 19billion
      System.out.println(primaryMap.size()); //returned correct size: 19billion
  </code></pre>
  
  <p>So then I checked if the primaryMap even worked, and checked a couple int values, and it returned a record like it should</p>
  
  <pre><code>    Record r1 = primaryMap.get(1);
      Record r2 = primaryMap.get(2);
  
      System.out.println(r1.toString());
      System.out.println(r2.toString());
  </code></pre>
  
  <p>It only fails when I try to iterate through the what is given by Fun.filter(map_common*, "something") but the act of calling it does not make it fail, just trying to iterate through it. I tested it like so:</p>
  
  <pre><code>//this method fails and causes and exception to be thrown
  for (Object[] k : Fun.filter(map_commonPerson, "person"))
      {
          System.out.println(primaryMap.get(k[1]).toString());
      }
  
  //this method doesn't cause an exception to be thrown
  Iterable&lt;Object[]&gt; x = Fun.filter(map_commonPerson, "person");
  </code></pre>
  
  <p>So now I'm stuck, and I have no idea what's wrong with my map. It works perfectly once I've created a new DB and inserted the 19 billion items, but once I close it and try re-openning it for more reading it fails.</p>
  
  <p>Can anyone help? Thanks.</p>