是否有可能在客户端使用客观化的ID?

时间:2023-02-11 23:12:10

I'm working on an android app with a GAE endpoint backend. I want to on the android side access the Id from an objectify entity, but it doesn't seem to exist on the client side. Is there a reason for this, or a way round it?

我正在使用带有GAE端点后端的Android应用程序。我想在android端从一个客观化的实体访问Id,但它似乎不存在于客户端。这有什么理由,还是绕道而行呢?

1 个解决方案

#1


0  

I'm not sure I understand you completely, but I'll make some comments. First, objectify ID are just datastore ID's, which can be represented as a String or a long (actually just 56bits of a long).

我不确定我完全理解你,但我会发表一些评论。首先,客观化ID只是数据存储区ID,可以表示为String或long(实际上只有56位长)。

So it is no problem to communicate these ID's between your Android app and your server. If you want to use them as ID's on Android, i.e. for storing records in sqlite, that would be fine for the long id's. The String ID's could be hashed into a long ID suitable for use as an ID on Android, but you would have to evaluate the potential for a hash collision.

因此,在您的Android应用和服务器之间传递这些ID是没有问题的。如果你想在Android上使用它们作为ID,即用于在sqlite中存储记录,那对于长ID来说就没问题了。字符串ID可以被散列为适合在Android上用作ID的长ID,但您必须评估散列冲突的可能性。

#1


0  

I'm not sure I understand you completely, but I'll make some comments. First, objectify ID are just datastore ID's, which can be represented as a String or a long (actually just 56bits of a long).

我不确定我完全理解你,但我会发表一些评论。首先,客观化ID只是数据存储区ID,可以表示为String或long(实际上只有56位长)。

So it is no problem to communicate these ID's between your Android app and your server. If you want to use them as ID's on Android, i.e. for storing records in sqlite, that would be fine for the long id's. The String ID's could be hashed into a long ID suitable for use as an ID on Android, but you would have to evaluate the potential for a hash collision.

因此,在您的Android应用和服务器之间传递这些ID是没有问题的。如果你想在Android上使用它们作为ID,即用于在sqlite中存储记录,那对于长ID来说就没问题了。字符串ID可以被散列为适合在Android上用作ID的长ID,但您必须评估散列冲突的可能性。