In terms of performance and convenience which is better, using Custom Object or Map in Java to store/retrieve documents in Firestore. Does using Custom Object cause performance issues?
// HashMap
Map<String, Object> sampleMap = new HashMap<>();
sampleMap.put("name","sample1");
sampleMap.put("age", 26);
// Custom Class
class Sample {
String name;
int age;
public Sample(String name, int age) {
this.name = name;
this.age = age;
}
public void setName(String name) {
this.name = name;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
}
// Custom Object
Sample sample = new Sample("sample1", 26);
FirestoreOptions firestoreOptions =
FirestoreOptions.getDefaultInstance().toBuilder().setProjectId("project-id")
.setCredentials(GoogleCredentials.getApplicationDefault()).build();
Firestore db = firestoreOptions.getService();
// using Custom Object
db.collection("SampleData").document().set(sample);
// using HashMap
db.collection("SampleData").document().set(sampleMap);
Which is better for an application with 100 reads/100 writes per second?
Does having a custom class justify the performance cost (if any)?