Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 有没有加入app engine的解决方案?_Java_Google App Engine_Bigtable - Fatal编程技术网

Java 有没有加入app engine的解决方案?

Java 有没有加入app engine的解决方案?,java,google-app-engine,bigtable,Java,Google App Engine,Bigtable,我有以下数据模型: class StadiumOccupant { String stadiumname; String username; } class Friend { String username; String friendname; } 我想找到体育场里的所有用户,他们也是我的朋友。我可以这样做: List<String> friendsAtStadium; String stadiumId = 'xyz'; List<Friend>

我有以下数据模型:

class StadiumOccupant {
  String stadiumname;
  String username;
}

class Friend {
  String username;
  String friendname;
}
我想找到体育场里的所有用户,他们也是我的朋友。我可以这样做:

List<String> friendsAtStadium;
String stadiumId = 'xyz';

List<Friend> friends = select from Friend where username = 'me';
for (Friend friend : friends) {
  List<StadiumOccupant> friendAtStadium = 
    select from StadiumOccupant where 
    stadiumname = stadiumId and
    username = friend.friendname;
  friendsAtStadium.addAll(friendAtStadium);
}
因此,如果我是用户“john”,我的朋友是:{tim,mary}。
如果我使用stadiumname='abc'运行stadium查询,我应该返回{tim}。

对于少量数据,您可以按您的建议执行。对于较大的数据量,您无论如何都不会进行连接,即使您的后端使用SQL数据库

你的问题几乎就是典型的社交网络数据问题。最有可能的情况是,您希望对数据进行非规范化,并在用户更新其状态时将信息“推送”到用户的所有好友列表中,或者可能像上面所做的那样将其拉入。最佳解决方案取决于数据的形状,以及您希望优化哪些查询以进行检索或更新


更多信息,请参见我的答案,包括facebook工程师的帖子。

是否允许更改数据建模?
username=friend.getUsername()@Edward:是的,我可以改变造型,我想知道是否有任何可能的方法可以做到这一点。@Andrei:你是对的,纠正了这个错误。一个人一次可以在多个体育场吗?“体育场占用率”可能是用户的财产。或者,我想更准确地说,一个人实体的子实体?
Friend { john, tim }
Friend { john, mary }
Friend { mary, frank }

StadiumOccupant { abc, tim }
StadiumOccupant { abc, frank }
StadiumOccupant { abc, kim }