doutun9179 2014-09-07 01:29
浏览 43

Golang-AppEngine数据存储区GetMulti()返回MultiError时是否返回无效数据?

I am calling into the AppEngine Datastore to get data that may or may not be stored; I am not concerned with a multi error except in the case that all of the multi error entries return an error.

err := datastore.GetMulti(context, keys, data)
if err_entries, ok := err.(appengine.MultiError); ok {
    for _, err_entry := range err_entries {
        if err_entry == nil {
            return data, nil
        }
    }
}
return data, err

My question is whether the data returned, given that one err_entry of a multi error is nil, will contain false, empty, or corrupt data entries for keys that match an error in the multi error. It works as expected for now but I don't know what potential exceptions might come up or if this is horrendous for some idiomatic reason.

  • 写回答

1条回答 默认 最新

  • drblhw5731 2014-09-07 02:40
    关注

    Right from https://developers.google.com/appengine/docs/go/reference#MultiError:

    MultiError is returned by batch operations when there are errors with particular elements.

    Errors will be in a one-to-one correspondence with the input elements; successful elements will have a nil entry.

    It will never have data, each i, err_entry is either nil or an error linked to data[i].

    评论

报告相同问题?

悬赏问题

  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程