gpt4 book ai didi

Java Google App Engine 批量加载器上传错误 “OverflowError: date value out of range”

转载 作者:行者123 更新时间:2023-11-30 11:53:23 24 4
gpt4 key购买 nike

我正在使用批量加载器从一个 GAE 服务器下载我的评论 类型并上传到另一个 GAE 服务器。这种评论 类型包含大约 30,000 个实体。

我使用命令上传:

appcfg.py upload_data --kind=Review --filename=review.csv --application=<MY_APP_ID> --url=http://<MY_APP_ID>.appspot.com/remote_api --rps_limit=500 --bandwidth_limit=2500000 --batch_size=100

注意:整个错误很长。所以我把它放在了这个问题的底部。

上传根本没有开始,并在以下行停止:[INFO] Opening database: bulkloader-progress-20110611.222101.sql3

我在整个跟踪的底部看到:lambda val: _EPOCH + datetime.timedelta(microseconds=val), OverflowError: date value out of range

我怀疑这是由于在我的 publisheddate 列中发现格式错误的日期造成的(请参阅下面的完整评论 类型)。


我已经尝试修复它

我在 GAE 管理门户中运行了 GQL:SELECT * FROM Review where publisheddate = null,发现大约 15 个实体的 publisheddate< 为 null 值/strong> 专栏。所以我删除了那些,重新下载并尝试重新上传评论类型。我仍然遇到同样的错误。

我在想,因为我使用的是没有配置文件参数的上传命令,例如--config_file=bulkloader.yaml(见上面上传我没有指定--config_file)

我依靠数据存储区统计信息来确定下载到我的 review.csv 文件的内容。

现在,因为我刚刚删除了带有 null publisheddate 的实体,所以重新下载然后立即重新上传与我最初的下载和上传没有任何不同。由于数据存储区统计信息尚未更新。


我的问题

  1. 由于有 30, 000 个实体,我不确定如何找到日期格式错误的实体。是否有快速定位具有错误 publisheddate 值的实体的方法?

  2. 有谁知道如何解决这个问题?从错误跟踪中我不确定真正的问题是什么。


评论类型

我正在使用 objectify3.0.jar 来操作我的 GAE 数据存储。所以我的评论类看起来是这样的:

public class Review {
@Id private Long id; //This is my key property, auto generated by objectify
private String reviewlink;
private Date publisheddate;
private double rating;
private Long gameid; //to make querying easier

//ommitting getters and setters
}

整个错误

10:20:48>appcfg.py upload_data --kind=Review --filename=review.csv --application=<MY_APP_ID> --url=http://<MY_APP_ID>.appspot.com/remote_api --rps_limit=500 --bandwidth_limit=2500000 --batch_size=100
Uploading data records.
[INFO ] Logging to bulkloader-log-20110611.222101
[INFO ] Throttling transfers:
[INFO ] Bandwidth: 2500000 bytes/second
[INFO ] HTTP connections: 8/second
[INFO ] Entities inserted/fetched/modified: 500/second
[INFO ] Batch Size: 100
[INFO ] Opening database: bulkloader-progress-20110611.222101.sql3
Traceback (most recent call last):
File "/usr/local/bin/appcfg.py", line 76, in <module>
run_file(__file__, globals())
File "/usr/local/bin/appcfg.py", line 72, in run_file
execfile(script_path, globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 3592, in <module>
main(sys.argv)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 3583, in main
result = AppCfgApp(argv).Run()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 2229, in Run
self.action(self)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 3368, in __call__
return method()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 3195, in PerformUpload
run_fn(args)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 3087, in RunBulkloader
sys.exit(bulkloader.Run(arg_dict))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 4360, in Run
return _PerformBulkload(arg_dict)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 4204, in _PerformBulkload
loader.initialize(filename, loader_opts)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 2879, in initialize
self.high_id_table = self._find_high_id(self.generate_records(filename))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 2896, in _find_high_id
for values in record_generator:
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 2920, in generate_records
yield datastore.Entity._FromPb(fixed_entity_proto)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/datastore.py", line 958, in _FromPb
value = datastore_types.FromPropertyPb(prop)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/datastore_types.py", line 1792, in FromPropertyPb
value = conversion(value)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/datastore_types.py", line 1722, in <lambda>
lambda val: _EPOCH + datetime.timedelta(microseconds=val),
OverflowError: date value out of range

最佳答案

查找问题行的方法

我用来查找有问题的行的方法是使用批量加载器WITH 一个配置文件来下载每一行,直到它到达无法下载的行。纠正有问题的行后,下载/上传工作正常。

注意:事实上,它是多行,但一旦我找到第一行,只需用有问题的数据查找/替换其他行即可。

我用来查找行的命令是:

appcfg.py upload_data --coinfig_file=bulkloader.yaml --kind=Review --filename=review.csv --application=<MY_APP_ID> --url=http://<MY_APP_ID>.appspot.com/remote_api --rps_limit=500 --bandwidth_limit=2500000 --batch_size=100

注意:在我上面的问题中,我没有使用配置文件。在上面的这个命令中。我正在使用配置文件。此配置文件是使用此命令从数据存储区统计信息生成的:

appcfg.py create_bulkloader_config --filename=bulkloader.yaml --application=<appname> --url=http://<appname>.appspot.com/remote_api

使用配置文件的主要原因是它下载我的数据存储,格式为正确的 csv 文件。


问题?

出于某种原因,当您没有为批量加载程序指定配置文件时。下载的 csv 很乱,即它包含很多随机字符。但是,将这些文件上传回您的数据存储没有问题。

为什么格式正确的 csv 文件和这些杂乱的 csv 文件在上传到您的数据存储时都能正常工作?


有问题的行

实际问题是 publisheddate 属性的某些数据的值设置为 00/00/0000 (MM/DD/YYYY)。 Java 将其转换为 Date,值为 Sunday 2nd January 0001(不要引用我的值,但我记得它是 0001 年)。

这可以很好地插入到 GAE 数据存储中,但是当批量加载程序尝试下载或上传这些值时,它会报错:lambda val: _EPOCH + datetime.timedelta(microseconds=val), OverflowError : 日期值超出范围 如上所示。

关于Java Google App Engine 批量加载器上传错误 “OverflowError: date value out of range”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6316096/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com