public void close()

in src/main/java/com/spotify/sparkey/ReadWriteMemMap.java [117:141]


  public void close() throws IOException {
    if (closed) {
      return;
    }
    closed = true;
    randomAccessFile.seek(0);
    randomAccessFile.write(header.asBytes());
    if (fsync) {
      randomAccessFile.getFD().sync();
    }
    randomAccessFile.close();
    final MappedByteBuffer[] chunks = this.chunks;
    this.chunks = null;
    curChunk = null;
    Sparkey.decrOpenFiles();
    Util.nonThrowingClose(randomAccessFile);

    // Clean it up immediately since this should only be used from a single thread anyway
    Sparkey.decrOpenMaps();
    for (int i = 0; i < chunks.length; i++) {
      final MappedByteBuffer byteBuffer = chunks[i];
      chunks[i] = null;
      ByteBufferCleaner.cleanMapping(byteBuffer);
    }
  }