Support mutation through non-terminal comma-separated-list outputs #45
Labels
No labels
bug
duplicate
enhancement/documentation
enhancement/feature
enhancement/organization
question
rejected
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
UserCurt/mpath#45
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
setandremovecurrently do not allow paths that continue through multi-output comma-separated list (CSL).For example, :
To support non-terminal CSL selector, MPath must retrieve the selected output, modify its descendant, and write the changed output back.
removerequires the same process when removing a descendant.Terminal comma-separated-list assignment is a separate problem tracked by #42. This issue covers CSL selection that occurs before the final mutation target.
There are three considered planning approaches.
1. Reuse the forward chunks
The simplest approach is to reuse the chunks selected during forward traversal when writing changes values. The chunk planner itself would not change.
This approach relies on two assumptions:
listLengthreturns the same result whethermatlab.indexing.IndexingContextisExpressionorAssignmentparent.(indexOps)successfully retrieves a child, thenparent.(indexOps) = childsupports the corresponding write-back operationThis is the proposed approach for initial support in the short term to enable non-terminal CSL mutation.
2. Plan write-back separately
In this approach, the chunk planner would run a second time during reverse write-back. The forward plan would determine how to retrieve each child, and the reverse plan would determine how to assign each changed child back into its parent. When a forward chunk cannot be used for assignment, the reverse planner could divide it into smaller chunks until it finds a valid write-back sequence.
This approach would mean retrieval and assignment could have different chunk boundaries. This can be confusing users because the write-back boundaries would remain internal, unless
resolveis modified such that it conditionally applies this two-phase chunk planning based on an optional named argument.The separate plans must also preserve resolved-input equivalence:
3. Plan both directions together
In this approach, there would only be one chunk planner step but it would choose he boundaries that would work for both the forward traversal and reverse write-back.
Query operation would continue planning only for
Expression. Mutation operations would require each non-terminal chunk to work under bothExpressionandAssignment, and the terminal chunk to work underAssignmentonly.This removes the assumption that
listLengthbehaves identically across indexing contexts because the planner would check both contexts. Though, it still has one assumption:parent.(indexOps) = childsupports the corresponding write-back operation.MPath cannot verify this completely without performing the assignment.
With this approach,
resolveshould be modified such that it is aware whether it is a query or mutation operation as the chunk planner could result in different chunks depending on which is the case.4. Plan both directions together with independent boundaries
The planner could build the forward traversal plan and reverse write-back plan together without requiring their chunk boundaries to align. For example:
/A/B<1>/Cfor forward traversal/A<1>/B/Cfor reverse write-backThis is the most flexible approach but is the most complex as there are two plans being created. Option 2 cannot produce this result because its reverse planner starts with the forward chunks and can only divide them into smaller chunks.
This removes the assumption that
listLengthbehaves identically across indexing contexts because the planner checks each plan using it applicable context. Though, it still has one assumption:parent.(indexOps) = childsupports the corresponding write-back operation.As with separate reverse planning, the implementation must preserve resolved-input equivalence.
With this approach,
resolveshould be modified such that it is aware whether it is a query or mutation operation and also, if it is a mutation operation, which of the two plans to return.UserCurt referenced this issue2026-07-27 08:06:30 +00:00
setassigns through missing paths and constructs new data #15Completed by commit
23ff124.setandremovenow support mutation through non-terminal CSL selectors. Option 1 has been chosen as the easiest short-term solution. Contemplation of other options is now separately tracked in #48, while sharing materialized route values is tracked by #47.