<commit_before>package viscel.database

import com.typesafe.scalalogging.slf4j.StrictLogging
import org.neo4j.cypher.ExecutionEngine
import org.neo4j.graphdb.factory.{GraphDatabaseFactory, GraphDatabaseSettings}
import org.neo4j.graphdb.{GraphDatabaseService, Label, Node}
import org.neo4j.helpers.Settings
import org.neo4j.tooling.GlobalGraphOperations
import viscel.time

import scala.collection.JavaConverters._
import scala.collection.Map


trait Neo {
	def tx[R](f: Ntx => R): R
	def txt[R](desc: => String)(f: Ntx => R): R
	def txs[R](f: => R): R
	def txts[R](desc: => String)(f: => R): R
}

trait Ntx {
	def db: GraphDatabaseService

	def node(label: Label, property: String, value: Any, logTime: Boolean = true): Option[Node]
	def nodes(label: Label): List[Node]

	def create(label: Label, attributes: (String, Any)*): Node
	def create(label: Label, attributes: Map[String, Any]): Node

	def delete(node: Node): Unit
}


object NeoSingleton extends Neo with Ntx with StrictLogging {
	val db: GraphDatabaseService = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder("neoViscelStore")
		.setConfig(GraphDatabaseSettings.keep_logical_logs, Settings.FALSE).newGraphDatabase()

	val ee: ExecutionEngine = new ExecutionEngine(db)

	def execute(query: String, args: (String, Any)*) = ee.execute(Predef.wrapString(query).stripMargin.trim, args.toMap[String, Any])

	def apply(q: String) = execute(q).dumpToString()

	def shutdown(): Unit = {
		txt("export") { ArchiveExport.exportAll(_) }
		db.shutdown()
	}
<commit_msg>disable neo export on shutdown<commit_after>package viscel.database

import com.typesafe.scalalogging.slf4j.StrictLogging
import org.neo4j.cypher.ExecutionEngine
import org.neo4j.graphdb.factory.{GraphDatabaseFactory, GraphDatabaseSettings}
import org.neo4j.graphdb.{GraphDatabaseService, Label, Node}
import org.neo4j.helpers.Settings
import org.neo4j.tooling.GlobalGraphOperations
import viscel.time

import scala.collection.JavaConverters._
import scala.collection.Map


trait Neo {
	def tx[R](f: Ntx => R): R
	def txt[R](desc: => String)(f: Ntx => R): R
	def txs[R](f: => R): R
	def txts[R](desc: => String)(f: => R): R
}

trait Ntx {
	def db: GraphDatabaseService

	def node(label: Label, property: String, value: Any, logTime: Boolean = true): Option[Node]
	def nodes(label: Label): List[Node]

	def create(label: Label, attributes: (String, Any)*): Node
	def create(label: Label, attributes: Map[String, Any]): Node

	def delete(node: Node): Unit
}


object NeoSingleton extends Neo with Ntx with StrictLogging {
	val db: GraphDatabaseService = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder("neoViscelStore")
		.setConfig(GraphDatabaseSettings.keep_logical_logs, Settings.FALSE).newGraphDatabase()

	val ee: ExecutionEngine = new ExecutionEngine(db)

	def execute(query: String, args: (String, Any)*) = ee.execute(Predef.wrapString(query).stripMargin.trim, args.toMap[String, Any])

	def apply(q: String) = execute(q).dumpToString()

	def shutdown(): Unit = {
		//txt("export") { ArchiveExport.exportAll(_) }
		db.shutdown()
	}

{'fraction_non_alphanumeric': 0.13042060645582002, 'fraction_numerical': 0.0039126181936746, 'mean_word_length': 5.89438202247191, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '2259729', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1017, 'n_words': 248}