Db4o marshaller implementation uses reflection to detect class fields. This approach is universal, but reflection usage imposes a certain performance penalty. In some cases you may want to improve the performance using custom marshallers through a plug-in interface:
Java:
Db4o.configure().objectClass(YourClass.class).marshallWith(yourMarshaller);
Custom marshaller provides a functionality to convert object fields to a byte array and back. This approach allows to achieve a better performance due to the following:
However there are certain limitations:
Custom marshallers should implement an ObjectMarshaller interface:
Java:
public class CustomMarshaller
implements ObjectMarshaller
To simplify the task of creating custom marshallers db4o provides a PrimitiveCodec class, which implements write and read functions for int and long values.