Exemple #1
0
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)))
}
Exemple #2
0
func (n *Node) cached(m ints_ints.MultiMap, key []int32) (nodes []lattice.Node, _ error) {
	nodes = make([]lattice.Node, 0, 10)
	doerr := m.DoFind(key,
		func(_, value []int32) error {
			node, err := LoadNode(value, n.dt)
			if err != nil {
				return err
			}
			nodes = append(nodes, node)
			return nil
		})
	if doerr != nil {
		return nil, doerr
	}
	return nodes, nil
}