Note that there are some explanatory texts on larger screens.

plurals
  1. POOutOfMemoryError caused when db4o databse has 15000+ objects
    text
    copied!<p>I am using db4o 8.0. </p> <p>I have a class </p> <pre><code>PostedMessage{ @Indexed long receivedTime; @Indexed long sentTime; ... //getter methods and setter methods for all the fields. } </code></pre> <p>I persist the PostedMessage objects to db4o database. I have already saved 15000+ objects to db4o database. And now when I run following query, it results in OutOfMemoryError.</p> <pre><code> //Query to get PostedMessages between "start" and "end" dates. Query q = db.query(); q.constrain(PostedMessage.class); Constraint from = q.descend("receivedTime").constrain(new Long(start.getTimeInMillis())).greater().equal(); q.descend("receivedTime").constrain(new Long(end.getTimeInMillis())).smaller().equal().and(from); q.execute();//results in OutOfMemoryError </code></pre> <p>To avoid the OutOfMemoryError, I need to add indexes to the fields of PostedMessage class. <a href="http://community.versant.com/Forums/tabid/98/aft/5258/Default.aspx" rel="nofollow">Read This</a>. </p> <p>I have a server/client configuration. I don't have control over pre-configuring the ObjectContainer before opening it.</p> <p>I will have to apply/append the indexing CommonConfiguration after the ObjectContainer is just opened and provided to me.</p> <p>I know how to create the config. </p> <pre><code> EmbeddedConfiguration appendConfig = Db4oEmbedded.newConfiguration(); appendConfig.common().objectClass(EmailMessage.class).objectField("receivedTime").indexed(true); appendConfig.common().objectClass(EmailMessage.class).objectField("sentTime").indexed(true); </code></pre> <p>I am not able to figure out how to apply this config to already opened ObjectContainer. How can I add indexes to the just opened ObjectContainer?</p> <p>Is <strong>EmbeddedConfigurationItem's apply()</strong> method the answer? If it is, can I get a sample code that shows how to use it?</p> <p>Edited : Added @Indexed annotation later to the question.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload