Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/xitdb/array_list.clj
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,13 @@
(-unwrap [this]
wal)

common/IReadOnly
(-read-only [this]
(XITDBArrayList. wal))

Object
(toString [this]
(str "XITDBWriteArrayList")))

(defmethod print-method XITDBWriteArrayList [o ^java.io.Writer w]
(.write w "#XITDBWriteArrayList")
(print-method (into [] (common/-read-only o)) w))
(print-method (into [] (seq o)) w))

;; Constructors

Expand Down
3 changes: 0 additions & 3 deletions src/xitdb/common.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
(defprotocol IUnwrap
(-unwrap [this]))

(defprotocol IReadOnly
(-read-only [this]))

(defn materialize [v]
(cond
(satisfies? IMaterialize v) (-materialize v)
Expand Down
20 changes: 11 additions & 9 deletions src/xitdb/db.clj
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,14 @@
outside of a transaction. Returns a read-only version of the
given writeable data structure."
[x]
(when-not (satisfies? common/IReadOnly x)
(throw (IllegalArgumentException.
(str "freeze! requires a writeable XITDB data structure, got: " (type x)))))
(let [^ReadCursor cursor (-> x common/-unwrap .cursor)
^Database writer (.-db cursor)
^Database reader (db-context/reader-database writer)]
(.freeze writer)
(.flush ^Core (.-core writer))
(xtypes/read-from-cursor (ReadCursor. (.-slotPtr cursor) reader) false)))
(let [^ReadCursor cursor (when (common/wrapper? x)
(-> x common/-unwrap .cursor))]
(when-not (instance? WriteCursor cursor)
(throw (IllegalArgumentException.
(str "freeze! requires a writeable XITDB data structure, got: " (type x)))))
(let [^Database writer (.-db cursor)
^Database reader (db-context/reader-database writer)]
(.freeze writer)
(.flush ^Core (.-core writer))
;; rebuild on the reader handle so the value can be shared across threads
(xtypes/read-from-cursor (ReadCursor. (.-slotPtr cursor) reader) false))))
6 changes: 1 addition & 5 deletions src/xitdb/hash_map.clj
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,13 @@
(-unwrap [this]
whm)

common/IReadOnly
(-read-only [this]
(XITDBHashMap. whm))

Object
(toString [this]
(str "XITDBWriteHashMap")))

(defmethod print-method XITDBWriteHashMap [o ^java.io.Writer w]
(.write w "#XITDBWriteHashMap")
(print-method (into {} (common/-read-only o)) w))
(print-method (into {} (seq o)) w))

(defn xwrite-hash-map [^WriteCursor write-cursor]
(->XITDBWriteHashMap (WriteHashMap. write-cursor)))
Expand Down
6 changes: 1 addition & 5 deletions src/xitdb/hash_set.clj
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,13 @@
(-unwrap [_]
whs)

common/IReadOnly
(-read-only [this]
(XITDBHashSet. whs))

Object
(toString [_]
(str "XITDBWriteHashSet")))

(defmethod print-method XITDBWriteHashSet [o ^java.io.Writer w]
(.write w "#XITDBWriteHashSet")
(print-method (into #{} (common/-read-only o)) w))
(print-method (into #{} (seq o)) w))

;; Constructor functions
(defn xwrite-hash-set [^WriteCursor write-cursor]
Expand Down
6 changes: 1 addition & 5 deletions src/xitdb/linked_list.clj
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,13 @@
(-unwrap [this]
wlal)

common/IReadOnly
(-read-only [this]
(XITDBLinkedArrayList. wlal))

Object
(toString [this]
(str "XITDBWriteLinkedArrayList")))

(defmethod print-method XITDBWriteLinkedArrayList [o ^java.io.Writer w]
(.write w "#XITDBWriteLinkedArrayList")
(print-method (into [] (common/-read-only o)) w))
(print-method (into [] (seq o)) w))

;; Constructors

Expand Down
6 changes: 1 addition & 5 deletions src/xitdb/sorted_map.clj
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,13 @@
(-unwrap [this]
wsm)

common/IReadOnly
(-read-only [this]
(XITDBSortedMap. wsm))

Object
(toString [this]
(str "XITDBWriteSortedMap")))

(defmethod print-method XITDBWriteSortedMap [o ^java.io.Writer w]
(.write w "#XITDBWriteSortedMap")
(print-method (into (sorted-map-by sorted-key/key-comparator) (common/-read-only o)) w))
(print-method (into (sorted-map-by sorted-key/key-comparator) (seq o)) w))

(defn xwrite-sorted-map [^WriteCursor write-cursor]
(->XITDBWriteSortedMap (WriteSortedMap. write-cursor)))
Expand Down
6 changes: 1 addition & 5 deletions src/xitdb/sorted_set.clj
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,13 @@
(-unwrap [_]
wss)

common/IReadOnly
(-read-only [this]
(XITDBSortedSet. wss))

Object
(toString [_]
(str "XITDBWriteSortedSet")))

(defmethod print-method XITDBWriteSortedSet [o ^java.io.Writer w]
(.write w "#XITDBWriteSortedSet")
(print-method (into (sorted-set-by sorted-key/key-comparator) (common/-read-only o)) w))
(print-method (into (sorted-set-by sorted-key/key-comparator) (seq o)) w))

;; Constructor functions
(defn xwrite-sorted-set [^WriteCursor write-cursor]
Expand Down
Loading