Skip to content

Commit

Permalink
Name split elements
Browse files Browse the repository at this point in the history
  • Loading branch information
zhilingc committed Oct 18, 2019
1 parent 0a7e767 commit 1c70ef8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions sdk/go/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,24 @@ func buildFeatureSets(features []string, maxAgeSeconds int) ([]*serving.GetOnlin
featureSetMap := map[string]*serving.GetOnlineFeaturesRequest_FeatureSet{}
for _, feature := range features {
split := strings.Split(feature, ":")
featureSetName, featureSetVersion, featureName := split[0], split[1], split[2]
if len(split) != 3 {
return nil, fmt.Errorf(ErrInvalidFeatureName, feature)
}
key := split[0] + ":" + split[1]
key := featureSetName + ":" + featureSetVersion
if fs, ok := featureSetMap[key]; !ok {
version, err := strconv.Atoi(split[1])
version, err := strconv.Atoi(featureSetVersion)
if err != nil {
return nil, fmt.Errorf(ErrInvalidFeatureName, feature)
}
featureSetMap[key] = &serving.GetOnlineFeaturesRequest_FeatureSet{
Name: split[0],
Name: featureSetName,
Version: int32(version),
FeatureNames: []string{split[2]},
FeatureNames: []string{featureName},
MaxAge: &duration.Duration{Seconds: int64(maxAgeSeconds)},
}
} else {
fs.FeatureNames = append(fs.GetFeatureNames(), split[2])
fs.FeatureNames = append(fs.GetFeatureNames(), featureName)
}
}
var featureSets []*serving.GetOnlineFeaturesRequest_FeatureSet
Expand Down

0 comments on commit 1c70ef8

Please sign in to comment.