Skip to content

refactor(value): migrate Value::Object to Object storage abstraction#736

Open
anakrish wants to merge 1 commit into
microsoft:mainfrom
anakrish:storage-abstraction-object-migration
Open

refactor(value): migrate Value::Object to Object storage abstraction#736
anakrish wants to merge 1 commit into
microsoft:mainfrom
anakrish:storage-abstraction-object-migration

Conversation

@anakrish
Copy link
Copy Markdown
Collaborator

@anakrish anakrish commented Jun 2, 2026

Swaps Value::Object's payload from Rc<BTreeMap<Value, Value>> to Rc<Object> and migrates every call site to the Object API.

  • as_object / as_object_mut keep their names; return types become &Object / &mut Object. The mutable accessor handles Rc::make_mut internally.
  • Value serialization delegates to Object::serialize, removing a duplicated non-string-key path.
  • RVM IterationState::Object is rewritten around ObjectCursor — O(log n) steps over a shared Rc<Object>, no eager pair snapshot, with CoW for snapshot independence. New test iteration_state_object_is_snapshot_independent_of_source covers the alias-mutation case.
  • Azure Policy test harness swaps entry().or_insert for Object::get_or_insert_with (the entry API is intentionally not exposed).

Value::Set is unchanged; the matching Set abstraction and swap ship in the next PRs.

This is a semver-major change for as_object / as_object_mut (return type changes), which will land at the next release.

@anakrish anakrish force-pushed the storage-abstraction-object-migration branch 3 times, most recently from 50770ce to a7894b2 Compare June 4, 2026 17:57
Builds on #57. Swap Value::Object's payload from Rc<BTreeMap<Value, Value>>
to Rc<Object> and migrate all call sites to the Object API.

as_object / as_object_mut keep their names but return &Object / &mut Object.
The mutable accessor handles Rc::make_mut internally, so callers no longer
do it themselves. Object grows into_value() and From<Object> for Value.
Value's serializer now delegates to Object::serialize, dropping a duplicate
non-string-key stringification path.

RVM IterationState::Object is rewritten around ObjectCursor: O(log n)
steps over a shared Rc<Object>, no eager pair snapshot. Snapshot
independence is preserved by Rc copy-on-write; setup_next_iteration
advances the cursor inline and advance() becomes a no-op for this variant.
A new iteration_state_object_is_snapshot_independent_of_source test
covers CoW against a mutated alias.

Value::Set still wraps Rc<BTreeSet<Value>>; the matching Set abstraction
and its swap ship in follow-up PRs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@anakrish anakrish force-pushed the storage-abstraction-object-migration branch from a7894b2 to 21d5431 Compare June 4, 2026 18:14
@anakrish anakrish requested review from dekomissMSFT and dpokluda June 4, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant