Skip to content

Commit

Permalink
Outline of group method
Browse files Browse the repository at this point in the history
  • Loading branch information
fd committed Feb 11, 2013
1 parent bc9bf23 commit 5e53a98
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions runtime/methods_group.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,36 +40,19 @@ func (op *group_op) Resolve(txn *Transaction, events chan<- event.Event) {
coll_key_b = cas.Collate(key_b) coll_key_b = cas.Collate(key_b)
} }


// skip when they are equal // propagate event
// - to sub table at coll_key_b
// - to groups table
if bytes.Compare(coll_key_a, coll_key_b) == 0 { if bytes.Compare(coll_key_a, coll_key_b) == 0 {
continue continue
} }


// remove old entry // remove old entry from sub table
if i_change.a != nil { // add new entry to sub table (while potentially adding new subtables)
key_addr, elt_addr, err := table.Del(coll_key_a)
if err != nil {
panic("runtime: " + err.Error())
}
events <- &ChangedMember{op.name, coll_key_a, key_addr, elt_addr, nil}
}

// add new entry
if i_change.b != nil {
key_addr, err := cas.Encode(txn.env.Store, key_b, -1)
if err != nil {
panic("runtime: " + err.Error())
}

prev_elt_addr, err := table.Set(coll_key_a, key_addr, i_change.b)
if err != nil {
panic("runtime: " + err.Error())
}

events <- &ChangedMember{op.name, coll_key_b, key_addr, prev_elt_addr, i_change.b}
}
} }


// remove empty sub tables

tab_addr_a, tab_addr_b := txn.CommitTable(op.name, table) tab_addr_a, tab_addr_b := txn.CommitTable(op.name, table)
events <- &ConsistentTable{op.name, tab_addr_a, tab_addr_b} events <- &ConsistentTable{op.name, tab_addr_a, tab_addr_b}
} }

0 comments on commit 5e53a98

Please sign in to comment.