func (n *EmbListNode) SaveUnsupportedExts(orgLen int, vord []int, eps *set.SortedSet) error { if n.Dt.Config.Mode&ExtensionPruning == 0 { return nil } n.unsupExts = set.NewSortedSet(eps.Size()) for x, next := eps.Items()(); next != nil; x, next = next() { ep := x.(*subgraph.Extension) ept := ep.Translate(orgLen, vord) n.unsupExts.Add(ept) } if n.Dt.UnsupExts == nil || n.Dt.Config.Mode&Caching == 0 { return nil } n.Dt.lock.Lock() defer n.Dt.lock.Unlock() if len(n.Pat.E) < 4 { return nil } label := n.Label() for x, next := n.unsupExts.Items()(); next != nil; x, next = next() { ept := x.(*subgraph.Extension) err := n.Dt.UnsupExts.Add(label, ept) if err != nil { return err } } return nil }
func setToInt32s(s *set.SortedSet) []int32 { items := make([]int32, 0, s.Size()) for i, n := s.Items()(); n != nil; i, n = n() { item := int32(i.(types.Int32)) items = append(items, item) } return items }
func (m *RandomWalkMiner) supportedKeys(from []byte, keys *set.SortedSet) *set.SortedSet { key := types.ByteSlice(from) if m.supportedExtensions.Has(key) { supKeys := m.supportedExtensions.Get(key) return supKeys } keysCh := make(chan []byte) partKeys := make(chan []byte) done := make(chan bool) for i := 0; i < m.PLevel; i++ { go func() { for key := range keysCh { if len(m.partition(key)) >= m.Support { partKeys <- key } } done <- true }() } go func() { for k, next := keys.Items()(); next != nil; k, next = next() { keysCh <- []byte(k.(types.ByteSlice)) } close(keysCh) }() go func() { for i := 0; i < m.PLevel; i++ { <-done } close(partKeys) close(done) }() supKeys := set.NewSortedSet(10) for partKey := range partKeys { supKeys.Add(types.ByteSlice(partKey)) } m.supportedExtensions.Put(key, supKeys) return supKeys }