Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixing go static analyzer warnings #174

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions go/internal/feast/onlinestore/cassandraonlinestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/feast-dev/feast/go/protos/feast/serving"
"github.com/feast-dev/feast/go/protos/feast/types"
"github.com/gocql/gocql"
"github.com/golang/protobuf/proto"
"github.com/rs/zerolog/log"
"google.golang.org/protobuf/proto"

"google.golang.org/protobuf/types/known/timestamppb"
gocqltrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/gocql/gocql"
Expand Down Expand Up @@ -380,7 +380,7 @@ func (c *CassandraOnlineStore) UnbatchedKeysOnlineRead(ctx context.Context, enti
var eventTs time.Time
var valueStr []byte
var deserializedValue types.Value
rowFeatures := make(map[string]FeatureData)
rowFeatures := make(map[string]*FeatureData)
for scanner.Next() {
err := scanner.Scan(&entityKey, &featureName, &eventTs, &valueStr)
if err != nil {
Expand All @@ -394,7 +394,7 @@ func (c *CassandraOnlineStore) UnbatchedKeysOnlineRead(ctx context.Context, enti

if deserializedValue.Val != nil {
// Convert the value to a FeatureData struct
rowFeatures[featureName] = FeatureData{
rowFeatures[featureName] = &FeatureData{
Reference: serving.FeatureReferenceV2{
FeatureViewName: featureViewName,
FeatureName: featureName,
Expand All @@ -413,9 +413,20 @@ func (c *CassandraOnlineStore) UnbatchedKeysOnlineRead(ctx context.Context, enti
}

for _, featName := range featureNames {
featureData, ok := rowFeatures[featName]
if !ok {
featureData = FeatureData{

if featureData, exists := rowFeatures[featName]; exists {
results[rowIdx][featureNamesToIdx[featName]] = FeatureData{
Reference: serving.FeatureReferenceV2{
FeatureViewName: featureData.Reference.FeatureViewName,
FeatureName: featureData.Reference.FeatureName,
},
Timestamp: timestamppb.Timestamp{Seconds: featureData.Timestamp.Seconds, Nanos: featureData.Timestamp.Nanos},
Value: types.Value{
Val: featureData.Value.Val,
},
}
} else {
results[rowIdx][featureNamesToIdx[featName]] = FeatureData{
Reference: serving.FeatureReferenceV2{
FeatureViewName: featureViewName,
FeatureName: featName,
Expand All @@ -427,7 +438,7 @@ func (c *CassandraOnlineStore) UnbatchedKeysOnlineRead(ctx context.Context, enti
},
}
}
results[rowIdx][featureNamesToIdx[featName]] = featureData

}
}(serializedEntityKey)
}
Expand Down Expand Up @@ -516,7 +527,7 @@ func (c *CassandraOnlineStore) BatchedKeysOnlineRead(ctx context.Context, entity
var valueStr []byte
var deserializedValue types.Value
// key 1: entityKey - key 2: featureName
batchFeatures := make(map[string]map[string]FeatureData)
batchFeatures := make(map[string]map[string]*FeatureData)
for scanner.Next() {
err := scanner.Scan(&entityKey, &featureName, &eventTs, &valueStr)
if err != nil {
Expand All @@ -530,9 +541,9 @@ func (c *CassandraOnlineStore) BatchedKeysOnlineRead(ctx context.Context, entity

if deserializedValue.Val != nil {
if batchFeatures[entityKey] == nil {
batchFeatures[entityKey] = make(map[string]FeatureData)
batchFeatures[entityKey] = make(map[string]*FeatureData)
}
batchFeatures[entityKey][featureName] = FeatureData{
batchFeatures[entityKey][featureName] = &FeatureData{
Reference: serving.FeatureReferenceV2{
FeatureViewName: featureViewName,
FeatureName: featureName,
Expand All @@ -553,9 +564,20 @@ func (c *CassandraOnlineStore) BatchedKeysOnlineRead(ctx context.Context, entity
for _, serializedEntityKey := range keyBatch {
for _, featName := range featureNames {
keyString := serializedEntityKey.(string)
featureData, ok := batchFeatures[keyString][featName]
if !ok {
featureData = FeatureData{

if featureData, exists := batchFeatures[keyString][featName]; exists {
results[serializedEntityKeyToIndex[keyString]][featureNamesToIdx[featName]] = FeatureData{
Reference: serving.FeatureReferenceV2{
FeatureViewName: featureData.Reference.FeatureViewName,
FeatureName: featureData.Reference.FeatureName,
},
Timestamp: timestamppb.Timestamp{Seconds: featureData.Timestamp.Seconds, Nanos: featureData.Timestamp.Nanos},
Value: types.Value{
Val: featureData.Value.Val,
},
}
} else {
results[serializedEntityKeyToIndex[keyString]][featureNamesToIdx[featName]] = FeatureData{
Reference: serving.FeatureReferenceV2{
FeatureViewName: featureViewName,
FeatureName: featName,
Expand All @@ -567,7 +589,6 @@ func (c *CassandraOnlineStore) BatchedKeysOnlineRead(ctx context.Context, entity
},
}
}
results[serializedEntityKeyToIndex[keyString]][featureNamesToIdx[featName]] = featureData
}
}
}(batch, cqlStatement)
Expand Down
Loading