From c879960a9849ef73638ba60dfe016f056aeb2c69 Mon Sep 17 00:00:00 2001 From: Tristan Nelson Date: Thu, 15 Aug 2024 10:51:40 -0400 Subject: [PATCH] Apply fix for Jena bug https://github.com/apache/jena/issues/2584 --- src/genegraph/gene_validity.clj | 11 ++++++--- src/genegraph/notebooks.clj | 2 +- src/genegraph/user.clj | 44 ++++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/genegraph/gene_validity.clj b/src/genegraph/gene_validity.clj index 22d488d..45c10e9 100644 --- a/src/genegraph/gene_validity.clj +++ b/src/genegraph/gene_validity.clj @@ -521,13 +521,18 @@ (defn gv-ready-fn [e] (let [tdb (get-in e [::storage/storage :gv-tdb]) type-count (fn [t] - (count (type-query tdb {:type t})))] - (rdf/tx tdb + (count (type-query tdb {:type t}))) + in-tx (.isInTransaction tdb)] + (try + (when-not in-tx + (.begin tdb ReadWrite/READ)) (let [gv-count (type-count :sepio/GeneValidityEvidenceLevelAssertion) ac-count (type-count :sepio/ActionabilityReport) gd-count (type-count :sepio/GeneDosageReport)] - (log/info :fn ::gv-ready-fn + (.commit tdb) ; https://github.com/apache/jena/issues/2584 + (.end tdb) + #_(log/info :fn ::gv-ready-fn :gv-count gv-count :ac-count ac-count :gd-count gd-count) diff --git a/src/genegraph/notebooks.clj b/src/genegraph/notebooks.clj index c482544..adae4e7 100644 --- a/src/genegraph/notebooks.clj +++ b/src/genegraph/notebooks.clj @@ -13,7 +13,7 @@ (assoc gv/gv-tdb :snapshot-handle {:type :file :base "/Users/tristan/code/genegraph-gene-validity/data/" - :path "gv-tdb-v11.nq.gz"})}}) + :path "gv-tdb-v12.nq.gz"})}}) (comment diff --git a/src/genegraph/user.clj b/src/genegraph/user.clj index 51f3466..9aa4d80 100644 --- a/src/genegraph/user.clj +++ b/src/genegraph/user.clj @@ -118,7 +118,32 @@ (def gv-test-app (p/init gv-test-app-def)) (p/start gv-test-app) (p/stop gv-test-app) + + (time + (let [c (hc/build-http-client {}) + lock (Semaphore. 10)] + (dotimes [n 10000] + (.acquire lock) + (Thread/startVirtualThread + (fn [] + (hc/get "http://localhost:8888/ready") + (.release lock)))))) + (time + (let [c (hc/build-http-client {}) + lock (Semaphore. 10) + db @(get-in gv-test-app [:storage :gv-tdb :instance])] + (dotimes [n 100000] + (.acquire lock) + (Thread/startVirtualThread + (fn [] + (try + (let [db @(get-in gv-test-app [:storage :gv-tdb :instance])] + (gv/gv-ready-fn {::storage/storage {:gv-tdb db}})) + (finally (.release lock)))))))) + + (let [db @(get-in gv-test-app [:storage :gv-tdb :instance])] + (gv/gv-ready-fn {::storage/storage {:gv-tdb db}})) ) ;; Downloading events @@ -1299,10 +1324,27 @@ select ?x where { ::event/skip-local-effects true ::event/skip-publish-effects true))) + + (let [tdb @(get-in gv-test-app [:storage :gv-tdb :instance])] + (rdf/tx tdb + (let [r (rdf/resource "CGGV:fe942eb4-ba59-43bf-89e0-243522ba7cbf" + tdb)] + (rdf/pp-model (storage/read tdb (str r)))))) + (-> dnase1 last - process-gv-event + process-gv-event :gene-validity/model rdf/pp-model) ) + + +(comment + (time + (let [tdb @(get-in gv-test-app [:storage :gv-tdb :instance])] + (dotimes [n 100000] + (rdf/tx tdb + (+ 1 1))))) + + )