[JAVA-1050] Establishing an empty array during insert Created: 14/Nov/13  Updated: 11/Sep/19  Resolved: 15/Nov/13

Status: Closed
Project: Java Driver
Component/s: Command Operations
Affects Version/s: 2.4
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Matt Reichert Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

development



 Description   

Hi there,

We're setting up a document collection that will hold 24 months of data result sets that we'll use to supply data to our reporting applications.
We're currently using an array to hold the result sets, each element in the array contains the rows of data that pertain to a particular month.

We're going to build up the documents month-by-month, and are using a TTL index (so we have PowerOf2Sizes for the collection). I thought I had understood that we can help with space allocation by allocating 24 elements to the array when we first create the document.

My question is, what's the most efficient way to do that? I thought I could use the $setOnInsert property to establish the array, then use a $set in the same update statement to insert the element into the array, but I found that's not allowed.
Now it feels like I need to make a separate call to check whether the document exists, add the 24 element array, then have a second statement that adds the first element. Checking whether a document exists before each update statement sounds like a lot of overhead to me, so I wanted to ask the question about how best to accomplish this.

Thanks for your help!

Matt



 Comments   
Comment by Jeffrey Yemin [ 15/Nov/13 ]

Hi Matt,

This particular Jira project it for reporting bugs or requesting features for the MongoDB Java driver. I suggest you ask your question in a different forum, either StackOverflow or the mongodb-user Google group.

Regards,
Jeff

Generated at Thu Feb 08 08:53:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.