简体   繁体   English

从Firestore获取数据的最快方法是什么?

[英]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.

相关问题 从Java应用程序获取数据到Cassandra 2的最快方法是什么? - What is the fastest way to get data into Cassandra 2 from a Java application? 从ArrayList过滤数据的最快方法是什么? - What is the fastest way to filter data from ArrayList? 什么是从Oracle数据库获取大量数据到Java对象的最快方法 - what's the fastest way to get a large volume of data from an Oracle database into Java objects 从URL获取域/主​​机名的最快方法是什么? - What is the fastest way to get the domain/host name from a URL? 将数据从应用程序(Java)导入临时表的最快方法是什么? - What is the fastest way to import data from application (Java) into temporary table? 从数据库中检索顺序数据的最快方法是什么? - What is the fastest way to retrieve sequential data from database? 将 memory 中的大量数据写入文件的最快方法是什么? - What is the fastest way to write a large amount of data from memory to a file? 从在线托管的mysql数据库中检索数据的最快方法是什么? - What is the fastest way of retrieving data from mysql database hosted online? 获取集合元素的最快方法是什么? - What is the fastest way to get the elements of a collection? 在Java中,获取系统时间最快的方法是什么? - In Java, what is the fastest way to get the system time?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM