Skip to content

Commit

Permalink
Adapt code to API changes in IGNITE-21669 (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahitrin authored Apr 4, 2024
1 parent 73ccdce commit 821e782
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
22 changes: 9 additions & 13 deletions ignite-3/src/jepsen/ignite3/append.clj
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

(defn run-sql
"Run a SQL query. Return ResultSet instance that should be closed afterwards."
([session query params] (run-sql session nil query params))
([session txn query params]
([sql query params] (run-sql sql nil query params))
([sql txn query params]
(log/info query params)
(.execute session txn query (object-array params))))
(.execute sql txn query (object-array params))))

(defn as-int-list [s]
"Convert a string representation of integers into an actual list of integers.
Expand All @@ -57,22 +57,20 @@
Accessor
;
(read! [this ignite txn [opcode k v]]
(let [r (with-open [session (.createSession (.sql ignite))
rs (run-sql session txn sql-select [k])]
(let [r (with-open [rs (run-sql (.sql ignite) txn sql-select [k])]
(let [s (if (.hasNext rs) (.stringValue (.next rs) 1) "")]
(as-int-list s)))]
[:r k r]))
;
(append! [this ignite txn [opcode k v]]
(with-open [session (.createSession (.sql ignite))
read-rs (run-sql session txn sql-select [k])]
(with-open [read-rs (run-sql (.sql ignite) txn sql-select [k])]
(if (.hasNext read-rs)
; update existing list
(let [old-list (.stringValue (.next read-rs) 1)
new-list (str old-list "," v)]
(with-open [write-rs (run-sql session txn sql-update [new-list k])]))
(with-open [write-rs (run-sql (.sql ignite) txn sql-update [new-list k])]))
; create a new list
(with-open [write-rs (run-sql session txn sql-insert [k (str v)])]))
(with-open [write-rs (run-sql (.sql ignite) txn sql-insert [k (str v)])]))
[opcode k v])))

; ---------- KV Access ----------
Expand Down Expand Up @@ -114,8 +112,7 @@

(defn print-table-content [ignite]
"Save resulting table content in the log."
(with-open [session (.createSession (.sql ignite))
rs (run-sql session sql-select-all [])]
(with-open [rs (run-sql (.sql ignite) sql-select-all [])]
(log/info "Table content")
(while (.hasNext rs)
(let [row (.next rs)]
Expand All @@ -133,8 +130,7 @@
;
(setup! [this test]
(with-open [create-stmt (.createStatement (.sql ignite) sql-create)
session (.createSession (.sql ignite))
rs (run-sql session create-stmt [])]
rs (run-sql (.sql ignite) create-stmt [])]
(log/info "Table" table-name "created")))
;
(invoke! [this test op]
Expand Down
3 changes: 1 addition & 2 deletions ignite-3/src/jepsen/ignite3/register.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
(log/info "Node: " node)
(let [ignite (.build (.addresses (IgniteClient/builder) (into-array [(str node ":10800")])))
create-stmt (.createStatement (.sql ignite) sql-create)]
(with-open [session (.createSession (.sql ignite))
rs (.execute session nil create-stmt (into-array []))]
(with-open [rs (.execute (.sql ignite) nil create-stmt (into-array []))]
(log/info "Table" table-name "created"))
(assoc this :ignite ignite)))
Expand Down

0 comments on commit 821e782

Please sign in to comment.