OpenHFT/Java-Lang — pull request #46 by RuedigerMoeller (2014-06-22 17:04:04+00:00)
Title: make serialization pluggable

allows to optionally use fast serialization as default (speeds up 8-10 times for pojos). NO dependency added.

* added ObjectStreamFactory providing ObjectOutput/ObjectInput instances
* BytesMarshallerFactory implements ObjectStreamFactory
* added and implementation of ObjectStreamFactory for JDK serialization
* lame: added global static var to VanillaBytesMarshallerFactory. I could not find a way to inject this otherwise
* added flush() statement after writing an Object.

speedup in iteration for this class is from 50k per second to 480k per second (on a slow AMD opteron 2.x Ghz)

```java
class TestRec extends Record {

String name = "Bla";
String other = "Bla1";
String another = "Bla3";

int x = 13;
int arr[] = {1,2,3,4,5};
..
}
```
with this factory impl (requires **fst 2.0 beta !!! from releases section**):
```java
public class HugeCollectionsBinaryStorage implements BinaryStorage {

public static FSTConfiguration conf = FSTConfiguration.getDefaultConfiguration();

static {
VanillaBytesMarshallerFactory.defaultOSFactory = new ObjectStreamFactory() {
@Override
public ObjectOutput getObjectOutput(OutputStream out) throws IOException {
return conf.getObjectOutput(out);
}

@Override
public ObjectInput getObjectInput(InputStream in) throws IOException {
return conf.getObjectInput(in);
}
};
}
....
}
```