|
Download knowledge_vault/computer_science/data-structures-and-git.md from Johnny5b/portable-ai-runner: direct link, hf CLI and curl.
- Browser
- Download file 3.21 kB
-
https://huggingface.co/datasets/Johnny5b/portable-ai-runner/resolve/main/knowledge_vault/computer_science/data-structures-and-git.md
- Command line
-
hf download hf://datasets/Johnny5b/portable-ai-runner/knowledge_vault/computer_science/data-structures-and-git.md
-
curl -L -o data-structures-and-git.md https://huggingface.co/datasets/Johnny5b/portable-ai-runner/resolve/main/knowledge_vault/computer_science/data-structures-and-git.md
3.21 kB
Data structures + Git operations (CS vault)
Data structures — selection table
| Need | Structure | Why | Cost (typical) |
|---|---|---|---|
| Fast lookup by key | hash table | O(1) average | O(1) insert/lookup |
| Ordered iteration + range query | balanced BST (red-black, B-tree) | sorted invariants | O(log n) |
| Priority by score | binary heap | heap property, no full ordering needed | O(log n) push/pop |
| LRU cache | hash map + doubly linked list | O(1) evict of least-recent | O(1) all ops |
| Prefix search / autocomplete | trie | shared-prefix compression | O( |
| Union/grouping | disjoint set | near-constant merges | O(α(n)) |
| Immutable snapshot (undo, diff) | persistent tree (git object model) | structural sharing | O(log n) version access |
- B-trees (fat nodes matched to disk pages, high branching factor) are the structure for USB/SSD-backed indexes — this drive's situation. A linear scan of the vault beats an in-RAM index only for vaults < ~10 MB; beyond that, keep symbol_index.json + per-domain index files as the B-tree stand-in (flat files, page-friendly, diffable).
Git — operations this drive's provenance system relies on
- Content-addressed storage. Every object (blob, tree, commit, tag) is stored by sha1 of its content. Same content = same hash = free dedup. Same idea as this package's sha256 manifests: hash the bytes, record the hash, verify later.
- commit = (tree, parent(s), author, committer, message, timestamp). Ancestry is a DAG — merges create two parents.
- Working clone with full provenance:
git clone --origin upstream <url>— keepupstreamso audits cangit fetch upstreamand compare.git rev-parse HEAD— record the commit hash in the module manifest. This, plus per-file sha256, is the provenance stored insymbols/schemas/*.manifest.json.git diff --stat HEAD~1..HEAD— what changed last commit.
- Conflict discipline: rebase your own local work before a merge; never rebase published history others depend on (
git push --forceto shared branches is destructive — treat like a delete). - Selective recovery:
git checkout <hash> -- path/to/filerestores one file without moving the branch;git revert <hash>creates an inverse commit — safe on shared history, unlikereset --hard. - Verification:
git fsckchecks object database integrity;git verify-commit <hash>checks a GPG signature. A manifest storing (repo, commit, file, sha256) detects any silent mutation: recompute, compare, report.
Storage-aware notes for an offline USB drive
- Git repos store objects loosely or packed (
git gc→ packfiles). The clones inmodules/carry full history; if drive space is tight, a--depth 1re-clone drops history AND the ability to audit provenance — the trade-off is recorded per module in its manifest, and the default here is full history. - Filesystem reality: exFAT (cross-platform) has no journaling and no permissions — portable but weaker for integrity; ext4 (Linux) has journaling. Either way the audit ledger (
memories/audit_ledger.jsonl) + sha256 manifests are the integrity system of record, because they work on any filesystem.