[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extremely large inner DocumentReferences #12959

Closed
Mayco-Anderson opened this issue May 14, 2024 · 3 comments
Closed

Extremely large inner DocumentReferences #12959

Mayco-Anderson opened this issue May 14, 2024 · 3 comments
Assignees
Labels
api: firestore Issues related to the Firestore API. needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue.

Comments

@Mayco-Anderson
Copy link
Mayco-Anderson commented May 14, 2024

I am successfully recovering documents from firestore using the this package. Yet, one thing that I find really strange, is that my data models have some inner references to other DocumentReferences and while I would expect those references to be very light, like a string with the path to the document, they in reality are very large objects.

As an example, I have a data mode like "exam". The exam has documentReferences to another User document and a patient reference.
If I use documentSnapshot.ToDictionary(), the resulting dictionary is so large, that if I try to parse into a json and print it into the screen, I run out of memory. Yet, those documents should be very very light, less than 0.1 mb of data.
From this dictionary, If I capture a DocumentReference alone, and save the resulting as a Json string, the resulting text file is more than 5mb of data.

Am I doing something wrong, or is there another way to force those DocumenReferences have less information? Following is my code:

   public async Task<List<T>> GetDocumentListAsync<T>(string collectionName, Func<Query, Query>? queryBuilder = null) where T : BaseFirestoreDocument<T>, new()
   {
       var collectionRef = _firestoreDb.Collection(collectionName);
       Query query = collectionRef;

       if (queryBuilder != null)
       {
           query = queryBuilder(query);
       }

       var snapshot = await query.GetSnapshotAsync();

       List<T> documents = new List<T>();
       Parallel.ForEach(snapshot.Documents, documentSnapshot =>
       {
           if (!documentSnapshot.Exists) return;

           var document = documentSnapshot.ConvertTo<T>();
           document.Reference = documentSnapshot.Reference;
           documents.Add(document);
       });
      
       return documents;
   }
@jskeet
Copy link
Collaborator
jskeet commented May 14, 2024

My guess is that it's due to the way you're converting the result to JSON, and I don't know what you're doing there.

Please could you post a short but complete program which demonstrates the problem (ideally including populating a small data set)? A DocumentReference itself is very small, but if you're using some form of JSON serialization which recursively walks all properties (which would include a reference to the FirestoreDb) then that could cause problems. (You probably just want to serialize the Path property.)

@jskeet jskeet added type: question Request for information or clarification. Not an issue. api: firestore Issues related to the Firestore API. needs more info This issue needs more information from the customer to proceed. labels May 14, 2024
@jskeet
Copy link
Collaborator
jskeet commented May 17, 2024

Please provide more information - there's nothing more we can do without more details.
I'll close this issue early next week if we don't hear anything more.

@jskeet
Copy link
Collaborator
jskeet commented May 20, 2024

Closing due to a lack of information.

@jskeet jskeet closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the Firestore API. needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants