Java Google App Engine:检索按属性排序并插入的所有实体以供以后检索,但保持其插入顺序

发布于 2024-11-07 19:26:00 字数 2520 浏览 0 评论 0原文

我正在使用 Java Google App Engine 和 Objectify3.0(因此某些类型可能看起来与标准 JPO/JPA 不同)。

无论如何,我希望能够检索按属性排序的所有实体并将其插入以供以后检索,以便您按照插入的排序顺序获取结果。

基本上,这意味着我想要一些东西:

  • 检索所有实体(大约 10,000 个) 按“名称”升序排序。如果我尝试获取,将达到 30 秒响应限制 所有实体都一次性完成。
  • 将顺序检索的实体插入另一种名为: 按游戏名称排序。这与游戏完全相同(见下文)。
  • 从 SortedByNameGame 类型中检索实体(使用过滤器,例如流派=动作),但拥有它们 以升序排列的“名称”属性顺序返回,其中 实体被插入。

我的游戏类型如下所示:

public class Game {
    @Id private Long id; //This is my key, auto generated by objectify  
    private String name;
    private String genre; 
    private Date releasedate;

    //ommitting getters and setters 
}

我的 SortedByNameGame 类型如下所示:

public class SortedByNameGame {
    @Id private Long id; //This is my key, auto generated by objectify  
    private Long gameid; //This is the Long id of the Game kind shown above
    private String name;
    private String genre; 
    private Date releasedate;

    //ommitting getters and setters 
}

我已经考虑并尝试了几种方法(围绕递归请求)但没有成功。例如:

我怀疑请求相同 URL/Servlet 的递归方法是不可能的,即“为了防止应用程序导致请求的无限递归,不允许请求处理程序获取自己的 URL。仍然可以通过其他方式导致无限递归,因此如果您的应用可以获取用户提供的 URL 请求,请务必小心。”(来源http://code.google.com/appengine/docs/java/urlfetch/overview.html#Responses


我的问题是

  1. 我做错了什么,导致这些递归队列任务没有被创建或递归请求不起作用?

  2. 或者,还有哪些其他方法可以实现我想要的功能?

I'm using Java Google App Engine with Objectify3.0 (so some of the kinds may look different to standard JPO/JPA).

Anyways, I want to be able to retrieve all entities sorted by a property and insert it for later retrieval so that you get the results back in the sorted order that it was inserted.

Basically, this means I want a few things:

  • Retrieve all entities (around 10,000)
    sorted by "name" in ascending order.The 30 seconds response limit will be hit if I try to get
    all of the entities in one go.
  • Insert the order retrieved entities into another kind called:
    SortedByNameGame. This is the exact same kind as game (see below).
  • Retrieve entities (with filters e.g. genre = action) from the SortedByNameGame kind but have them
    returned in the sorted ascending "name" property order in which
    entities were inserted.

My Game kind looks like this:

public class Game {
    @Id private Long id; //This is my key, auto generated by objectify  
    private String name;
    private String genre; 
    private Date releasedate;

    //ommitting getters and setters 
}

My SortedByNameGame kind looks like this:

public class SortedByNameGame {
    @Id private Long id; //This is my key, auto generated by objectify  
    private Long gameid; //This is the Long id of the Game kind shown above
    private String name;
    private String genre; 
    private Date releasedate;

    //ommitting getters and setters 
}

I've considered and tried a couple of approaches (all around recursive requests) but have been unsuccessful. For example:

I suspect that recursive approach of requesting the same URL/Servlet aren't possible i.e. "To prevent an app from causing an endless recursion of requests, a request handler is not allowed to fetch its own URL. It is still possible to cause an endless recursion with other means, so exercise caution if your app can be made to fetch requests for URLs supplied by the user." (source: http://code.google.com/appengine/docs/java/urlfetch/overview.html#Responses)


My questions are

  1. What am I doing wrong such that these recursive queue tasks aren't being created or recursive requests aren't working?

  2. Alternatively, what other approaches exist to do what I want?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文