eantyshev commented on code in PR #24751:
URL: https://github.com/apache/beam/pull/24751#discussion_r1056206459
##########
playground/backend/internal/db/datastore/datastore_db.go:
##########
@@ -519,27 +521,26 @@ func rollback(tx *datastore.Transaction) {
}
}
-func getEntities[V entity.DatastoreEntity](tx *datastore.Transaction, keys
[]*datastore.Key) ([]*V, error) {
- var entitiesWithNils = make([]*V, len(keys))
- entities := make([]*V, 0)
+// generic wrapper around GetMulti & filtering nil elements
+func getEntities[V any](tx *datastore.Transaction, keys []*datastore.Key)
([]*V, error) {
+ entitiesWithNils := make([]*V, len(keys))
+ entitiesNotNil := make([]*V, 0)
if err := tx.GetMulti(keys, entitiesWithNils); err != nil {
if errorsVal, ok := err.(datastore.MultiError); ok {
- for _, errVal := range errorsVal {
- if errors.Is(datastore.ErrNoSuchEntity, errVal)
{
Review Comment:
Previous logic was slightly brain-damaged: if there's ErrNoSuchEntity in a
MultiError, then we skip all other errors
Currently it is reduced to this: if there was MultiError, we filter out nil
entities from the result.
Go client also guarantees, that `MultiError` and `entitiesWithNils` have the
same length and items positions (that fact was ignored in the previous version).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]