예제 #1
0
 public BSkipList makeIndex(String name, Serializer key, Serializer val) throws IOException {
   if (metaIndex.get(name) != null) {
     throw new IOException("Index already exists");
   }
   int page = allocPage();
   metaIndex.put(name, Integer.valueOf(page));
   BSkipList.init(this, page, spanSize);
   BSkipList bsl = new BSkipList(spanSize, this, page, key, val, true);
   openIndices.put(name, bsl);
   return bsl;
 }
예제 #2
0
  /** If the file is writable, this runs an integrity check and repair on first open. */
  public BSkipList getIndex(String name, Serializer key, Serializer val) throws IOException {
    // added I2P
    BSkipList bsl = (BSkipList) openIndices.get(name);
    if (bsl != null) return bsl;

    Integer page = (Integer) metaIndex.get(name);
    if (page == null) {
      return null;
    }
    bsl = new BSkipList(spanSize, this, page.intValue(), key, val, true);
    if (file.canWrite()) {
      log.info("Checking skiplist " + name + " in blockfile " + file);
      if (bsl.bslck(true, false))
        log.logAlways(Log.WARN, "Repaired skiplist " + name + " in blockfile " + file);
      else log.info("No errors in skiplist " + name + " in blockfile " + file);
    }
    openIndices.put(name, bsl);
    return bsl;
  }