feat: add listByType(typeHash) to Store interface #10

Merged
xiaomo merged 1 commits from feat/9-list-by-type into main 2026-05-18 14:13:16 +00:00
Owner

What

Add listByType(typeHash): Hash[] to the Store interface for O(1) type-based queries.

Why

Currently finding all nodes of a given type requires full CAS scan. This is needed by uwf cas schema list and will be useful for any type-based query.

Changes

  • json-cas/src/types.ts — add listByType to Store type
  • json-cas/src/store.ts — in-memory index via Map<Hash, Set<Hash>>
  • json-cas-fs/src/store.ts — fs index at _index/<typeHash>, append-only, with migration for existing dirs
  • Tests for both stores

Ref

Closes #9

## What Add `listByType(typeHash): Hash[]` to the `Store` interface for O(1) type-based queries. ## Why Currently finding all nodes of a given type requires full CAS scan. This is needed by `uwf cas schema list` and will be useful for any type-based query. ## Changes - `json-cas/src/types.ts` — add `listByType` to `Store` type - `json-cas/src/store.ts` — in-memory index via `Map<Hash, Set<Hash>>` - `json-cas-fs/src/store.ts` — fs index at `_index/<typeHash>`, append-only, with migration for existing dirs - Tests for both stores ## Ref Closes #9
xiaoju added 1 commit 2026-05-18 14:12:37 +00:00
Implement in-memory type index and fs append-only _index files. Rebuild index from existing .bin nodes on first load when _index is missing.

Co-authored-by: Cursor <cursoragent@cursor.com>
xiaomo approved these changes 2026-05-18 14:13:15 +00:00
xiaomo left a comment
Owner

LGTM 内存 Set 去重 + fs append-only index + 启动迁移,测试覆盖完整(含 idempotent put、round-trip、index 重建)。

LGTM ✅ 内存 Set 去重 + fs append-only index + 启动迁移,测试覆盖完整(含 idempotent put、round-trip、index 重建)。
xiaomo merged commit fb81f5a429 into main 2026-05-18 14:13:16 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
2 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/json-cas#10