Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
Archivo: node.go Proyecto: timtadh/sfp
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
}
Ejemplo n.º 3
0
func (st *SurveyLogStore) loadLine(line []byte, answers *[]*models.SurveyAnswer, answered *set.SortedSet) error {
	var a models.SurveyAnswer
	err := json.Unmarshal(line, &a)
	if err != nil {
		return err
	}
	answered.Add(types.Int(a.CloneID))
	*answers = append(*answers, &a)
	return nil
}
Ejemplo n.º 4
0
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
}
Ejemplo n.º 5
0
func visit(t testing.TB, x *assert.Assertions, visited *set.SortedSet, node Node) {
	errors.Logf("DEBUG", "visiting %v", node)
	if visited.Has(node.Pattern()) {
		return
	}
	visited.Add(node.Pattern())
	checkNode(t, x, node)
	kids, err := node.Children()
	if err != nil {
		t.Fatal(err)
	}
	for _, kid := range kids {
		if !visited.Has(kid.Pattern()) {
			visit(t, x, visited, kid.(Node))
		}
	}
}