~/bend-docscommunity

src/Comparison.bend fails

raw source on the hub · import 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Comparison.bend as Comparison

6 imports
import Base
import ./Reading.bend as Reading
import ./LogicalKey.bend as LogicalKey
import ./StateTree.bend as StateTree
import ./History.bend as History
import ./Store.bend as Store

Types

type ModifiedEntry source · line 18 · raw

Data

One changed key with its before/after hashes.

type CompareResult source · line 22 · raw

Data

Added, removed and modified sets plus prune/compare counts.

Definitions

def added_keys_of source · line 26 · raw

@compare_result:CompareResult -> List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey>

Projects the added keys out of a compare result.

def removed_keys_of source · line 32 · raw

@compare_result:CompareResult -> List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey>

Projects the removed keys out of a compare result.

def modified_entries_of source · line 38 · raw

@compare_result:CompareResult -> List<&2, ModifiedEntry>

Projects the modified entries out of a compare result.

def pruned_count_of source · line 44 · raw

@compare_result:CompareResult -> Nat

Projects the pruned-subtree count out of a compare result.

def compared_entry_count_of source · line 50 · raw

@compare_result:CompareResult -> Nat

Projects the compared-entry count out of a compare result.

def entry_to_logical_key source · line 56 · raw

@head_entry:0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry -> 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey

Splits an entry key into namespace and record.

def decide_member_found source · line 60 · raw

@head_matches:Bool -> @recursive_result:Bool -> Bool

True short-circuits the membership scan.

def key_in_entries source · line 68 · raw

@+target_key:String -> @entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> Bool

Scans entries for the target key.

def decide_member_keep source · line 76 · raw

@is_member:Bool -> @+head_entry:0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry -> @tail_keys:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey> -> List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey>

Keeps the entry only when absent from the other side.

def second_only_entries source · line 84 · raw

@+first_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @second_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey>

Keys of second absent from first: the added set.

def first_only_entries source · line 92 · raw

@+second_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @first_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey>

Keys of first absent from second: the removed set.

def decide_value_found source · line 100 · raw

@head_matches:Bool -> @head_value:String -> @tail_result:Maybe<&2, String> -> Maybe<&2, String>

Some on match, otherwise the tail result.

def value_of_key source · line 108 · raw

@+target_key:String -> @entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> Maybe<&2, String>

Finds the value stored under the key.

def decide_modified_value source · line 116 · raw

@values_equal:Bool -> @+head_entry:0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry -> @+second_value:String -> @tail_modified:List<&2, ModifiedEntry> -> List<&2, ModifiedEntry>

Records a change only when values differ.

def decide_modified_member source · line 124 · raw

@second_value_maybe:Maybe<&2, String> -> @+head_entry:0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry -> @tail_modified:List<&2, ModifiedEntry> -> List<&2, ModifiedEntry>

Records a change when the key exists on both sides.

def changed_pairs source · line 132 · raw

@+second_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @first_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> List<&2, ModifiedEntry>

Shared keys with different values: the modified set.

def compare_sorted_entries source · line 140 · raw

@+first_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @+second_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> CompareResult

Membership diff core; counts cover both inputs.

def split_step source · line 145 · raw

@entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @take_head:Bool -> @evens_accum:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @odds_accum:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> Pair(List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry>, List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry>)

Alternates entries into even/odd accumulators, then reverses.

def split_entries source · line 157 · raw

@+source_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> Pair(List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry>, List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry>)

Splits into balanced halves for any key distribution.

def fan_added_halves source · line 162 · raw

@even_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @odd_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @+reference_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey>

Compares both halves against the reference in parallel.

def fan_out_pair source · line 167 · raw

@split_pair:Pair(List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry>, List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry>) -> @+reference_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey>

Unpacks the split pair into the fanned added step.

def fan_added_entries source · line 173 · raw

@+first_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @+second_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey>

Fanned added-set computation.

def fan_removed_halves source · line 177 · raw

@even_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @odd_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @+reference_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey>

Compares both halves against the reference in parallel.

def fan_out_removed source · line 182 · raw

@split_pair:Pair(List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry>, List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry>) -> @+reference_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey>

Unpacks the split pair into the fanned removed step.

def fan_removed_entries source · line 188 · raw

@+first_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @+second_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/LogicalKey.LogicalKey>

Fanned removed-set computation.

def fan_modified_halves source · line 192 · raw

@even_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @odd_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @+reference_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> List<&2, ModifiedEntry>

Compares both halves against the reference in parallel.

def fan_out_modified source · line 197 · raw

@split_pair:Pair(List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry>, List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry>) -> @+reference_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> List<&2, ModifiedEntry>

Unpacks the split pair into the fanned modified step.

def fan_modified_entries source · line 203 · raw

@+first_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @+second_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> List<&2, ModifiedEntry>

Fanned modified-set computation.

def compare_entries_fanned source · line 207 · raw

@+first_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @+second_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> CompareResult

Parallel diff; sets and counts agree with sequential.

def comparison_parallel_threshold source · line 211 · raw

Nat

Entry count above which compare fans out.

def decide_fan_out source · line 215 · raw

@is_large:Bool -> @+first_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @+second_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> CompareResult

Fans out only past the threshold.

def compare_entries_auto source · line 223 · raw

@+first_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @+second_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> CompareResult

Chooses sequential or fanned compare by size.

def entries_or_empty source · line 227 · raw

@tree_maybe:Maybe<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/StateTree.StateTreeNode> -> List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry>

Missing trees read as empty entry lists.

def hash_or_empty source · line 235 · raw

@tree_maybe:Maybe<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/StateTree.StateTreeNode> -> String

Missing trees hash as the empty string.

def pruned_result source · line 243 · raw

@first_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> @second_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> CompareResult

Equal hashes yield an empty delta with one prune counted.

def pruned_or_present source · line 247 · raw

@second_maybe:Maybe<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/StateTree.StateTreeNode> -> @first_entries:List<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Reading.ChainEntry> -> CompareResult

Missing second tree degrades to a one-sided diff.

def pruned_or_empty source · line 255 · raw

@first_maybe:Maybe<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/StateTree.StateTreeNode> -> @second_maybe:Maybe<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/StateTree.StateTreeNode> -> CompareResult

Missing first tree degrades to a one-sided diff.

def dispatch_tree_hashes source · line 263 · raw

@hashes_equal:Bool -> @+first_maybe:Maybe<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/StateTree.StateTreeNode> -> @+second_maybe:Maybe<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/StateTree.StateTreeNode> -> CompareResult

Equal hashes prune; different hashes diff.

def compare_loaded_trees source · line 271 · raw

@+first_maybe:Maybe<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/StateTree.StateTreeNode> -> @+second_maybe:Maybe<&2, 0x876fb95e9d05a7c35ecfcf6d39b99754/src/StateTree.StateTreeNode> -> CompareResult

Diffs two loaded trees with hash pruning.

def compare_commits source · line 275 · raw

@+first_identifier:String -> @+second_identifier:String -> 0x876fb95e9d05a7c35ecfcf6d39b99754/src/Store.Op<&2, CompareResult>

Shell: loads both trees and diffs them.