<commit_before>(ns clojurewerkz.cassaforte.embedded
  (:require [clojure.java.io :as io])
  (:import [org.apache.cassandra.service CassandraDaemon]
           [org.apache.cassandra.config DatabaseDescriptor]))

(defn delete-file
  "Delete file f. Raise an exception if it fails unless silently is true."
  [f & [silently]]
  (or (.delete (io/file f))
      silently
      (throw (java.io.IOException. (str "Couldn't delete " f)))))

(defn delete-file-recursively
  "Delete file f. If it's a directory, recursively delete all its contents.
Raise an exception if any deletion fails unless silently is true."
  [f & [silently]]
  (let [f (io/file f)]
    (if (.isDirectory f)
      (doseq [child (.listFiles f)]
        (delete-file-recursively child silently)))
    (delete-file f silently)))

(declare daemon)

(defn start-server!
  []
  (System/setProperty "cassandra.config" (str (io/resource "cassandra.yaml")))
  (System/setProperty "java.version" "1.7.0_15") ;; WTF
  (System/setProperty "cassandra-foreground" "yes")
  (System/setProperty "log4j.defaultInitOverride" "false")
  (System/setProperty "log4j.appender.R.File" "/var/log/cassandra/system.log")

  (when-not (bound? (var daemon))
    (if (.exists (io/file "tmp"))
      (delete-file-recursively "tmp"))<commit_msg>Add justification comment for java version manipulation<commit_after>(ns clojurewerkz.cassaforte.embedded
  (:require [clojure.java.io :as io])
  (:import [org.apache.cassandra.service CassandraDaemon]
           [org.apache.cassandra.config DatabaseDescriptor]))

(defn delete-file
  "Delete file f. Raise an exception if it fails unless silently is true."
  [f & [silently]]
  (or (.delete (io/file f))
      silently
      (throw (java.io.IOException. (str "Couldn't delete " f)))))

(defn delete-file-recursively
  "Delete file f. If it's a directory, recursively delete all its contents.
Raise an exception if any deletion fails unless silently is true."
  [f & [silently]]
  (let [f (io/file f)]
    (if (.isDirectory f)
      (doseq [child (.listFiles f)]
        (delete-file-recursively child silently)))
    (delete-file f silently)))

(declare daemon)

(defn start-server!
  []
  (System/setProperty "cassandra.config" (str (io/resource "cassandra.yaml")))
  ;; If you're running Cassandra on Mac Os X on 1.7, you'll get in trouble with parsing version, because
  ;; "1.7.0_06-ea" ea doesn't parse as int. That's a workaround
  (System/setProperty "java.version" "1.7.0_15")
  (System/setProperty "cassandra-foreground" "yes")
  (System/setProperty "log4j.defaultInitOverride" "false")
  (System/setProperty "log4j.appender.R.File" "/var/log/cassandra/system.log")

  (when-not (bound? (var daemon))
    (if (.exists (io/file "tmp"))
      (delete-file-recursively "tmp"))
{'fraction_non_alphanumeric': 0.14228819695872555, 'fraction_numerical': 0.007603186097031137, 'mean_word_length': 3.8219895287958114, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '407939', 'n_tokens_mistral': 967, 'n_tokens_neox': 923, 'n_words': 261}