Skip to content

Commit 53eae3e

Browse files
committed
Use key-hash instead of hash-value
1 parent 909e138 commit 53eae3e

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/xitdb/util/operations.clj

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@
9595
Throws IllegalArgumentException if attempting to associate an internal key.
9696
Updates the internal count if fast counting is enabled."
9797
[^WriteHashMap whm k v]
98-
(let [hash-value (conversion/db-key-hash (-> whm .cursor .db) k)
99-
key-cursor (.putKeyCursor whm hash-value)
100-
cursor (.putCursor whm hash-value)]
98+
(let [key-hash (conversion/db-key-hash (-> whm .cursor .db) k)
99+
key-cursor (.putKeyCursor whm key-hash)
100+
cursor (.putCursor whm key-hash)]
101101
(.writeIfEmpty key-cursor (conversion/v->slot! key-cursor k))
102102
(.write cursor (conversion/v->slot! cursor v))))
103103

@@ -106,8 +106,8 @@
106106
Throws IllegalArgumentException if attempting to remove an internal key.
107107
Updates the internal count if fast counting is enabled."
108108
[^WriteHashMap whm k]
109-
(let [hash-value (conversion/db-key-hash (-> whm .cursor .db) k)]
110-
(.remove whm hash-value))
109+
(let [key-hash (conversion/db-key-hash (-> whm .cursor .db) k)]
110+
(.remove whm key-hash))
111111
whm)
112112

113113
(defn ^WriteHashMap map-empty!
@@ -122,8 +122,8 @@
122122
"Checks if a WriteHashMap contains the specified key.
123123
Returns true if the key exists, false otherwise."
124124
[^ReadHashMap whm key]
125-
(let [hash-value (conversion/db-key-hash (-> whm .cursor .db) key)]
126-
(not (nil? (.getKeyCursor whm hash-value)))))
125+
(let [key-hash (conversion/db-key-hash (-> whm .cursor .db) key)]
126+
(not (nil? (.getKeyCursor whm key-hash)))))
127127

128128
(defn map-item-count-iterated
129129
"Returns the number of keys in the map by iterating.
@@ -148,16 +148,16 @@
148148
"Gets a read cursor for the specified key in a ReadHashMap.
149149
Returns the cursor if the key exists, nil otherwise."
150150
[^ReadHashMap rhm key]
151-
(let [hash-value (conversion/db-key-hash (-> rhm .cursor .db) key)]
152-
(.getCursor rhm hash-value)))
151+
(let [key-hash (conversion/db-key-hash (-> rhm .cursor .db) key)]
152+
(.getCursor rhm key-hash)))
153153

154154

155155
(defn map-write-cursor
156156
"Gets a write cursor for the specified key in a WriteHashMap.
157157
Creates the key if it doesn't exist."
158158
[^WriteHashMap whm key]
159-
(let [hash-value (conversion/db-key-hash (-> whm .cursor .db) key)]
160-
(.putCursor whm hash-value)))
159+
(let [key-hash (conversion/db-key-hash (-> whm .cursor .db) key)]
160+
(.putCursor whm key-hash)))
161161

162162
;; ============================================================================
163163
;; Set Operations
@@ -174,7 +174,7 @@
174174
"Adds a value to a set."
175175
[^WriteHashSet whs v]
176176
(let [hash-code (conversion/db-key-hash (-> whs .cursor .db) v)
177-
cursor (.putCursor whs hash-code)]
177+
cursor (.putCursor whs hash-code)]
178178
(.writeIfEmpty cursor (conversion/v->slot! cursor v))
179179
whs))
180180

@@ -189,7 +189,7 @@
189189
"Returns true if `v` is in the set."
190190
[rhs v]
191191
(let [hash-code (conversion/db-key-hash (-> rhs .-cursor .-db) v)
192-
cursor (.getCursor rhs hash-code)]
192+
cursor (.getCursor rhs hash-code)]
193193
(some? cursor)))
194194

195195
(defn ^WriteHashMap set-empty!
@@ -235,11 +235,11 @@
235235
Uses the provided read-from-cursor function to convert cursors to values.
236236
Returns a lazy sequence of the array elements."
237237
[^ReadArrayList ral read-from-cursor]
238-
(let [iter (.iterator ral)
238+
(let [iter (.iterator ral)
239239
lazy-iter (fn lazy-iter []
240240
(when (.hasNext iter)
241241
(let [cursor (.next iter)
242-
value (read-from-cursor cursor)]
242+
value (read-from-cursor cursor)]
243243
(lazy-seq (cons value (lazy-iter))))))]
244244
(lazy-iter)))
245245

@@ -248,11 +248,11 @@
248248
Uses the provided read-from-cursor function to convert cursors to values.
249249
Returns a lazy sequence of the linked array elements."
250250
[^ReadLinkedArrayList rlal read-from-cursor]
251-
(let [iter (.iterator rlal)
251+
(let [iter (.iterator rlal)
252252
lazy-iter (fn lazy-iter []
253253
(when (.hasNext iter)
254254
(let [cursor (.next iter)
255-
value (read-from-cursor cursor)]
255+
value (read-from-cursor cursor)]
256256
(lazy-seq (cons value (lazy-iter))))))]
257257
(lazy-iter)))
258258

@@ -265,7 +265,7 @@
265265
(let [cursor (.next it)
266266
kv (.readKeyValuePair cursor)
267267
k (read-from-cursor (.-keyCursor kv))]
268-
(let [v (read-from-cursor (.-valueCursor kv))
268+
(let [v (read-from-cursor (.-valueCursor kv))
269269
new-result (f result k v)]
270270
(if (reduced? new-result)
271271
@new-result
@@ -277,11 +277,11 @@
277277
"Efficiently reduces over index-value pairs in a ReadArrayList."
278278
[^ReadArrayList ral read-from-cursor f init]
279279
(let [count (.count ral)]
280-
(loop [i 0
280+
(loop [i 0
281281
result init]
282282
(if (< i count)
283-
(let [cursor (.getCursor ral i)
284-
v (read-from-cursor cursor)
283+
(let [cursor (.getCursor ral i)
284+
v (read-from-cursor cursor)
285285
new-result (f result i v)]
286286
(if (reduced? new-result)
287287
@new-result

0 commit comments

Comments
 (0)