Skip to content

Commit

Permalink
release arrow context before any return
Browse files Browse the repository at this point in the history
  • Loading branch information
piket committed Oct 9, 2023
1 parent 9a9577b commit bb36c81
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions go/internal/feast/transformation/transformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ func AugmentResponseWithOnDemandTransforms(
for name, values := range requestData {
requestContextArrow[name], err = types.ProtoValuesToArrowArray(values.Val, arrowMemory, numRows)
if err != nil {
ReleaseArrowContext(requestContextArrow)
return nil, err
}
}

for name, values := range entityRows {
requestContextArrow[name], err = types.ProtoValuesToArrowArray(values.Val, arrowMemory, numRows)
if err != nil {
ReleaseArrowContext(requestContextArrow)
return nil, err
}
}
Expand All @@ -80,19 +82,24 @@ func AugmentResponseWithOnDemandTransforms(
fullFeatureNames,
)
if err != nil {
ReleaseArrowContext(requestContextArrow)
return nil, err
}
result = append(result, onDemandFeatures...)

// Release memory used by requestContextArrow
for _, arrowArray := range requestContextArrow {
arrowArray.Release()
}
ReleaseArrowContext(requestContextArrow)
}

return result, nil
}

func ReleaseArrowContext(requestContextArrow map[string]arrow.Array) {
// Release memory used by requestContextArrow
for _, arrowArray := range requestContextArrow {
arrowArray.Release()
}
}

func CallTransformations(
featureView *model.OnDemandFeatureView,
retrievedFeatures map[string]arrow.Array,
Expand Down

0 comments on commit bb36c81

Please sign in to comment.