func (n *Node) cache(counts ints_int.MultiMap, m ints_ints.MultiMap, key []int32, nodes []lattice.Node) error { for _, node := range nodes { err := m.Add(key, setToInt32s(node.(*Node).pat.Items)) if err != nil { return err } } return counts.Add(key, int32(len(nodes))) }
func (n *Node) kids(counts ints_int.MultiMap, kids ints_ints.MultiMap, candidates func() map[int32][]int32) ([]lattice.Node, error) { if n.pat.Items.Size() == 0 { return n.dt.FrequentItems, nil } if n.pat.Items.Size() >= n.dt.MaxItems { return []lattice.Node{}, nil } i := setToInt32s(n.pat.Items) if has, err := counts.Has(i); err != nil { return nil, err } else if has { return n.cached(kids, i) } exts := candidates() nodes, err := n.nodesFromCandidateKids(exts) if err != nil { return nil, err } err = n.cache(counts, kids, i, nodes) if err != nil { return nil, err } return nodes, nil }