KryoSerializers { public static Output serializeDocumentForIndexing(Object o, int maxSize) { Kryo k = getKryoThreadLocalForDocuments(); byte[] buffer = getBuffer(DEFAULT_BUFFER_SIZE_BYTES); OutputWithRoot out = new OutputWithRoot(buffer, maxSize, o); k.writeClassAndObject(out, o); return out; } private  KryoSerializers(); static Kryo create(boolean isObjectSerializer); static void register(ThreadLocal<Kryo> kryoThreadLocal, boolean isDocumentSerializer); static Output serializeDocument(ServiceDocument o, int maxSize); static Output serializeAsDocument(Object o, int maxSize); static Output serializeDocumentForIndexing(Object o, int maxSize); static int serializeObject(Object o, byte[] buffer, int position); static ByteBuffer serializeObject(Object o, int maxSize); static T clone(T t); static T cloneObject(T t); static byte[] getBuffer(int capacity); static Object deserializeObject(ByteBuffer bb); static Object deserializeObject(byte[] bytes, int position, int length); static Object deserializeDocument(byte[] bytes, int position, int length); static Object deserializeDocument(ByteBuffer bb); static final long THREAD_LOCAL_BUFFER_LIMIT_BYTES; }
@Test public void serializeDocumentForIndexing() { ExampleServiceState state = new ExampleServiceState(); state.documentSelfLink = "selfLink"; state.documentKind = Utils.buildKind(ExampleServiceState.class); Output o = KryoSerializers.serializeDocumentForIndexing(state, 2048); ExampleServiceState deser = (ExampleServiceState) KryoSerializers.deserializeDocument( o.getBuffer(), 0, o.position()); assertNull(deser.documentSelfLink); assertNull(deser.documentKind); }