[英]What is the fastest way to get data from Firestore?
I have a collection of locations. 我有一些地点。 For each location I have created a POJO class:
对于每个位置,我创建了一个POJO类:
class Location {
public String locationName;
public String locationId;
... Many more
}
There are about 29 properties, including arrays and other objects. 大约有29个属性,包括数组和其他对象。
Which is faster, to get the data like this: 获得数据的速度更快:
Location location = document.toObject(Location.class);
Or like this: 或像这样:
Map<String, Object> map = document.getData();
And then iterate through the map and get the values. 然后遍历地图并获取值。
And why? 又为什么呢? Thanks!
谢谢!
The second option is faster. 第二个选项更快。 The first option requires the client app to use reflection to map all the fields to object members.
第一个选项要求客户端应用程序使用反射将所有字段映射到对象成员。 This reflection is always much slower than reaching into a Map directly, even if it's more lines of code in the app.
这种反射总是比直接进入Map慢得多,即使应用程序中的代码行较多也是如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.