Implement java.util.List on sequence wrappers - #26
Merged
Merged
Conversation
codeboost
added this pull request to stack #27
September 15, 2026 08:40
codeboost
force-pushed
the
java-list-wrappers
branch
from
September 15, 2026 13:55
8d800f9 to
8c33cf8
Compare
codeboost
removed this pull request from stack #27
September 15, 2026 13:56
codeboost
changed the base branch from
dates-and-keyshashes-fixes
to
master
September 15, 2026 13:58
Read and write array-list and linked-array-list views now implement the full read-only java.util.List contract instead of only toArray: size, get with bounds checks on both ends, indexOf, containsAll, listIterator, subList, and typed toArray. Mutating methods throw UnsupportedOperationException. Sublists and iterators are live: a sublist taken inside a transaction reflects later assocs. Shared methods delegate to a Collections.unmodifiableList over an AbstractList proxy that streams the wrapper's seq, so no materialization happens. Since the wrappers are now List instances, java.util.ArrayList.equals accepts them and equality is symmetric with Java lists, including HashSet membership. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
codeboost
force-pushed
the
java-list-wrappers
branch
from
September 15, 2026 14:00
8c33cf8 to
495d4b9
Compare
Routing the transaction wrappers' iterator through listIterator made every element read go through putCursor, a write path that copies index nodes. Since coll-reduce dispatches on Iterable for these types, reduce, into and mapv inside swap! duplicated the whole list in the append-only file on every transaction (48 KB per 5000-element vector, 115 KB per list). Iterate the seq again, which walks cursors without copying. The plain iterator is therefore not live after assoc; listIterator and subList iterators still are, and the test now asserts liveness only for those. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #25. Read and write views over array lists and linked array lists now implement the full read-only
java.util.Listcontract, replacing the previousjava.util.Collectionimplementation that only providedtoArray.size,isEmpty,getwithIndexOutOfBoundsExceptionfor negative and past-the-end indices,contains,containsAll,indexOf,lastIndexOf,listIteratorwith and without a start index,subList, and bothtoArrayoverloads including the typed-array form. Every mutating method throwsUnsupportedOperationException, including on sublists and list iterators.Collections.unmodifiableListover anAbstractListproxy inxitdb.util.collectionthat streams the wrapper's seq. A sublist taken from a write view inside a transaction reflects laterassoccalls.java.util.ArrayList.equalsrequires the other operand to be aList, so it previously returned false against a stored sequence even though the reverse comparison was true. Both directions now agree, andhashCodematches, so views and Java lists find each other in aHashSet.Test plan
clojure -M:test: 237 tests, 3,157 assertions, 0 failurestoArraybuffers, bidirectionallistIterator, sublist bounds, live sublists across an in-transactionassoc, and every mutator throwingequals,hashCode, andHashSetmembership in both operand orders againstjava.util.ArrayList🤖 Generated with Claude Code