简体   繁体   中英

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:

class Location {
    public String locationName; 
    public String locationId;
    ... Many more
}

There are about 29 properties, including arrays and other objects.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM