1

I'm using db4o with groovy (actually griffon). I'm saving dozen of objects into db4o objectSet and see that .yarv file size is about 11Mb. I've checked its content and found that it stores metaClass with all nested fields into every object. It's a waste of space.
Looking for the way to avoid storing of metaClass and therefore reduce the size of result .yarv file, since I'm going to use db4o to store millions of entities. Should I try callConstructors(true) db4o configuration? Think it would help? Any help would be highly appreciated.

Archer
  • 5,073
  • 8
  • 50
  • 96

2 Answers2

1

As an alternative you can just store 'Groovy'-beans instances. Those are compiled down to regular Java-ish classes with no special Groovy specific code attached to them.

Just like this:

class Customer {
    // properties
    Integer id
    String name
    Address address

}

class Address{
    String street;
}

    def customer = new Customer(id:1, name:"Gromit", address:new Address(street:"Fun"))
Gamlor
  • 12,978
  • 7
  • 43
  • 70
0

I don't know groovy but based on your description every groovy object carries metadata and you want to skip storing these objects.

If that is the case installing a "null translator" (TNull class) will cause the "translated" objects to not be stored.

PS: Call Constructor configuration has no effect on what gets stored in the db; it only affects how objects are instantiated when reading from db.

Hope this helps

Vagaus
  • 4,174
  • 20
  • 31
  • yeah, I meant exactly should I use callConstructors to allow safe instantiation of object w/o metadata. Instantiation is another big problem I guess if I'm lucky to store groovy object w/o metadata. – Archer Jul 08 '11 at 13:02
  • If you configure a null translator for the metadata class it'll not be reloaded either (since nothing was stored to start with). As of setting callConstructors(false) it depends if groovy expects this metadata object to be instantiated (I'd expect groovy to complain if these objects has no "metadata" objects associated, but as I said, I have no experience with groovy) – Vagaus Jul 08 '11 at 13:18
  • I'm no db40 expert though I can tell you a few things about Groovy and Griffon (being the project lead it would come to no surprise ;-). Basically the metaClass is used at runtime, there is no need to persist it. A brand new metaClass instance will be available when the object is retrieved form the data store, so it's safe to save a null reference to it. Please let me know if you find a way to avoid storing the metaClass field in the data store so that I can add that step to the griffon-db4o plugin so you won't have to do it yourself :-) – Andres Almiray Jul 10 '11 at 05:49