Exemplo n.º 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;
 }
Exemplo n.º 2
0
 @Test
 public void testMapCtorShouldNotThrow() throws Exception {
   Options options = new Options();
   options.setCreateIfMissing(true);
   Map map = new Map(DIRECTORY, options);
   map.close();
 }
Exemplo n.º 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();
  }
Exemplo n.º 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();
  }