Skip to content

Commit b4c6c8a

Browse files
committed
add slot function and make it work with read-only types
1 parent 230e581 commit b4c6c8a

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed

src/xitdb/array_list.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@
106106
(aset result len nil))
107107
result))
108108

109+
common/ISlot
110+
(-slot [this]
111+
(-> ral .cursor .slot))
112+
109113
common/IUnwrap
110114
(-unwrap [this]
111115
ral)

src/xitdb/db.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
(common/-slot v)
6363
(conversion/v->slot! cursor v)))
6464

65+
(def slot common/-slot)
66+
6567
(defn xitdb-swap!
6668
"Starts a new transaction and calls `f` with the value at `base-keypath`.
6769
If `base-keypath` is nil, will use the root cursor.

src/xitdb/hash_map.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@
8181
(kv-reduce [this f init]
8282
(operations/map-kv-reduce rhm #(common/-read-from-cursor %) f init))
8383

84+
common/ISlot
85+
(-slot [this]
86+
(-> rhm .cursor .slot))
87+
8488
common/IUnwrap
8589
(-unwrap [this]
8690
rhm)

src/xitdb/hash_set.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
(remove [_]
6969
(throw (UnsupportedOperationException. "XITDBHashSet iterator is read-only"))))))
7070

71+
common/ISlot
72+
(-slot [this]
73+
(-> rhs .cursor .slot))
74+
7175
common/IUnwrap
7276
(-unwrap [_]
7377
rhs)

src/xitdb/linked_list.clj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@
8686
(aset result len nil))
8787
result))
8888

89+
common/ISlot
90+
(-slot [this]
91+
(-> rlal .cursor .slot))
92+
93+
common/IUnwrap
94+
(-unwrap [_]
95+
rlal)
96+
8997
Object
9098
(toString [this]
9199
(pr-str (into [] this))))

src/xitdb/util/conversion.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@
103103
[v]
104104
(cond
105105

106+
(or (nil? v) (instance? Slot v))
107+
v
108+
106109
(string? v)
107110
(database-bytes v)
108111

@@ -118,9 +121,6 @@
118121
(double? v)
119122
(Database$Float. v)
120123

121-
(nil? v)
122-
nil
123-
124124
(instance? java.time.Instant v)
125125
(database-bytes (str v) (fmt-tag-value :inst))
126126

0 commit comments

Comments
 (0)