// Generates the requested number of triples.
420205
func (t *treeGenerator) Generate(n int) ([]*triple.Triple, error) {
	var trpls []*triple.Triple
	if n <= 0 {
		return trpls, nil
	}
	root, err := t.newNode(0, "")
	if err != nil {
		return nil, err
	}
	depth := int(math.Log(float64(n)) / math.Log(float64(t.branch)))
	ntrpls, err := t.recurse(root, &n, 0, depth, trpls)
	if err != nil {
		return nil, err
	}
	return ntrpls, nil
}
1229676
func (s *server) signAndInsertTriples(triples []*protocol.Triple, key *crypto.PrivateKey) error {
	hashes := make(map[uint64][]*protocol.Triple)
	unix := time.Now().Unix()
	for _, triple := range triples {
		if err := key.SignTriple(triple); err != nil {
			return err
		}
		triple.Created = unix
		hash := murmur3.Sum64([]byte(triple.Subj))
		hashes[hash] = append(hashes[hash], triple)
	}

	for hash, triples := range hashes {
		msg := &protocol.Message{
			Message: &protocol.Message_InsertTriples{
				InsertTriples: &protocol.InsertTriples{
					Triples: triples,
				}},
			Gossip: true,
		}
		currentKeyspace := s.network.LocalPeer().Keyspace.Includes(hash)
		if err := s.network.Broadcast(&hash, msg); currentKeyspace && err == network.ErrNoRecipients {
		} else if err != nil {
			return err
		}
		if currentKeyspace {
			s.ts.Insert(triples)
		}
	}
	return nil
}
1358457
func (h *Hash) GenerateExample(r *RandomGenerator, seen []string) interface{} {
	count := r.Int()%3 + 1
	pair := map[interface{}]interface{}{}
	for i := 0; i < count; i++ {
		pair[h.KeyType.Type.GenerateExample(r, seen)] = h.ElemType.Type.GenerateExample(r, seen)
	}
	return h.MakeMap(pair)
}
450465
func (g *Generator) Generate() (_ []string, err error) {
	if g.API == nil {
		return nil, fmt.Errorf("missing API definition, make sure design is properly initialized")
	}

	go utils.Catch(nil, func() { g.Cleanup() })

	defer func() {
		if err != nil {
			g.Cleanup()
		}
	}()

	if g.Target == "" {
		g.Target = "app"
	}

	codegen.Reserved[g.Target] = true

	mainFile := filepath.Join(g.OutDir, "main.go")
	if g.Force {
		os.Remove(mainFile)
	}
	_, err = os.Stat(mainFile)
	if err != nil {
		// ensure that the output directory exists before creating a new main
		if err = os.MkdirAll(g.OutDir, 0755); err != nil {
			return nil, err
		}
		if err = g.createMainFile(mainFile, funcMap(g.Target, nil)); err != nil {
			return nil, err
		}
	}

	err = g.API.IterateResources(func(r *design.ResourceDefinition) error {
		filename, err := GenerateController(g.Force, g.Regen, g.Target, g.OutDir, "main", r.Name, r)
		if err != nil {
			return err
		}

		g.genfiles = append(g.genfiles, filename)
		return nil
	})
	if err != nil {
		return
	}

	return g.genfiles, nil
}
261138
func FingerprintTriple(t *protocol.Triple) ([]byte, error) {
	data, err := t.Marshal()
	if err != nil {
		return nil, err
	}
	sum := sha1.Sum(data)
	return sum[:], nil
}
726979
func (g *Generator) Generate() error {
	// first we read the code from which we should find the types
	if err := g.readPackageCode(g.options.Source); err != nil {
		return err
	}

	// then we generate code for the types given
	for _, rootType := range g.options.Types {
		if err := g.generateStructCode(rootType); err != nil {
			return err
		}
	}

	//
	g.Imports = strings.Join(toolbox.MapKeysToStringSlice(g.imports), "\n")
	return g.writeCode()
}
1333048
func (g *Generator) Generate(api *design.APIDefinition) (_ []string, err error) {
	if api == nil {
		return nil, fmt.Errorf("missing API definition, make sure design.Design is properly initialized")
	}
	go utils.Catch(nil, func() { g.Cleanup() })
	defer func() {
		if err != nil {
			g.Cleanup()
		}
	}()
	if err := os.MkdirAll(g.outDir, 0755); err != nil {
		return nil, err
	}

	if err := g.generateUserTypes(g.outDir, api); err != nil {
		return g.genfiles, err
	}
	if err := g.generateUserHelpers(g.outDir, api); err != nil {
		return g.genfiles, err
	}

	return g.genfiles, nil
}
547396
func binOpHypot(rate int8, x, y Input, numOutputs int) Input {
	CheckRate(rate)
	return NewInput(BinOpUgenName, rate, BinOpHypot, numOutputs, x, y)
}
2696
func (as ArraySpec) Sum3rand() Input {
	return as.proc(func(i Input) Input {
		return i.Sum3rand()
	})
}
495699
func (g *Generator) Generate() (_ []string, err error) {
	if g.API == nil {
		return nil, fmt.Errorf("missing API definition, make sure design is properly initialized")
	}

	go utils.Catch(nil, func() { g.Cleanup() })

	defer func() {
		if err != nil {
			g.Cleanup()
		}
	}()

	codegen.Reserved[g.Target] = true

	os.RemoveAll(g.OutDir)

	if err := os.MkdirAll(g.OutDir, 0755); err != nil {
		return nil, err
	}
	g.genfiles = []string{g.OutDir}
	if err := g.generateContexts(); err != nil {
		return nil, err
	}
	if err := g.generateControllers(); err != nil {
		return nil, err
	}
	if err := g.generateSecurity(); err != nil {
		return nil, err
	}
	if err := g.generateHrefs(); err != nil {
		return nil, err
	}
	if err := g.generateMediaTypes(); err != nil {
		return nil, err
	}
	if err := g.generateUserTypes(); err != nil {
		return nil, err
	}
	if !g.NoTest {
		if err := g.generateResourceTest(); err != nil {
			return nil, err
		}
	}

	return g.genfiles, nil
}
1286075
func (m *memory) AddTriples(ctx context.Context, ts []*triple.Triple) error {
	m.rwmu.Lock()
	defer m.rwmu.Unlock()
	for _, t := range ts {
		tuuid := UUIDToByteString(t.UUID())
		sUUID := UUIDToByteString(t.Subject().UUID())
		pUUID := UUIDToByteString(t.Predicate().PartialUUID())
		oUUID := UUIDToByteString(t.Object().UUID())
		// Update master index
		m.idx[tuuid] = t

		if _, ok := m.idxS[sUUID]; !ok {
			m.idxS[sUUID] = make(map[string]*triple.Triple)
		}
		m.idxS[sUUID][tuuid] = t

		if _, ok := m.idxP[pUUID]; !ok {
			m.idxP[pUUID] = make(map[string]*triple.Triple)
		}
		m.idxP[pUUID][tuuid] = t

		if _, ok := m.idxO[oUUID]; !ok {
			m.idxO[oUUID] = make(map[string]*triple.Triple)
		}
		m.idxO[oUUID][tuuid] = t

		key := sUUID + pUUID
		if _, ok := m.idxSP[key]; !ok {
			m.idxSP[key] = make(map[string]*triple.Triple)
		}
		m.idxSP[key][tuuid] = t

		key = pUUID + oUUID
		if _, ok := m.idxPO[key]; !ok {
			m.idxPO[key] = make(map[string]*triple.Triple)
		}
		m.idxPO[key][tuuid] = t

		key = sUUID + oUUID
		if _, ok := m.idxSO[key]; !ok {
			m.idxSO[key] = make(map[string]*triple.Triple)
		}
		m.idxSO[key][tuuid] = t
	}
	return nil
}
1022090
func (s *mustRunAs) Generate(pod *api.Pod, container *api.Container) (*int64, error) {
	return &s.opts.Ranges[0].Min, nil
}
790668
func (msg MultiServiceGenerator) Generate(req *api.GenerateServiceRequest) (*api.GenerateServiceResponse, error) {
	var (
		lock      sync.Mutex
		files     = make(map[string][]byte)
		usedPaths = make(map[string]string) // path -> plugin name
	)

	err := concurrent.Range(msg, func(_ int, sg ServiceGenerator) error {
		res, err := sg.Generate(req)
		if err != nil {
			return err
		}

		lock.Lock()
		defer lock.Unlock()

		pluginName := sg.Handle().Name()
		for path, contents := range res.Files {
			if takenBy, taken := usedPaths[path]; taken {
				return fmt.Errorf("plugin conflict: cannot write file %q for plugin %q: "+
					"plugin %q already wrote to that file", path, pluginName, takenBy)
			}

			usedPaths[path] = pluginName
			files[path] = contents
		}

		return nil
	})

	return &api.GenerateServiceResponse{Files: files}, err
}
240859
func (mock *MyInterfaceMock) Three() string {
	if mock.ThreeFunc == nil {
		panic("MyInterfaceMock.ThreeFunc: method is nil but MyInterface.Three was just called")
	}
	callInfo := struct {
	}{}
	lockMyInterfaceMockThree.Lock()
	mock.calls.Three = append(mock.calls.Three, callInfo)
	lockMyInterfaceMockThree.Unlock()
	return mock.ThreeFunc()
}
399619
func (t Triple) Strings() []string {
	acc := make([]string, 0, 4)
	acc = append(acc, string(t.S))
	acc = append(acc, string(t.P))
	acc = append(acc, string(t.O))
	acc = append(acc, string(t.V))
	return acc
}
378552
func (j *RS256JWTStrategy) Generate(ctx context.Context, claims jwt.Claims, header Mapper) (string, string, error) {
	if header == nil || claims == nil {
		return "", "", errors.New("Either claims or header is nil.")
	}

	token := jwt.NewWithClaims(jwt.SigningMethodRS256, claims)
	token.Header = assign(token.Header, header.ToMap())

	var sig, sstr string
	var err error
	if sstr, err = token.SigningString(); err != nil {
		return "", "", errors.WithStack(err)
	}

	if sig, err = token.Method.Sign(sstr, j.PrivateKey); err != nil {
		return "", "", errors.WithStack(err)
	}

	return fmt.Sprintf("%s.%s", sstr, sig), sig, nil
}
60098
func (t *Triple) String() string {
	return fmt.Sprintf("%s\t%s\t%s", t.s, t.p, t.o)
}