// Interpret a raw DataRecord into a list of InterpretedFields.
555964
func (i *Interpreter) Interpret(rec DataRecord) []InterpretedField {
	return i.InterpretInto(rec, nil)
}
1129247
func (SimpleMetaFactory) Interpret(data []byte) (*schema.GroupVersionKind, error) {
	findKind := struct {
		// +optional
		APIVersion string `json:"apiVersion,omitempty"`
		// +optional
		Kind string `json:"kind,omitempty"`
	}{}
	if err := json.Unmarshal(data, &findKind); err != nil {
		return nil, fmt.Errorf("couldn't get version/kind; json parse error: %v", err)
	}
	gv, err := schema.ParseGroupVersion(findKind.APIVersion)
	if err != nil {
		return nil, err
	}
	return &schema.GroupVersionKind{Group: gv.Group, Version: gv.Version, Kind: findKind.Kind}, nil
}
837819
func parseFixedFields(input string, schemaObject *SchemaObject) {
	lines := strings.Split(input, "\n")
	for _, line := range lines {

		// replace escaped bars with "OR", assuming these are used to describe union types
		line = strings.Replace(line, " \\| ", " OR ", -1)

		// split the table on the remaining bars
		parts := strings.Split(line, "|")
		if len(parts) > 1 {
			fieldName := strings.Trim(stripLink(parts[0]), " ")
			if fieldName != "Field Name" && fieldName != "---" {

				if len(parts) == 3 || len(parts) == 4 {
					// this is what we expect
				} else {
					log.Printf("ERROR: %+v", parts)
				}

				typeName := parts[1]
				typeName = strings.Replace(typeName, "{expression}", "Expression", -1)
				typeName = strings.Trim(typeName, " ")
				typeName = strings.Replace(typeName, "`", "", -1)
				typeName = removeMarkdownLinks(typeName)
				typeName = strings.Replace(typeName, " ", "", -1)
				typeName = strings.Replace(typeName, "Object", "", -1)
				isArray := false
				if typeName[0] == '[' && typeName[len(typeName)-1] == ']' {
					typeName = typeName[1 : len(typeName)-1]
					isArray = true
				}
				isMap := false
				mapPattern := regexp.MustCompile("^Mapstring,\\[(.*)\\]$")
				if matches := mapPattern.FindSubmatch([]byte(typeName)); matches != nil {
					typeName = string(matches[1])
					isMap = true
				} else {
					// match map[string,<typename>]
					mapPattern2 := regexp.MustCompile("^Map\\[string,(.+)\\]$")
					if matches := mapPattern2.FindSubmatch([]byte(typeName)); matches != nil {
						typeName = string(matches[1])
						isMap = true
					}
				}
				description := strings.Trim(parts[len(parts)-1], " ")
				description = removeMarkdownLinks(description)
				description = strings.Replace(description, "\n", " ", -1)

				requiredLabel1 := "**Required.** "
				requiredLabel2 := "**REQUIRED**."
				if strings.Contains(description, requiredLabel1) ||
					strings.Contains(description, requiredLabel2) {
					// only include required values if their "Validity" is "Any" or if no validity is specified
					valid := true
					if len(parts) == 4 {
						validity := parts[2]
						if strings.Contains(validity, "Any") {
							valid = true
						} else {
							valid = false
						}
					}
					if valid {
						schemaObject.RequiredFields = append(schemaObject.RequiredFields, fieldName)
					}
					description = strings.Replace(description, requiredLabel1, "", -1)
					description = strings.Replace(description, requiredLabel2, "", -1)
				}
				schemaField := SchemaObjectField{
					Name:        fieldName,
					Type:        typeName,
					IsArray:     isArray,
					IsMap:       isMap,
					Description: description,
				}
				schemaObject.FixedFields = append(schemaObject.FixedFields, schemaField)
			}
		}
	}
}
775368
func decodeObjectFields(objValue reflect.Value, body map[string]*json.RawMessage) error {
	objValueType := objValue.Type()
	for i := 0; i != objValue.NumField(); i++ {
		f := objValueType.Field(i)
		if f.Anonymous {
			// Recurse into fields of anonymous field
			if err := decodeObjectFields(objValue.Field(i), body); err != nil {
				return driver.WithStack(err)
			}
		} else {
			// Decode individual field
			jsonName := strings.Split(f.Tag.Get("json"), ",")[0]
			if jsonName == "" {
				jsonName = f.Name
			} else if jsonName == "-" {
				continue
			}
			raw, ok := body[jsonName]
			if ok && raw != nil {
				field := objValue.Field(i)
				if err := json.Unmarshal(*raw, field.Addr().Interface()); err != nil {
					return driver.WithStack(err)
				}
			}
		}
	}
	return nil
}
592614
func (pb *pointBuilder) extractFields(mbean string, value interface{}) map[string]interface{} {
	fieldMap := make(map[string]interface{})
	valueMap, ok := value.(map[string]interface{})

	if ok {
		// complex value
		if len(pb.objectAttributes) == 0 {
			// if there were no attributes requested,
			// then the keys are attributes
			pb.fillFields("", valueMap, fieldMap)

		} else if len(pb.objectAttributes) == 1 {
			// if there was a single attribute requested,
			// then the keys are the attribute's properties
			fieldName := pb.formatFieldName(pb.objectAttributes[0], pb.objectPath)
			pb.fillFields(fieldName, valueMap, fieldMap)

		} else {
			// if there were multiple attributes requested,
			// then the keys are the attribute names
			for _, attribute := range pb.objectAttributes {
				fieldName := pb.formatFieldName(attribute, pb.objectPath)
				pb.fillFields(fieldName, valueMap[attribute], fieldMap)
			}
		}
	} else {
		// scalar value
		var fieldName string
		if len(pb.objectAttributes) == 0 {
			fieldName = pb.formatFieldName(defaultFieldName, pb.objectPath)
		} else {
			fieldName = pb.formatFieldName(pb.objectAttributes[0], pb.objectPath)
		}

		pb.fillFields(fieldName, value, fieldMap)
	}

	if len(pb.substitutions) > 1 {
		pb.applySubstitutions(mbean, fieldMap)
	}

	return fieldMap
}
1079545
func (r *Reader) unpackDRecord(f *File) (byte, error) {
	// Gets the directory record length
	var len byte
	if err := binary.Read(r.image, binary.BigEndian, &len); err != nil {
		return len, ErrCorruptedImage(err)
	}

	if len == 0 {
		return len + 1, io.EOF
	}

	// Reads directory record into Go struct
	var drecord DirectoryRecord
	if err := binary.Read(r.image, binary.BigEndian, &drecord); err != nil {
		return len, ErrCorruptedImage(err)
	}

	f.DirectoryRecord = drecord
	// Gets the name
	name := make([]byte, drecord.FileIDLength)
	if err := binary.Read(r.image, binary.BigEndian, name); err != nil {
		return len, ErrCorruptedImage(err)
	}
	f.fileID = string(name)

	// Padding field as per section 9.1.12 in ECMA-119
	if (drecord.FileIDLength % 2) == 0 {
		var zero byte
		if err := binary.Read(r.image, binary.BigEndian, &zero); err != nil {
			return len, ErrCorruptedImage(err)
		}
	}

	// System use field as per section 9.1.13 in ECMA-119
	// Directory record has 34 bytes in addition to the name's
	// variable length and the padding field mentioned in section 9.1.12
	totalLen := 34 + drecord.FileIDLength - (drecord.FileIDLength % 2)
	sysUseLen := int64(len - totalLen)
	if sysUseLen > 0 {
		sysData := make([]byte, sysUseLen)
		if err := binary.Read(r.image, binary.BigEndian, sysData); err != nil {
			return len, ErrCorruptedImage(err)
		}
	}
	return len, nil
}
235537
func (s *NodesStatsService) FielddataFields(fielddataFields ...string) *NodesStatsService {
	s.fielddataFields = append(s.fielddataFields, fielddataFields...)
	return s
}
650444
func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) {
	urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
	*(*[]byte)(urv.ptr) = d.rawBytes()
}
978962
func DecodeAttrs(v []byte) (map[string]interface{}, error) {
	var pb internal.AttrMap
	if err := proto.Unmarshal(v, &pb); err != nil {
		return nil, err
	}
	return decodeAttrs(pb.GetAttrs()), nil
}
298406
func getRecordList(r io.Reader) <-chan *skyrecord.Record {
	c := make(chan *skyrecord.Record)

	go func() {
		defer close(c)

		dec := json.NewDecoder(r)
		for {
			var data map[string]interface{}
			if err := dec.Decode(&data); err == io.EOF {
				break
			} else if err != nil {
				warn(err)
				break
			}

			record, err := skyrecord.MakeRecord(data)
			if err != nil {
				warn(err)
				continue
			}

			c <- record
		}
	}()

	return c
}
468937
func getRecords(c *godo.Client, zoneName string) ([]godo.DomainRecord, error) {
	allRecords := []godo.DomainRecord{}

	opt := &godo.ListOptions{}
	for {
		records, resp, err := c.Domains.Records(context.TODO(), zoneName, opt)
		if err != nil {
			return nil, err
		}

		allRecords = append(allRecords, records...)

		if resp.Links == nil || resp.Links.IsLastPage() {
			break
		}

		page, err := resp.Links.CurrentPage()
		if err != nil {
			return nil, err
		}

		opt.Page = page + 1
	}

	return allRecords, nil
}
626605
func DeriveFromFields(format string, fields ...string) FieldFormatterFunc {
	return func(input interface{}, _ FieldOperation) (interface{}, error) {
		if record, ok := input.(*Record); ok {
			values := make([]interface{}, len(fields))

			for i, field := range fields {
				values[i] = record.Get(field)
			}

			return fmt.Sprintf(format, values...), nil
		} else {
			return nil, fmt.Errorf("DeriveFromFields formatter requires a *dal.Record argument, got %T", input)
		}
	}
}
1301823
func (i *Interpreter) InterpretInto(rec DataRecord, fieldList []InterpretedField) []InterpretedField {
	tpl := i.session.lookupTemplateFieldSpecifiers(rec.TemplateID)
	if tpl == nil {
		return nil
	}

	if len(fieldList) < len(tpl) {
		fieldList = make([]InterpretedField, len(tpl))
	} else {
		fieldList = fieldList[:len(tpl)]
	}

	for j, field := range tpl {
		fieldList[j].FieldID = field.FieldID
		fieldList[j].EnterpriseID = field.EnterpriseID

		if entry, ok := i.dictionary[dictionaryKey{field.EnterpriseID, field.FieldID}]; ok {
			fieldList[j].Name = entry.Name
			fieldList[j].Value = interpretBytes(&rec.Fields[j], entry.Type)
		} else {
			fieldList[j].RawValue = rec.Fields[j]
		}
	}

	return fieldList
}
1202944
func (e *LoadDataInfo) getFieldsFromLine(line []byte) ([]field, error) {
	var (
		reader fieldWriter
		fields []field
	)

	if len(line) == 0 {
		str := []byte("")
		fields = append(fields, field{str, false, false})
		return fields, nil
	}

	reader.Init(e.FieldsInfo.Enclosed, e.FieldsInfo.Terminated[0], &line, &e.FieldsInfo.Terminated)
	for {
		eol, f := reader.GetField()
		f = f.escape()
		if string(f.str) == "NULL" && !f.enclosed {
			f.str = []byte{'N'}
			f.maybeNull = true
		}
		fields = append(fields, f)
		if eol {
			break
		}
	}
	return fields, nil
}
1084435
func (mock *Mock) Decode(data []byte) ([]*FileDataEntry, error) {
	items := mock.getReturnValues("Decode")
	if len(items) == 1 {
		switch typed := items[0].(type) {
		case []*FileDataEntry:
			return typed, nil
		case error:
			return []*FileDataEntry{}, typed
		}
	} else if len(items) == 2 {
		return items[0].([]*FileDataEntry), items[1].(error)
	}
	return []*FileDataEntry{}, nil
}
965803
func (api *Client) GetRecordingTranscriptions(id string) ([]*Transcription, error) {
	result, _, err := api.makeRequest(http.MethodGet, fmt.Sprintf("%s/%s/%s", api.concatUserPath(recordingsPath), id, transcriptionsPath), &[]*Transcription{})
	if err != nil {
		return nil, err
	}
	return *(result.(*[]*Transcription)), nil
}
851667
func InterpretListError(err error, qualifiedResource unversioned.GroupResource) error {
	switch {
	case storage.IsNotFound(err):
		return errors.NewNotFound(qualifiedResource, "")
	case storage.IsUnreachable(err):
		return errors.NewServerTimeout(qualifiedResource, "list", 2) // TODO: make configurable or handled at a higher level
	default:
		return err
	}
}