Skip to content

Commit 5d48edd

Browse files
committed
Use consistent return types
1 parent 8de4ba3 commit 5d48edd

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

CLAUDE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Development Commands
6+
7+
### Running Tests
8+
```bash
9+
clj -M:test
10+
```
11+
12+
### Running a Single Test File
13+
```bash
14+
clj -M:test -n xitdb.database-test
15+
```
16+
17+
### REPL Development
18+
```bash
19+
clj
20+
```
21+
22+
## Architecture Overview
23+
24+
This is a Clojure wrapper around the xitdb-java immutable database, providing atom-like semantics for persistent data structures.
25+
26+
### Core Components
27+
28+
- **xitdb.db**: Main database interface implementing IAtom protocol. The `XITDBDatabase` type wraps Java database instances and provides thread-safe operations via ReentrantLock.
29+
30+
- **xitdb.xitdb-types**: Type dispatch system that handles reading/writing different data structures (HashMap, ArrayList, LinkedList, HashSet) to/from database cursors.
31+
32+
- **Data Structure Implementations**: Each data type (hash-map, array-list, linked-list, hash-set) has its own namespace implementing Clojure collection protocols over persistent storage.
33+
34+
- **Conversion Layer**: `util/conversion.clj` handles serialization between Clojure values and database slots.
35+
36+
### Key Protocols
37+
38+
- `ISlot`: For types that can provide their own database slot representation
39+
- `IReadFromCursor`: For reading values from database cursors
40+
- `IMaterialize`: For converting lazy database structures to in-memory Clojure data
41+
- `IUnwrap`: For extracting wrapped values
42+
43+
### Database Operations
44+
45+
The database acts like a Clojure atom with `reset!` and `swap!` operations, but persists all changes to disk. History is maintained as an append-only log accessible via `db-history`.

src/xitdb/util/operations.clj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,23 @@
6060
[^WriteLinkedArrayList wlal v]
6161
(let [cursor (.appendCursor wlal)]
6262
(.write cursor (conversion/v->slot! cursor v))
63-
nil))
63+
wlal))
6464

6565
(defn linked-array-list-insert-value!
6666
"Inserts a value at position pos in a WriteLinkedArrayList.
6767
Converts the value to an appropriate XitDB representation using v->slot!."
6868
[^WriteLinkedArrayList wlal pos v]
6969
(let [cursor (-> wlal .cursor)]
7070
(.insert wlal pos (conversion/v->slot! cursor v)))
71-
nil)
71+
wlal)
7272

7373
(defn linked-array-list-pop!
7474
"Removes the first element from a WriteLinkedArrayList.
7575
This is a stack-like operation (LIFO) for linked lists.
76-
Returns nil."
76+
Returns the modified WriteLinkedArrayList."
7777
[^WriteLinkedArrayList wlal]
7878
(.remove wlal 0)
79-
nil)
79+
wlal)
8080

8181
;; ============================================================================
8282
;; Map Operations
@@ -99,7 +99,8 @@
9999
key-cursor (.putKeyCursor whm key-hash)
100100
cursor (.putCursor whm key-hash)]
101101
(.writeIfEmpty key-cursor (conversion/v->slot! key-cursor k))
102-
(.write cursor (conversion/v->slot! cursor v))))
102+
(.write cursor (conversion/v->slot! cursor v))
103+
whm))
103104

104105
(defn map-dissoc-key!
105106
"Removes a key-value pair from a WriteHashMap.

0 commit comments

Comments
 (0)