// combineDescriptors creates one FileDescriptorSet that covers all services
// and their dependencies.
491083
func combineDescriptors(serviceNames []string) (*descriptor.FileDescriptorSet, error) {
	result := &descriptor.FileDescriptorSet{}
	// seenFiles is a set of descriptor files keyed by SHA256 of their contents.
	seenFiles := map[[sha256.Size]byte]bool{}

	for _, s := range serviceNames {
		desc, err := GetDescriptorSet(s)
		if err != nil {
			return nil, fmt.Errorf("service %s: %s", s, err)
		}
		if desc == nil {
			return nil, fmt.Errorf(
				"descriptor for service %q is not found. "+
					"Did you compile it with go.chromium.org/luci/grpc/cmd/cproto?",
				s)
		}
		for _, f := range desc.GetFile() {
			binary, err := proto.Marshal(f)
			if err != nil {
				return nil, fmt.Errorf("could not marshal description of %s", f.GetName())
			}
			hash := sha256.Sum256(binary)
			if !seenFiles[hash] {
				result.File = append(result.File, f)
				seenFiles[hash] = true
			}

		}
	}
	return result, nil
}
605294
func (g *Generator) buildNestedDescriptors(descs []*Descriptor) {
	for _, desc := range descs {
		if len(desc.NestedType) != 0 {
			for _, nest := range descs {
				if nest.parent == desc {
					desc.nested = append(desc.nested, nest)
				}
			}
			if len(desc.nested) != len(desc.NestedType) {
				g.Fail("internal error: nesting failure for", desc.GetName())
			}
		}
	}
}
1325215
func wrapDescriptors(file *descriptor.FileDescriptorProto) []*Descriptor {
	sl := make([]*Descriptor, 0, len(file.MessageType)+10)
	for i, desc := range file.MessageType {
		sl = wrapThisDescriptor(sl, desc, nil, file, i)
	}
	return sl
}
541831
func combineProperties(a, b *Properties) *Properties {
	r := &Properties{values: make(map[key]attr)}
	for k, v := range a.values {
		r.values[k] = v
	}
	r.updateMissing(b)
	return r
}
474912
func LoadDescriptor(name string, pathSegments ...string) (*descriptor.FileDescriptorProto, error) {
	set, err := LoadDescriptorSet(pathSegments...)
	if err != nil {
		return nil, err
	}

	if pf := FindDescriptor(set, name); pf != nil {
		return pf, nil
	}

	return nil, errors.New("FileDescriptor not found")
}
959270
func (m Manifest) References() []distribution.Descriptor {
	references := make([]distribution.Descriptor, 0, 1+len(m.Layers))
	references = append(references, m.Config)
	references = append(references, m.Layers...)
	return references
}
321637
func (p *propertySet) GetCombinedUseMap() map[string]uint64 {
	combinedUse := make(map[string]uint64, helper.IntMax(len(p.existingValues), len(p.proposedValues)))
	for _, usedValues := range []map[string]uint64{p.existingValues, p.proposedValues} {
		for propertyValue, usedCount := range usedValues {
			combinedUse[propertyValue] += usedCount
		}
	}

	// Go through and discount the combined count when the value has been
	// cleared by a proposed stop.
	for propertyValue, clearedCount := range p.clearedValues {
		combined, ok := combinedUse[propertyValue]
		if !ok {
			continue
		}

		// Don't clear below 0.
		if combined >= clearedCount {
			combinedUse[propertyValue] = combined - clearedCount
		} else {
			combinedUse[propertyValue] = 0
		}
	}
	return combinedUse
}
1034607
func (m *Multi) AddLoaders(loaders ...jet.Loader) {
	m.loaders = append(m.loaders, loaders...)
}
88298
func GetDescriptorSet(serviceName string) (*descriptor.FileDescriptorSet, error) {
	e := getEntry(serviceName)
	if e == nil {
		return nil, nil
	}
	e.init.Do(func() {
		var unGzip io.Reader
		unGzip, e.err = gzip.NewReader(bytes.NewBuffer(e.compressedBytes))
		if e.err != nil {
			return
		}

		var uncompressed []byte
		uncompressed, e.err = ioutil.ReadAll(unGzip)
		if e.err != nil {
			return
		}

		var unmarshaled descriptor.FileDescriptorSet
		e.err = proto.Unmarshal(uncompressed, &unmarshaled)
		if e.err != nil {
			return
		}
		e.unmarshaled = &unmarshaled
	})
	return e.unmarshaled, e.err
}
1217907
func Combine(w Writer, r Reader) ReadWriteCloser {
	return &readWriter{Reader: r, Writer: w}
}
387993
func (o *VNFDescriptor) VNFInterfaceDescriptors(info *bambou.FetchingInfo) (VNFInterfaceDescriptorsList, *bambou.Error) {

	var list VNFInterfaceDescriptorsList
	err := bambou.CurrentSession().FetchChildren(o, VNFInterfaceDescriptorIdentity, &list, info)
	return list, err
}
596888
func (mc MongoClient) ValueDescriptors() ([]contract.ValueDescriptor, error) {
	return mapValueDescriptors(mc.getValueDescriptors(nil))
}
900006
func (scope *Scope) CombinedConditionSql() string {
	joinSQL := scope.joinsSQL()
	whereSQL := scope.whereSQL()
	if scope.Search.raw {
		whereSQL = strings.TrimSuffix(strings.TrimPrefix(whereSQL, "WHERE ("), ")")
	}
	return joinSQL + whereSQL + scope.groupSQL() +
		scope.havingSQL() + scope.orderSQL() + scope.limitAndOffsetSQL()
}
4517
func (d *Drain) CombineErrors() error {
	if d == nil || len(d.errors) == 0 {
		return nil
	}
	return drainError(d.errors)
}
640009
func (o *VNFCatalog) VNFDescriptors(info *bambou.FetchingInfo) (VNFDescriptorsList, *bambou.Error) {

	var list VNFDescriptorsList
	err := bambou.CurrentSession().FetchChildren(o, VNFDescriptorIdentity, &list, info)
	return list, err
}
971792
func (ca *CertAuthorityV2) CombinedMapping() RoleMap {
	if len(ca.Spec.Roles) != 0 {
		return RoleMap([]RoleMapping{{Remote: Wildcard, Local: ca.Spec.Roles}})
	}
	return RoleMap(ca.Spec.RoleMap)
}
999832
func SerializeDescriptor(fields []Field) []*pb.MetricsDataSet_MetricFieldDescriptor {
	ret := make([]*pb.MetricsDataSet_MetricFieldDescriptor, len(fields))

	for i, f := range fields {
		d := &pb.MetricsDataSet_MetricFieldDescriptor{
			Name: proto.String(f.Name),
		}

		switch f.Type {
		case StringType:
			d.FieldType = pb.MetricsDataSet_MetricFieldDescriptor_STRING.Enum()
		case BoolType:
			d.FieldType = pb.MetricsDataSet_MetricFieldDescriptor_BOOL.Enum()
		case IntType:
			d.FieldType = pb.MetricsDataSet_MetricFieldDescriptor_INT64.Enum()
		}

		ret[i] = d
	}

	return ret
}