|
95 | 95 | Throws IllegalArgumentException if attempting to associate an internal key.
|
96 | 96 | Updates the internal count if fast counting is enabled."
|
97 | 97 | [^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)] |
101 | 101 | (.writeIfEmpty key-cursor (conversion/v->slot! key-cursor k))
|
102 | 102 | (.write cursor (conversion/v->slot! cursor v))))
|
103 | 103 |
|
|
106 | 106 | Throws IllegalArgumentException if attempting to remove an internal key.
|
107 | 107 | Updates the internal count if fast counting is enabled."
|
108 | 108 | [^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)) |
111 | 111 | whm)
|
112 | 112 |
|
113 | 113 | (defn ^WriteHashMap map-empty!
|
|
122 | 122 | "Checks if a WriteHashMap contains the specified key.
|
123 | 123 | Returns true if the key exists, false otherwise."
|
124 | 124 | [^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))))) |
127 | 127 |
|
128 | 128 | (defn map-item-count-iterated
|
129 | 129 | "Returns the number of keys in the map by iterating.
|
|
148 | 148 | "Gets a read cursor for the specified key in a ReadHashMap.
|
149 | 149 | Returns the cursor if the key exists, nil otherwise."
|
150 | 150 | [^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))) |
153 | 153 |
|
154 | 154 |
|
155 | 155 | (defn map-write-cursor
|
156 | 156 | "Gets a write cursor for the specified key in a WriteHashMap.
|
157 | 157 | Creates the key if it doesn't exist."
|
158 | 158 | [^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))) |
161 | 161 |
|
162 | 162 | ;; ============================================================================
|
163 | 163 | ;; Set Operations
|
|
174 | 174 | "Adds a value to a set."
|
175 | 175 | [^WriteHashSet whs v]
|
176 | 176 | (let [hash-code (conversion/db-key-hash (-> whs .cursor .db) v)
|
177 |
| - cursor (.putCursor whs hash-code)] |
| 177 | + cursor (.putCursor whs hash-code)] |
178 | 178 | (.writeIfEmpty cursor (conversion/v->slot! cursor v))
|
179 | 179 | whs))
|
180 | 180 |
|
|
189 | 189 | "Returns true if `v` is in the set."
|
190 | 190 | [rhs v]
|
191 | 191 | (let [hash-code (conversion/db-key-hash (-> rhs .-cursor .-db) v)
|
192 |
| - cursor (.getCursor rhs hash-code)] |
| 192 | + cursor (.getCursor rhs hash-code)] |
193 | 193 | (some? cursor)))
|
194 | 194 |
|
195 | 195 | (defn ^WriteHashMap set-empty!
|
|
235 | 235 | Uses the provided read-from-cursor function to convert cursors to values.
|
236 | 236 | Returns a lazy sequence of the array elements."
|
237 | 237 | [^ReadArrayList ral read-from-cursor]
|
238 |
| - (let [iter (.iterator ral) |
| 238 | + (let [iter (.iterator ral) |
239 | 239 | lazy-iter (fn lazy-iter []
|
240 | 240 | (when (.hasNext iter)
|
241 | 241 | (let [cursor (.next iter)
|
242 |
| - value (read-from-cursor cursor)] |
| 242 | + value (read-from-cursor cursor)] |
243 | 243 | (lazy-seq (cons value (lazy-iter))))))]
|
244 | 244 | (lazy-iter)))
|
245 | 245 |
|
|
248 | 248 | Uses the provided read-from-cursor function to convert cursors to values.
|
249 | 249 | Returns a lazy sequence of the linked array elements."
|
250 | 250 | [^ReadLinkedArrayList rlal read-from-cursor]
|
251 |
| - (let [iter (.iterator rlal) |
| 251 | + (let [iter (.iterator rlal) |
252 | 252 | lazy-iter (fn lazy-iter []
|
253 | 253 | (when (.hasNext iter)
|
254 | 254 | (let [cursor (.next iter)
|
255 |
| - value (read-from-cursor cursor)] |
| 255 | + value (read-from-cursor cursor)] |
256 | 256 | (lazy-seq (cons value (lazy-iter))))))]
|
257 | 257 | (lazy-iter)))
|
258 | 258 |
|
|
265 | 265 | (let [cursor (.next it)
|
266 | 266 | kv (.readKeyValuePair cursor)
|
267 | 267 | k (read-from-cursor (.-keyCursor kv))]
|
268 |
| - (let [v (read-from-cursor (.-valueCursor kv)) |
| 268 | + (let [v (read-from-cursor (.-valueCursor kv)) |
269 | 269 | new-result (f result k v)]
|
270 | 270 | (if (reduced? new-result)
|
271 | 271 | @new-result
|
|
277 | 277 | "Efficiently reduces over index-value pairs in a ReadArrayList."
|
278 | 278 | [^ReadArrayList ral read-from-cursor f init]
|
279 | 279 | (let [count (.count ral)]
|
280 |
| - (loop [i 0 |
| 280 | + (loop [i 0 |
281 | 281 | result init]
|
282 | 282 | (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) |
285 | 285 | new-result (f result i v)]
|
286 | 286 | (if (reduced? new-result)
|
287 | 287 | @new-result
|
|
0 commit comments