Esempio n. 1
0
func (self *Fs2UniqueIndex) Has(sg *goiso.SubGraph) bool {
	self.mutex.Lock()
	defer self.mutex.Unlock()
	key := sg.Serialize()
	if len(key) < 0 {
		panic(fmt.Errorf("Could not serialize sg, %v\n%v\n%v", len(key), sg, key))
	}
	has, err := self.bpt.Has(key)
	assert_ok(err)
	return has
}
Esempio n. 2
0
func (c *ParCollector) send(sg *goiso.SubGraph) {
	label := sg.ShortLabel()
	lg := &labelGraph{label, sg}
	bkt := hash(label) % len(c.chs)
	next := bkt
	for i := 0; i < len(c.chs); i++ {
		select {
		case c.chs[next] <- lg:
			return
		default:
			next = (next + 1) % len(c.chs)
		}
	}
	c.chs[bkt] <- lg
}
Esempio n. 3
0
func (self *Fs2UniqueIndex) Add(sg *goiso.SubGraph) {
	self.mutex.Lock()
	defer self.mutex.Unlock()
	if sg == nil {
		panic(fmt.Errorf("sg was a nil\n%p", sg))
	}
	key := sg.Serialize()
	if len(key) < 0 {
		panic(fmt.Errorf("Could not serialize sg, %v\n%v\n%v", len(key), sg, key))
	}
	assert_ok(self.bpt.Add(key, []byte{}))
	has, err := self.bpt.Has(key)
	assert_ok(err)
	if !has {
		panic("didn't have key just added")
	}
	// assert_ok(self.bf.Sync())
}
Esempio n. 4
0
func (m *RandomWalkMiner) PrMatrices(sg *goiso.SubGraph) (vp int, Q, R, u Sparse, err error) {
	defer func() {
		if e := recover(); e != nil {
			stack := string(debug.Stack())
			err = fmt.Errorf("%v\n%v", e, stack)
		}
	}()
	lattice := sg.Lattice()
	log.Printf("lattice size %d %v", len(lattice.V), sg.Label())
	p := m.probabilities(lattice)
	log.Println("got transistion probabilities", p)
	vp = m.startingPoints.Size()
	Q = Sparse{
		Rows:    len(lattice.V) - 1,
		Cols:    len(lattice.V) - 1,
		Entries: make([]*SparseEntry, 0, len(lattice.V)-1),
	}
	R = Sparse{
		Rows:    len(lattice.V) - 1,
		Cols:    1,
		Entries: make([]*SparseEntry, 0, len(lattice.V)-1),
	}
	u = Sparse{
		Rows:    1,
		Cols:    len(lattice.V) - 1,
		Entries: make([]*SparseEntry, 0, len(lattice.V)-1),
	}
	for i, x := range lattice.V {
		if len(x.V) == 1 && len(x.E) == 0 && i < len(lattice.V)-1 {
			u.Entries = append(u.Entries, &SparseEntry{0, i, 1.0 / float64(vp), vp})
		}
	}
	for _, e := range lattice.E {
		if e.Targ >= len(lattice.V)-1 {
			R.Entries = append(R.Entries, &SparseEntry{e.Src, 0, 1.0 / float64(p[e.Src]), p[e.Src]})
		} else {
			Q.Entries = append(Q.Entries, &SparseEntry{e.Src, e.Targ, 1.0 / float64(p[e.Src]), p[e.Src]})
		}
	}
	return vp, Q, R, u, nil
}
Esempio n. 5
0
File: fs.go Progetto: timtadh/graple
func (self *Fs2BpTree) Add(key []byte, sg *goiso.SubGraph) {
	self.mutex.Lock()
	defer self.mutex.Unlock()
	if len(key) < 0 {
		panic(fmt.Errorf("Key was a bad value %d %v %p\n%p", len(key), key, key, sg))
	}
	if sg == nil {
		panic(fmt.Errorf("sg was a nil %d %v %p\n%p", len(key), key, key, sg))
	}
	value := sg.Serialize()
	if len(value) < 0 {
		panic(fmt.Errorf("Could not serialize sg, %v\n%v\n%v", len(value), sg, value))
	}
	assert_ok(self.bpt.Add(key, value))
	has, err := self.bpt.Has(key)
	assert_ok(err)
	if !has {
		panic("didn't have key just added")
	}
	// assert_ok(self.bf.Sync())
}
Esempio n. 6
0
func (c *SerialCollector) send(sg *goiso.SubGraph) {
	c.ch <- &labelGraph{sg.ShortLabel(), sg}
}
Esempio n. 7
0
func (c *ParHashCollector) send(sg *goiso.SubGraph) {
	label := sg.ShortLabel()
	idx := hash(label) % len(c.chs)
	c.chs[idx] <- &labelGraph{label, sg}
}
Esempio n. 8
0
File: fs.go Progetto: timtadh/graple
func serializeValue(value *goiso.SubGraph) []byte {
	return value.Serialize()
}
Esempio n. 9
0
File: types.go Progetto: timtadh/sfp
func SerializeSubGraph(sg *goiso.SubGraph) []byte {
	return sg.Serialize()
}