public void writeHash()

in src/main/java/com/spotify/sparkey/SingleThreadedSparkeyWriter.java [89:108]


  public void writeHash() throws IOException {
    flush();

    File parentFile = indexFile.getCanonicalFile().getParentFile();
    File newFile = new File(parentFile, indexFile.getName() + "-tmp" + UUID.randomUUID().toString());
    try {
      int hashSeed = this.hashSeed;
      if (hashSeed == 0) {
        hashSeed = new Random().nextInt();
      }
      long maxMemory = this.maxMemory;
      if (maxMemory < 0) {
        maxMemory = Runtime.getRuntime().freeMemory() / 2;
      }
      IndexHash.createNew(newFile, logFile, hashType, sparsity, fsync, hashSeed, Math.max(maxMemory, 10*1024*1024L), method);
      Util.renameFile(newFile, indexFile);
    } finally {
      boolean deleted = newFile.delete();
    }
  }