Пример #1
0
 static Map createAndFillMap(Path directory, int numKeys, int numValuesPerKey) throws Exception {
   Options options = new Options();
   options.setCreateIfMissing(true);
   Map map = new Map(DIRECTORY, options);
   fill(map, numKeys, numValuesPerKey);
   return map;
 }
Пример #2
0
 @Test
 public void testMapCtorShouldNotThrow() throws Exception {
   Options options = new Options();
   options.setCreateIfMissing(true);
   Map map = new Map(DIRECTORY, options);
   map.close();
 }
Пример #3
0
  @Test
  public void testIsReadOnly() throws Exception {
    int numKeys = 1000;
    int numValuesPerKeys = 1000;
    Map map = createAndFillMap(DIRECTORY, numKeys, numValuesPerKeys);
    Assert.assertFalse(map.isReadOnly());
    map.close();

    Options options = new Options();
    options.setReadonly(true);
    map = new Map(DIRECTORY, options);
    Assert.assertTrue(map.isReadOnly());
    map.close();
  }
Пример #4
0
  @Test
  public void testImportFromBase64ShouldNotThrow() throws Exception {
    int numKeys = 1000;
    int numValuesPerKeys = 1000;
    writeAsBase64ToFile(DATAFILE, numKeys, numValuesPerKeys);

    Options options = new Options();
    options.setCreateIfMissing(true);
    Map.importFromBase64(DIRECTORY, DATAFILE, options);

    Map map = new Map(DIRECTORY);
    for (int i = 0; i < numKeys; ++i) {
      Iterator iter = map.get(makeKey(i));
      for (int j = 0; j < numValuesPerKeys; ++j) {
        Assert.assertTrue(iter.hasNext());
        Assert.assertEquals(j, getSuffix(iter.next()));
      }
      iter.close();
    }
    map.close();
  }