简体   繁体   中英

Can I store HashSet to Firestore document (Java)

I am retrieving a list from Firestore and checking if it contains a particular string. This list can have thousands of entries. But I have found out the HashSet.contains is much faster than List.contains (sometimes up to 20 times faster). So I'm trying to find out if a HashSet can be saved to Firestore so that searching through the set is faster than searching through a list if it were a list.

From research, I have found that Firestore supports particular data types. I know that Firestore supports Maps and that HashSet uses Maps internally. So does this mean that HashSet is a supported data type?

https://firebase.google.com/docs/firestore/manage-data/data-types

So I'm trying to find out if a HashSet can be saved to Firestore

As specified in the official documentation regarding data types :

A HashSet is not a supported data type.

So does this mean that HashSet is a supported data type?

It doesn't. There is no way you can save a HashSet as a property in a document. You can save it as a Map or as an array and then convert it to a HashSet on the client.

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