├── README ├── protowar ├── .classpath ├── .pmd ├── .project ├── .settings │ ├── .jsdtscope │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.jst.common.project.facet.core.prefs │ ├── org.eclipse.wst.common.component │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.wst.jsdt.ui.superType.container │ ├── org.eclipse.wst.jsdt.ui.superType.name │ └── org.eclipse.wst.ws.service.policy.prefs ├── WebContent │ ├── META-INF │ │ └── MANIFEST.MF │ └── WEB-INF │ │ └── web.xml └── src │ └── org │ └── protowar │ ├── ProtoServerHandler.java │ └── ProtoWar.java ├── scala_media_container ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── pom.xml └── src │ └── serializers │ └── scala │ ├── Image.scala │ ├── Media.scala │ ├── MediaContent.scala │ ├── Player.scala │ ├── Runner.scala │ ├── SbinarySerializerSupport.scala │ └── Size.scala └── tpc ├── .classpath ├── .gitignore ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── Makefile ├── README ├── attic ├── README_old ├── run ├── run-stream ├── run-wiki └── serializers.txt ├── data-stream ├── media.3.cks └── media.9.cks ├── data ├── media.1.json ├── media.2.json ├── media.3.json └── media.4.json ├── lib ├── FastInfoset-1.2.6.jar ├── aalto-xml-1.2.2.jar ├── activemq-protobuf-1.1-SNAPSHOT.jar ├── activemq-util-6.0-SNAPSHOT.jar ├── argo-2.10.jar ├── asm-4.0.jar ├── asm-commons-3.2.jar ├── avro-1.10.0.jar ├── avro-compiler-1.10.0.jar ├── avro-fastserde-0.2.4.jar ├── bson-2.7.1.jar ├── bson4jackson-2.7.0.jar ├── capnproto-runtime-0.1.1.jar ├── codemodel-2.6.jar ├── commons-beanutils-1.8.3.jar ├── commons-codec-1.3.jar ├── commons-collections-3.2.1.jar ├── commons-httpclient-3.1.jar ├── commons-lang-2.4.jar ├── commons-lang3-3.4.jar ├── commons-logging-1.1.1.jar ├── dsl-json-1.9.5.jar ├── dsl-json-java8-1.9.5.jar ├── exi-exificient-0.9.1.jar ├── extra │ └── avro-tools-1.8.2.jar ├── ezmorph-1.0.6.jar ├── fastjson-1.2.11.jar ├── flatbuffers-java-1.9.0.jar ├── flexjson-2.1.jar ├── fst-1.42.jar ├── fury-core-0.2.0.jar ├── gson-2.8.0.jar ├── guava-19.0.jar ├── helper-all-0.2.1.jar ├── hessian-4.0.7.jar ├── jackson-all-1.9.6.jar ├── jackson-annotations-2.9.0.jar ├── jackson-core-2.9.2.jar ├── jackson-databind-2.9.2.jar ├── jackson-dataformat-avro-2.9.2.jar ├── jackson-dataformat-cbor-2.9.2.jar ├── jackson-dataformat-protobuf-2.9.2.jar ├── jackson-dataformat-smile-2.9.2.jar ├── jackson-dataformat-xml-2.9.2.jar ├── jackson-dataformat-yaml-2.9.2.jar ├── jackson-jr-objects-2.9.2.jar ├── jackson-module-afterburner-2.9.2.jar ├── jackson-module-jaxb-annotations-2.9.2.jar ├── jakarta.xml.bind-api-2.3.3.jar ├── javassist-3.27.0-GA.jar ├── javax.annotation-api-1.3.2.jar ├── javax.json-1.0-b06.jar ├── javolution-5.5.1.jar ├── jboss-marshalling-2.0.9.Final.jar ├── jboss-marshalling-river-2.0.9.Final.jar ├── jboss-marshalling-serial-2.0.9.Final.jar ├── jboss-serialization-4.2.2.GA.jar ├── jopt-simple-3.2.jar ├── json-0.19-tpc.jar ├── json-lib-2.4-jdk15.jar ├── json-smart-1.0.8.jar ├── json.org-ref-2011.06.21.jar ├── json_simple-1.1.jar ├── jsonij-0.2.7.jar ├── jsonpath-2011.06.23.jar ├── kryo-5.0.0-RC6.jar ├── libthrift-0.13.0.jar ├── log4j-1.2.17.jar ├── minlog-none-1.2.jar ├── msgpack-0.6.9.jar ├── objenesis-1.2.jar ├── obser-0.9.0-SNAPSHOT.jar ├── paranamer-1.5.jar ├── protobuf-java-3.6.1.jar ├── protostuff-api-1.5.9.jar ├── protostuff-collectionschema-1.5.9.jar ├── protostuff-compiler-1.5.9-jar-with-dependencies.jar ├── protostuff-core-1.5.9.jar ├── protostuff-json-1.5.9.jar ├── protostuff-runtime-1.5.9.jar ├── protostuff-xml-1.5.9.jar ├── reflectasm-1.05.jar ├── sbinary_2.11-0.4.3-SNAPSHOT.jar ├── scala-library-2.13.3.jar ├── scala-reflect-2.13.3.jar ├── scala-xml_2.11-1.0.2.jar ├── serializer-1.1.2.jar ├── slf4j-api-1.7.14.jar ├── slf4j-log4j12-1.7.14.jar ├── snakeyaml-1.18.jar ├── stax-api-1.0.1.jar ├── stax2-api-3.0.1.jar ├── stephenerialization-3.0.0.jar ├── svenson-1.4.0.jar ├── trove-1.0.2.jar ├── velocity-1.7-dep.jar ├── velocity-1.7.jar ├── wobly-core-1.0.jar ├── woodstox-core-5.0.3.jar ├── xpp3_min-1.1.4c.jar └── xstream-1.3.1.jar ├── mk-js-stats ├── mk-stats.sh ├── pregen ├── media.capnp │ └── serializers │ │ └── capnproto │ │ └── media │ │ └── Mediacontent.java ├── media.colf │ └── serializers │ │ └── colfer │ │ └── media │ │ ├── Image.java │ │ ├── Media.java │ │ └── MediaContent.java ├── media.fbs │ └── serializers │ │ └── flatbuffers │ │ └── media │ │ ├── Image.java │ │ ├── Media.java │ │ ├── MediaContent.java │ │ ├── Player.java │ │ └── Size.java ├── media.proto │ └── serializers │ │ └── protobuf │ │ └── media │ │ └── MediaContentHolder.java └── media.thrift │ └── gen-javabean │ └── serializers │ └── thrift │ └── media │ ├── Image.java │ ├── Media.java │ ├── MediaContent.java │ ├── Player.java │ └── Size.java ├── run-bench.sh ├── schema ├── media.activemq.proto ├── media.avro ├── media.capnp ├── media.colf ├── media.fbs ├── media.proto ├── media.proto.jackson ├── media.protostuff.proto └── media.thrift ├── src ├── com │ └── google │ │ └── protobuf │ │ └── JsonFormat.java ├── data │ ├── ReprUtil.java │ └── media │ │ ├── FieldMapping.java │ │ ├── Image.java │ │ ├── Media.java │ │ ├── MediaContent.java │ │ ├── MediaContentCustom.java │ │ └── MediaTransformer.java ├── log4j.xml └── serializers │ ├── BenchmarkBase.java │ ├── BenchmarkExporter.java │ ├── BenchmarkRunner.java │ ├── FastSerialization.java │ ├── Hessian.java │ ├── JBossMarshalling.java │ ├── JBossSerialization.java │ ├── JavaBuiltIn.java │ ├── JavaManual.java │ ├── MediaItemBenchmark.java │ ├── MediaStreamBenchmark.java │ ├── MiscFeatures.java │ ├── MongoDB.java │ ├── Obser.java │ ├── Scala.scala │ ├── SerClass.java │ ├── SerFeatures.java │ ├── SerFormat.java │ ├── SerGraph.java │ ├── Serializer.java │ ├── SimpleClassLoader.java │ ├── StatsCruncher.java │ ├── Stephenerialization.java │ ├── TestCase.java │ ├── TestCaseRunner.java │ ├── TestGroup.java │ ├── TestGroups.java │ ├── Thrift.java │ ├── Transformer.java │ ├── WriteResultsToJavascript.java │ ├── avro │ ├── Avro.java │ ├── AvroGeneric.java │ ├── AvroSpecific.java │ └── AvroTransformer.java │ ├── capnproto │ └── CapNProto.java │ ├── colfer │ └── Colfer.java │ ├── datakernel │ └── DataKernelSerializer.java │ ├── dsljson │ └── DSLJson.java │ ├── flatbuffers │ └── FlatBuffers.java │ ├── fury │ └── Fury.java │ ├── jackson │ ├── AsArrayIntrospector.java │ ├── BaseJacksonDataBind.java │ ├── BaseJacksonDriver.java │ ├── JacksonAvroDatabind.java │ ├── JacksonCBORDatabind.java │ ├── JacksonJrDatabind.java │ ├── JacksonJsonDatabind.java │ ├── JacksonJsonManual.java │ ├── JacksonJsonTree.java │ ├── JacksonProtobufDatabind.java │ ├── JacksonSmileDatabind.java │ ├── JacksonSmileManual.java │ ├── JacksonWithAfterburner.java │ ├── JacksonWithColumnsDatabind.java │ ├── JacksonXmlDatabind.java │ └── StdJacksonDataBind.java │ ├── java │ ├── Image.java │ ├── Media.java │ └── MediaContent.java │ ├── javaxjson │ ├── JavaxJsonStream.java │ ├── JavaxJsonStreamGlassfish.java │ ├── JavaxJsonTransformer.java │ ├── JavaxJsonTree.java │ └── JavaxJsonTreeGlassfish.java │ ├── json │ ├── FastJSONArrayDatabind.java │ ├── FastJSONDatabind.java │ ├── FlexjsonDatabind.java │ ├── JsonArgoTree.java │ ├── JsonDotOrgManualTree.java │ ├── JsonGsonDatabind.java │ ├── JsonGsonManual.java │ ├── JsonGsonTree.java │ ├── JsonLibJsonDatabind.java │ ├── JsonPathDeserializerOnly.java │ ├── JsonSimpleManualTree.java │ ├── JsonSimpleWithContentHandler.java │ ├── JsonSmartManualTree.java │ ├── JsonSvensonDatabind.java │ ├── JsonTwoLattes.java │ ├── JsonijJpath.java │ └── JsonijManualTree.java │ ├── kryo │ └── Kryo.java │ ├── msgpack │ ├── ImageSizeTemplate.java │ ├── ImageTemplate.java │ ├── MediaContentTemplate.java │ ├── MediaContentTypeHandler.java │ ├── MediaPlayerTemplate.java │ ├── MediaTemplate.java │ ├── MsgPack.java │ ├── MsgPackSerializer.java │ └── TypeHandler.java │ ├── protobuf │ ├── ActiveMQProtobuf.java │ ├── Protobuf.java │ └── ProtobufJson.java │ ├── protostuff │ ├── Protostuff.java │ ├── ProtostuffJson.java │ ├── ProtostuffSmile.java │ └── ProtostuffXml.java │ ├── scala │ └── media │ │ ├── Image.scala │ │ ├── Media.scala │ │ └── MediaContent.scala │ ├── stephenerialization │ ├── Image.java │ ├── Media.java │ └── MediaContent.java │ ├── wobly │ ├── Wobly.java │ ├── compact │ │ ├── WImage.java │ │ ├── WMedia.java │ │ ├── WMediaContent.java │ │ └── WoblyCompactUtils.java │ └── simple │ │ ├── WImage.java │ │ ├── WMedia.java │ │ ├── WMediaContent.java │ │ └── WoblySimpleUtils.java │ └── xml │ ├── BaseStaxMediaSerializer.java │ ├── ExiExificient.java │ ├── StaxDeserializer.java │ ├── StaxSerializer.java │ ├── XmlJavolution.java │ ├── XmlStax.java │ └── XmlXStream.java ├── support ├── intellij │ ├── .gitignore │ ├── .idea │ │ ├── .name │ │ ├── compiler.xml │ │ ├── copyright │ │ │ └── profiles_settings.xml │ │ ├── encodings.xml │ │ ├── inspectionProfiles │ │ │ ├── Project_Default.xml │ │ │ └── profiles_settings.xml │ │ ├── libraries │ │ │ └── All.xml │ │ ├── modules.xml │ │ ├── scopes │ │ │ └── scope_settings.xml │ │ └── vcs.xml │ └── Main.iml └── scala │ ├── scala-compiler-2.13.3.jar │ └── scalac └── website ├── .gitignore ├── beval.js ├── example-benchmarkResults.js ├── fchart.css ├── fchart.js ├── glue.js └── index.html /README: -------------------------------------------------------------------------------- 1 | Look in the "tpc" directory for source code; or see https://github.com/eishay/jvm-serializers/wiki for current results. 2 | -------------------------------------------------------------------------------- /protowar/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /protowar/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | protowar 4 | 5 | 6 | tpc 7 | 8 | 9 | 10 | org.eclipse.wst.jsdt.core.javascriptValidator 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javabuilder 16 | 17 | 18 | 19 | 20 | org.eclipse.wst.common.project.facet.core.builder 21 | 22 | 23 | 24 | 25 | org.eclipse.wst.validation.validationbuilder 26 | 27 | 28 | 29 | 30 | 31 | org.eclipse.wst.common.project.facet.core.nature 32 | org.eclipse.jdt.core.javanature 33 | org.eclipse.wst.common.modulecore.ModuleCoreNature 34 | org.eclipse.jem.workbench.JavaEMFNature 35 | org.eclipse.wst.jsdt.core.jsNature 36 | 37 | 38 | -------------------------------------------------------------------------------- /protowar/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /protowar/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Mon Nov 24 21:28:45 PST 2008 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 4 | org.eclipse.jdt.core.compiler.compliance=1.5 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.5 8 | -------------------------------------------------------------------------------- /protowar/.settings/org.eclipse.jst.common.project.facet.core.prefs: -------------------------------------------------------------------------------- 1 | #Mon Nov 24 21:28:47 PST 2008 2 | classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\:org.eclipse.jdt.internal.launching.macosx.MacOSXType\:\:JVM\ 1.5.0\ (MacOS\ X\ Default)/owners=jst.java\:5.0 3 | eclipse.preferences.version=1 4 | -------------------------------------------------------------------------------- /protowar/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | uses 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /protowar/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /protowar/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /protowar/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /protowar/.settings/org.eclipse.wst.ws.service.policy.prefs: -------------------------------------------------------------------------------- 1 | #Mon Nov 24 22:02:48 PST 2008 2 | eclipse.preferences.version=1 3 | org.eclipse.wst.ws.service.policy.projectEnabled=false 4 | -------------------------------------------------------------------------------- /protowar/WebContent/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /protowar/WebContent/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | protowar 4 | 5 | 6 | 7 | 8 | ProtoWar 9 | ProtoWar 10 | 11 | org.protowar.ProtoWar 12 | 13 | 14 | ProtoWar 15 | /ProtoWar 16 | 17 | 18 | index.html 19 | index.htm 20 | index.jsp 21 | default.html 22 | default.htm 23 | default.jsp 24 | 25 | 26 | -------------------------------------------------------------------------------- /protowar/src/org/protowar/ProtoServerHandler.java: -------------------------------------------------------------------------------- 1 | package org.protowar; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.DataOutputStream; 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.io.OutputStream; 8 | 9 | import serializers.ObjectSerializer; 10 | import serializers.ProtobufSerializer; 11 | import serializers.protobuf.MediaContentHolder.MediaContent; 12 | import serializers.protobuf.MediaContentHolder.MediaServer; 13 | 14 | import com.google.protobuf.Message; 15 | import com.google.protobuf.RpcCallback; 16 | import com.google.protobuf.RpcController; 17 | import com.google.protobuf.Descriptors.MethodDescriptor; 18 | 19 | class ProtoServerHandler extends MediaServer 20 | { 21 | private final ObjectSerializer _serializer = new ProtobufSerializer(); 22 | 23 | @Override 24 | public void updateMedia (RpcController controller, MediaContent request, RpcCallback done) 25 | { 26 | try 27 | { 28 | //System.out.println(request.getMedia().getUri()); 29 | done.run(_serializer.create()); 30 | } 31 | catch (Exception e) 32 | { 33 | e.printStackTrace(); 34 | } 35 | } 36 | 37 | void handle(final OutputStream os, final InputStream is) throws IOException 38 | { 39 | RpcCallback done = new RpcCallback() 40 | { 41 | DataOutputStream dos = new DataOutputStream(os); 42 | 43 | public void run (Message content) 44 | { 45 | try 46 | { 47 | byte[] array = _serializer.serialize((MediaContent) content); 48 | dos.writeInt(array.length); 49 | dos.write(array); 50 | dos.flush(); 51 | } 52 | catch (Exception e) 53 | { 54 | e.printStackTrace(); 55 | } 56 | } 57 | }; 58 | DataInputStream dis = new DataInputStream(is); 59 | int index = dis.readInt(); 60 | MethodDescriptor method = getDescriptor().getMethods().get(index); 61 | byte[] array = new byte[dis.readInt()]; 62 | dis.readFully(array); 63 | Message request = getRequestPrototype(method).newBuilderForType().mergeFrom(array).build(); 64 | callMethod(method, null, request, done); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /protowar/src/org/protowar/ProtoWar.java: -------------------------------------------------------------------------------- 1 | package org.protowar; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.http.HttpServlet; 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | 10 | /** 11 | * Servlet implementation class ProtoWar 12 | */ 13 | public class ProtoWar extends HttpServlet 14 | { 15 | private static final long serialVersionUID = 1L; 16 | 17 | private ProtoServerHandler _handler = new ProtoServerHandler(); 18 | 19 | /** 20 | * Default constructor. 21 | */ 22 | public ProtoWar () 23 | { 24 | } 25 | 26 | /** 27 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) 28 | */ 29 | protected void doGet (HttpServletRequest request, HttpServletResponse response) 30 | throws ServletException, IOException 31 | { 32 | doIt(request, response); 33 | } 34 | 35 | /** 36 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) 37 | */ 38 | protected void doPost (HttpServletRequest request, HttpServletResponse response) 39 | throws ServletException, IOException 40 | { 41 | doIt(request, response); 42 | } 43 | 44 | private void doIt (HttpServletRequest request, HttpServletResponse response) 45 | throws ServletException, IOException 46 | { 47 | _handler.handle(response.getOutputStream(), request.getInputStream()); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /scala_media_container/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /scala_media_container/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | scala_media_container 4 | 5 | 6 | 7 | 8 | 9 | ch.epfl.lamp.sdt.core.scalabuilder 10 | 11 | 12 | 13 | 14 | 15 | ch.epfl.lamp.sdt.core.scalanature 16 | org.eclipse.jdt.core.javanature 17 | 18 | 19 | -------------------------------------------------------------------------------- /scala_media_container/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Sat Nov 29 21:34:27 PST 2008 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.builder.cleanOutputFolder=ignore 4 | org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.scala 5 | -------------------------------------------------------------------------------- /scala_media_container/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | sandbox 5 | mediacontent-scala 6 | 1.0-SNAPSHOT 7 | ${project.artifactId} 8 | 2009 9 | 10 | 11 | 12 | org.scala-lang 13 | scala-library 14 | 2.7.3 15 | 16 | 17 | org.scala-libs 18 | sbinary 19 | 0.3-alpha 20 | system 21 | ${basedir}/../tpc/lib/sbinary-0.3-alpha.jar 22 | 23 | 24 | 25 | 26 | src 27 | 28 | 29 | org.scala-tools 30 | maven-scala-plugin 31 | 32 | 33 | compile 34 | 35 | compile 36 | 37 | 38 | 39 | 40 | 41 | -target:jvm-1.5 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /scala_media_container/src/serializers/scala/Image.scala: -------------------------------------------------------------------------------- 1 | package serializers.scala 2 | 3 | @serializable 4 | case class Image(uri: String, title: String, width: Int, height: Int, size: Size.Value) 5 | -------------------------------------------------------------------------------- /scala_media_container/src/serializers/scala/Media.scala: -------------------------------------------------------------------------------- 1 | package serializers.scala 2 | 3 | @serializable 4 | class Media (val uri: String, val title: String, 5 | val width: Int, val height: Int, val format: String, 6 | val duration: Long, val size: Long, 7 | val bitrate: Int, 8 | val copyright: Option[String], 9 | val player: Player.Value){ 10 | 11 | def this(uri: String, title: String, 12 | width: Int, height: Int, format: String, 13 | duration: Long, size: Long, 14 | bitrate: Int, 15 | player: Player.Value) = this(uri, title, width, height, format, duration, size, bitrate, None, player) 16 | 17 | private var _persons: List[String] = Nil 18 | def persons = _persons 19 | 20 | def addPerson(persons: String){ 21 | _persons = persons :: _persons 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /scala_media_container/src/serializers/scala/MediaContent.scala: -------------------------------------------------------------------------------- 1 | package serializers.scala 2 | @serializable 3 | class MediaContent (val media: Media){ 4 | var _images: List[Image] = Nil 5 | def images = _images 6 | 7 | def addImage(image: Image){ 8 | _images = image :: _images 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /scala_media_container/src/serializers/scala/Player.scala: -------------------------------------------------------------------------------- 1 | package serializers.scala 2 | @serializable 3 | object Player extends Enumeration{ 4 | val JAVA, FLASH = Value 5 | } 6 | -------------------------------------------------------------------------------- /scala_media_container/src/serializers/scala/Runner.scala: -------------------------------------------------------------------------------- 1 | package serializers.scala 2 | 3 | object Runner { 4 | def main(args: Array[String]){ 5 | println("start") 6 | var image1 = new Image("a", "b", 1, 2, Size.SMALL) 7 | var image2 = new Image("a", "b", 1, 2, Size.SMALL) 8 | var content = new MediaContent(null) 9 | content.addImage(image1) 10 | content.addImage(image2) 11 | 12 | println("end") 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /scala_media_container/src/serializers/scala/SbinarySerializerSupport.scala: -------------------------------------------------------------------------------- 1 | package serializers.scala 2 | 3 | import sbinary.DefaultProtocol 4 | import sbinary.DefaultProtocol._ 5 | 6 | object MyProtocol extends DefaultProtocol{ 7 | // import sbinary.DefaultProtocol._ 8 | 9 | // implicit val ImageFormat : Format[Image] = asProduct5(Image)(Image.unapply(_).get) 10 | implicit object ImageFormat extends Format[Image]{ 11 | def reads(in : Input) = { 12 | Image( 13 | read[String](in), 14 | read[String](in), 15 | read[Int](in), 16 | read[Int](in), 17 | read[Size.Value](in) 18 | ) 19 | } 20 | 21 | def writes(out : Output, value : Image) = { 22 | write[String](out, value.uri) 23 | write[String](out, value.title) 24 | write[Int](out, value.width) 25 | write[Int](out, value.height) 26 | write[Size.Value](out, value.size) 27 | } 28 | } 29 | 30 | implicit object MediaFormat extends Format[Media]{ 31 | def reads(in : Input) = { 32 | val back = new Media( 33 | read[String](in), 34 | read[String](in), 35 | read[Int](in), 36 | read[Int](in), 37 | read[String](in), 38 | read[Long](in), 39 | read[Long](in), 40 | read[Int](in), 41 | read[Option[String]](in), 42 | read[Player.Value](in) 43 | ) 44 | read[List[String]](in).foreach(p => back.addPerson(p)) 45 | back 46 | } 47 | 48 | def writes(out : Output, value : Media) = { 49 | write[String](out, value.uri) 50 | write[String](out, value.title) 51 | write[Int](out, value.width) 52 | write[Int](out, value.height) 53 | write[String](out, value.format) 54 | write[Long](out, value.duration) 55 | write[Long](out, value.size) 56 | write[Int](out, value.bitrate) 57 | write[Option[String]](out, value.copyright) 58 | write[Player.Value](out, value.player) 59 | write[List[String]](out, value.persons) 60 | } 61 | } 62 | 63 | // implicit object PlayerFormat extends Format[Player.Value] { 64 | // def reads(in : Input) = Player.Value(read[Int](in)) 65 | // def writed(out : Output, value : Player.Value) = write[Int](out, value) 66 | // } 67 | 68 | implicit val PlayerFormat = enumerationFormat[Player.Value](Player) 69 | implicit val SizeFormat = enumerationFormat[Size.Value](Size) 70 | 71 | implicit object MediaContentFormat extends Format[MediaContent]{ 72 | def reads(in : Input) = { 73 | val back = new MediaContent(read[Media](in)) 74 | read[List[Image]](in).foreach(i => back.addImage(i)) 75 | back 76 | } 77 | 78 | def writes(out : Output, value : MediaContent) = { 79 | write[Media](out, value.media) 80 | write[List[Image]](out, value.images) 81 | } 82 | } 83 | 84 | } 85 | 86 | 87 | object SbinarySerializerSupport { 88 | import MyProtocol._ 89 | def deserialize(array : Array[Byte]) : MediaContent = fromByteArray[MediaContent](array) 90 | def serialize(content : MediaContent) : Array[Byte] = toByteArray(content) 91 | } -------------------------------------------------------------------------------- /scala_media_container/src/serializers/scala/Size.scala: -------------------------------------------------------------------------------- 1 | package serializers.scala 2 | @serializable 3 | object Size extends Enumeration{ 4 | val SMALL, LARGE = Value 5 | } 6 | -------------------------------------------------------------------------------- /tpc/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /bin 3 | /results 4 | 5 | syntax: glob 6 | *~ 7 | -------------------------------------------------------------------------------- /tpc/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | tpc 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.wst.common.project.facet.core.nature 27 | org.eclipse.wst.common.modulecore.ModuleCoreNature 28 | org.eclipse.jem.workbench.JavaEMFNature 29 | 30 | 31 | -------------------------------------------------------------------------------- /tpc/README: -------------------------------------------------------------------------------- 1 | Requirements: 2 | - GNU Make 3.81+ 3 | - JDK 1.7+ 4 | 5 | for windows install cygwin with make+bash features 6 | 7 | To compile: 8 | make 9 | (if you run in trouble its usually because of CRLF dirt) E.g. scalac did not run because it was CRLF 10 | 11 | To run 12 | 13 | bash run-bench.sh 14 | 15 | Parameters of the default run are hardcoded in run-bench.sh 16 | 17 | To update results of subset of serializers 18 | 19 | bash run-bench.sh serializer1,serializer2,.. 20 | 21 | How this works: 22 | 23 | the project was somewhat messy, i probably contributed to that .. but its easier to manage now. 24 | I removed the config files to avoid problems when serializers rename or are un/commented. Additionally 25 | each benchmark runs in a separate VM. 26 | 27 | 1) the run-bench.sh uses class BenchmarkExporter.java to get a ',' separated list of all serializers to run. 28 | All benchmarks registered in the BenchnarkRunner.java class a run be default. 29 | 2) after each bench finished, the mk-stats.sh script aggregates the results found in ./results/raw to ./results/stats.txt 30 | the the class StatsCruncher.java creates a Textile style report. 31 | To modify the report output, directly edit the StatsCruncher.java . You are welcome to enhance this using 32 | some templating/configuration files. 33 | You can copy the results/report.texfile directly to github wiki in textile-mode. 34 | 3) You can run the mk-stats.sh script again without having to re-run the benchmarks if you want to add 35 | custom query charts. 36 | 4) to filter out certain libraries, do not uncomment them in BenchMarkRunner.java (except they fail), better 37 | edit StatsCruncher.java to exclude them. 38 | -------------------------------------------------------------------------------- /tpc/attic/README_old: -------------------------------------------------------------------------------- 1 | Requirements: 2 | - GNU Make 3.81+ 3 | - JDK 1.7+ 4 | 5 | To compile: 6 | make 7 | 8 | To run: 9 | ./run -help 10 | 11 | To run and generate charts with all serializers: (For official results, add -trials=500) 12 | ./run -chart -include=`cat serializers.txt | tr "\\n" ","` data/media.1.cks 13 | 14 | 15 | To generate bindings for schema files, see top of "Makefile" for 16 | instructions on what to put into "Config.mk". 17 | -------------------------------------------------------------------------------- /tpc/attic/run: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | set -e 3 | 4 | path_sep=":" 5 | case "`uname`" in 6 | CYGWIN*) path_sep=";" ;; 7 | esac 8 | 9 | cp=build/bytecode/main$path_sep$(cat build/gen-cp)$path_sep$(cat build/lib-cp) 10 | exec java -Xmx256m -server -cp "$cp" serializers.BenchmarkRunner "$@" 11 | -------------------------------------------------------------------------------- /tpc/attic/run-stream: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | set -e 3 | 4 | path_sep=":" 5 | case "`uname`" in 6 | CYGWIN*) path_sep=";" ;; 7 | esac 8 | 9 | cp=build/bytecode/main$path_sep$(cat build/gen-cp)$path_sep$(cat build/lib-cp) 10 | exec java -Xmx64m -server -cp "$cp" serializers.MediaStreamBenchmark "$@" 11 | -------------------------------------------------------------------------------- /tpc/attic/run-wiki: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | # SIMPLE/GENERIC: Serializes any POJO without special knowledge about the class. 4 | ./run -trials=500 -chart -include=java-built-in,hessian,kryo,protostuff-runtime,msgpack,json/jackson/databind,json/jackson/db-afterburner,json/google-gson/databind,json/svenson-databind,json/flexjson/databind,json/fastjson/databind,smile/jackson/databind,smile/jackson/db-afterburner,smile/protostuff-runtime,bson/jackson/databind,xml/xstream+c,xml/jackson/databind-aalto,json/protostuff-runtime data/media.1.cks 5 | 6 | # SIMPLE/SPECIFC: Serializes only specific classes using code generation or other special knowledge about the class. 7 | ./run -trials=500 -chart -include=wobly,wobly-compact,kryo-opt,protobuf,protostuff,protobuf/protostuff,thrift,thrift-compact,avro,json/json-lib-databind,json/jsonij-jpath,json/jsonpath/json.simple data/media.1.cks 8 | 9 | # MANUAL: Serializes only specific classes using hand written serialization code. 10 | ./run -trials=500 -chart -include=java-manual,kryo-manual,protostuff-manual,json/jackson/manual,json/jackson/tree,json/protostuff-manual,json/google-gson/manual,json/google-gson/manual/tree,json/json.simple/manual,json/json.simple/manual/tree,json/json-smart/manual/tree,json/org.json/manual/tree,json/jsonij-manual/tree,json/argo-manual/tree,smile/jackson/manual,smile/protostuff-manual,bson/mongodb,xml/woodstox-manual,xml/aalto-manual,xml/fastinfo-manual,xml/xstream+c-woodstox,xml/xstream+c-aalto,xml/xstream+c-fastinfo,xml/javolution,avro-generic data/media.1.cks 11 | -------------------------------------------------------------------------------- /tpc/attic/serializers.txt: -------------------------------------------------------------------------------- 1 | java-built-in 2 | java-manual 3 | scala/java-built-in 4 | scala/sbinary 5 | fast-serialization 6 | kryo 7 | kryo-opt 8 | kryo-manual 9 | msgpack 10 | wobly 11 | wobly-compact 12 | hessian 13 | jboss-serialization 14 | jboss-marshalling-river 15 | jboss-marshalling-river-manual 16 | jboss-marshalling-river-ct 17 | jboss-marshalling-river-ct-manual 18 | jboss-marshalling-serial 19 | obser 20 | obser-compact 21 | obser-manual 22 | obser-manual-compact 23 | protobuf 24 | protobuf/activemq+alt 25 | protostuff 26 | protostuff-manual 27 | protostuff-runtime 28 | protobuf/protostuff 29 | thrift 30 | thrift-compact 31 | avro 32 | avro-generic 33 | json/jackson-manual 34 | json/jackson-manual/tree 35 | json/jackson-manual/tree-strings 36 | json/jackson-databind 37 | json/jackson-databind-strings 38 | json/protostuff-manual 39 | json/protostuff-runtime 40 | json/protobuf 41 | json/google-gson 42 | json/google-gson/manual/tree 43 | json/svenson-databind 44 | json/flexjson/databind 45 | json/json-lib-databind 46 | json/fastjson-databind 47 | json/json.simple/manual/tree 48 | json/json.simple/manual 49 | json/json-smart/manual/tree 50 | json/org.json/manual/tree 51 | json/jsonij-jpath 52 | json/jsonij-manual/tree 53 | json/argo-manual/tree 54 | json/jsonpath/json.simple 55 | bson/jackson-manual 56 | bson/jackson-databind 57 | bson/mongodb 58 | smile/jackson-manual 59 | smile/jackson-databind 60 | smile/protostuff-manual 61 | smile/protostuff-runtime 62 | xml/manual-woodstox 63 | xml/manual-aalto 64 | xml/manual-fastinfo 65 | xml/xstream+c 66 | xml/xstream+c-woodstox 67 | xml/xstream+c-aalto 68 | xml/xstream+c-fastinfo 69 | xml/javolution 70 | datakernel 71 | -------------------------------------------------------------------------------- /tpc/data-stream/media.3.cks: -------------------------------------------------------------------------------- 1 | // Note: we use four at signs as separator, due to CKS limitations 2 | { 3 | Media = { 4 | Uri = "http://javaone.com/keynote.mpg" 5 | Title = Set: "Javaone Keynote" 6 | Width = 640 7 | Height = 480 8 | Format = "video/mpg4" 9 | Duration = 18000000 // half hour in milliseconds 10 | Size = 58982400 // bitrate * duration in seconds / 8 bits per byte 11 | Bitrate = Set: 262144 // 256k 12 | Persons = ["Bill Gates", "Steve Jobs"] 13 | Player = Java 14 | Copyright = None 15 | } 16 | Images = [ { 17 | Uri = "http://javaone.com/keynote_large.jpg" 18 | Title = Set: "Javaone Keynote" 19 | Width = 1024 20 | Height = 768 21 | Size = Large 22 | },{ 23 | Uri = "http://javaone.com/keynote_small.jpg" 24 | Title = Set: "Javaone Keynote" 25 | Width = 320 26 | Height = 240 27 | Size = Small 28 | } ] 29 | } 30 | @@@@ 31 | { 32 | Media = { 33 | Uri = "http://cowtowncoder.com/blog/blog.html" 34 | Title = Set: "CowTalk - Some stuff" 35 | Width = 63 36 | Height = 24 37 | Format = "text/html" 38 | Duration = 1600 39 | Size = 65536 40 | Bitrate = Set: 16000 41 | Persons = ["Tatu the Coder"] 42 | Player = Flash 43 | Copyright = None 44 | } 45 | Images = [ { 46 | Uri = "http://cowtowncoder.com/icon.jpg" 47 | Title = Set: "Cowboy Icon" 48 | Width = 128 49 | Height = 128 50 | Size = Large 51 | },{ 52 | Uri = "http://cowtowncoder.com/icon-small.jpg" 53 | Title = Set: "Cowboy Icon" 54 | Width = 24 55 | Height = 24 56 | Size = Small 57 | } ] 58 | } 59 | @@@@ 60 | { 61 | Media = { 62 | Uri = "http://google.com/search?foo=bar" 63 | Title = Set: "Big G -- search for masses" 64 | Width = 640 65 | Height = 480 66 | Format = "text/plain" 67 | Duration = 9000000 68 | Size = 256000 69 | Bitrate = Set: 192000 70 | Persons = ["Sergei Brin", "Steve Jobs", "Just Kiddin"] 71 | Player = Java 72 | Copyright = Set: "Probably" 73 | } 74 | Images = [ { 75 | Uri = "http://google.com/icon-large.jpg" 76 | Title = Set: "G!" 77 | Width = 192 78 | Height = 192 79 | Size = Large 80 | },{ 81 | Uri = "http://google.com/icon-small.jpg" 82 | Title = Set: "Javaone Keynote" 83 | Width = 15 84 | Height = 15 85 | Size = Small 86 | } ] 87 | } 88 | 89 | -------------------------------------------------------------------------------- /tpc/data/media.1.json: -------------------------------------------------------------------------------- 1 | // The standard test value. 2 | { 3 | "media": { 4 | "uri": "http://javaone.com/keynote.mpg", 5 | "title": "Javaone Keynote", 6 | "width": 640, 7 | "height": 480, 8 | "format": "video/mpg4", 9 | "duration": 18000000, // half hour in milliseconds 10 | "size": 58982400, // bitrate * duration in seconds / 8 bits per byte 11 | "bitrate": 262144, // 256k 12 | "persons": ["Bill Gates", "Steve Jobs스"], 13 | "player": "JAVA", 14 | "copyright": null 15 | }, 16 | "images": [ 17 | { 18 | "uri": "http://javaone.com/keynote_large.jpg", 19 | "title": "Javaone Keynote", 20 | "width": 1024, 21 | "height": 768, 22 | "size": "LARGE" 23 | }, 24 | { 25 | "uri": "http://javaone.com/keynote_small.jpg", 26 | "title": "Javaone Keynote", 27 | "width": 320, 28 | "height": 240, 29 | "size": "SMALL" 30 | } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /tpc/data/media.2.json: -------------------------------------------------------------------------------- 1 | // A test value where everything is different from media.1.json. 2 | // Also uses Unicode to make sure nobody's cheating and only handling ASCII. 3 | // This is mainly used to check if the serializers are "honest". 4 | { 5 | "media": { 6 | "uri": "http://javaone.com/keynote.ogg\u1234", 7 | "title": null, 8 | "width": 641, 9 | "height": 481, 10 | "format": "video/theora\u1234", 11 | "duration": 18000001, 12 | "size": 58982401, 13 | "bitrate": null, 14 | "persons": ["Bill Gates, Jr.\u1234", "Steven Jobs\u1234"], 15 | "player": "FLASH", 16 | "copyright": "2009, Scooby Doo\uD834\uDD1E" // last two characters are a UTF-16 surrogate pair 17 | }, 18 | 19 | "images": [ 20 | { 21 | "uri": "http://javaone.com/keynote_huge.jpg\u1234", 22 | "title": "Javaone Keynote\u1234", 23 | "width": 32000, 24 | "height": 24000, 25 | "size": "LARGE" 26 | }, 27 | { 28 | "uri": "http://javaone.com/keynote_large.jpg\u1234", 29 | "title": null, 30 | "width": 1024, 31 | "height": 768, 32 | "size": "LARGE" 33 | }, 34 | { 35 | "uri": "http://javaone.com/keynote_small.jpg\u1234", 36 | "title": null, 37 | "width": 320, 38 | "height": 240, 39 | "size": "SMALL" 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /tpc/data/media.3.json: -------------------------------------------------------------------------------- 1 | // Long strings. 2 | { 3 | "media": { 4 | "uri": "http://javaone.com/keynote.mpglkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj", 5 | "title": "Javaone Keynotelkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj", 6 | "width": 640, 7 | "height": 480, 8 | "format": "video/mpg4lkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj", 9 | "duration": 18000000, // half hour in milliseconds 10 | "size": 58982400, // bitrate * duration in seconds / 8 bits per byte 11 | "bitrate": 262144, // 256k 12 | "persons": ["Bill Gateslkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj", "Steve Jobslkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj"], 13 | "player": "JAVA", 14 | "copyright": null 15 | }, 16 | 17 | "images": [ 18 | { 19 | "uri": "http://javaone.com/keynote_large.jpglkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj", 20 | "title": "Javaone Keynotelkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj", 21 | "width": 1024, 22 | "height": 768, 23 | "size": "LARGE" 24 | }, 25 | { 26 | "uri": "http://javaone.com/keynote_small.jpglkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj", 27 | "title": "Javaone Keynotelkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj", 28 | "width": 320, 29 | "height": 240, 30 | "size": "SMALL" 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /tpc/data/media.4.json: -------------------------------------------------------------------------------- 1 | // Short strings. 2 | { 3 | "media": { 4 | "uri": "g", 5 | "title": "J", 6 | "width": 640, 7 | "height": 480, 8 | "format": "v", 9 | "duration": 18000000, // half hour in milliseconds 10 | "size": 58982400, // bitrate * duration in seconds / 8 bits per byte 11 | "bitrate": 262144, // 256k 12 | "persons": ["B", "S"], 13 | "player": "JAVA", 14 | "copyright": null 15 | }, 16 | 17 | "images": [ 18 | { 19 | "uri": "h", 20 | "title": "J", 21 | "width": 1024, 22 | "height": 768, 23 | "size": "LARGE" 24 | }, 25 | { 26 | "uri": "h", 27 | "title": "J", 28 | "width": 320, 29 | "height": 240, 30 | "size": "SMALL" 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /tpc/lib/FastInfoset-1.2.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/FastInfoset-1.2.6.jar -------------------------------------------------------------------------------- /tpc/lib/aalto-xml-1.2.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/aalto-xml-1.2.2.jar -------------------------------------------------------------------------------- /tpc/lib/activemq-protobuf-1.1-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/activemq-protobuf-1.1-SNAPSHOT.jar -------------------------------------------------------------------------------- /tpc/lib/activemq-util-6.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/activemq-util-6.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /tpc/lib/argo-2.10.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/argo-2.10.jar -------------------------------------------------------------------------------- /tpc/lib/asm-4.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/asm-4.0.jar -------------------------------------------------------------------------------- /tpc/lib/asm-commons-3.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/asm-commons-3.2.jar -------------------------------------------------------------------------------- /tpc/lib/avro-1.10.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/avro-1.10.0.jar -------------------------------------------------------------------------------- /tpc/lib/avro-compiler-1.10.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/avro-compiler-1.10.0.jar -------------------------------------------------------------------------------- /tpc/lib/avro-fastserde-0.2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/avro-fastserde-0.2.4.jar -------------------------------------------------------------------------------- /tpc/lib/bson-2.7.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/bson-2.7.1.jar -------------------------------------------------------------------------------- /tpc/lib/bson4jackson-2.7.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/bson4jackson-2.7.0.jar -------------------------------------------------------------------------------- /tpc/lib/capnproto-runtime-0.1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/capnproto-runtime-0.1.1.jar -------------------------------------------------------------------------------- /tpc/lib/codemodel-2.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/codemodel-2.6.jar -------------------------------------------------------------------------------- /tpc/lib/commons-beanutils-1.8.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/commons-beanutils-1.8.3.jar -------------------------------------------------------------------------------- /tpc/lib/commons-codec-1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/commons-codec-1.3.jar -------------------------------------------------------------------------------- /tpc/lib/commons-collections-3.2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/commons-collections-3.2.1.jar -------------------------------------------------------------------------------- /tpc/lib/commons-httpclient-3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/commons-httpclient-3.1.jar -------------------------------------------------------------------------------- /tpc/lib/commons-lang-2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/commons-lang-2.4.jar -------------------------------------------------------------------------------- /tpc/lib/commons-lang3-3.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/commons-lang3-3.4.jar -------------------------------------------------------------------------------- /tpc/lib/commons-logging-1.1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/commons-logging-1.1.1.jar -------------------------------------------------------------------------------- /tpc/lib/dsl-json-1.9.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/dsl-json-1.9.5.jar -------------------------------------------------------------------------------- /tpc/lib/dsl-json-java8-1.9.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/dsl-json-java8-1.9.5.jar -------------------------------------------------------------------------------- /tpc/lib/exi-exificient-0.9.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/exi-exificient-0.9.1.jar -------------------------------------------------------------------------------- /tpc/lib/extra/avro-tools-1.8.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/extra/avro-tools-1.8.2.jar -------------------------------------------------------------------------------- /tpc/lib/ezmorph-1.0.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/ezmorph-1.0.6.jar -------------------------------------------------------------------------------- /tpc/lib/fastjson-1.2.11.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/fastjson-1.2.11.jar -------------------------------------------------------------------------------- /tpc/lib/flatbuffers-java-1.9.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/flatbuffers-java-1.9.0.jar -------------------------------------------------------------------------------- /tpc/lib/flexjson-2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/flexjson-2.1.jar -------------------------------------------------------------------------------- /tpc/lib/fst-1.42.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/fst-1.42.jar -------------------------------------------------------------------------------- /tpc/lib/fury-core-0.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/fury-core-0.2.0.jar -------------------------------------------------------------------------------- /tpc/lib/gson-2.8.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/gson-2.8.0.jar -------------------------------------------------------------------------------- /tpc/lib/guava-19.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/guava-19.0.jar -------------------------------------------------------------------------------- /tpc/lib/helper-all-0.2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/helper-all-0.2.1.jar -------------------------------------------------------------------------------- /tpc/lib/hessian-4.0.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/hessian-4.0.7.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-all-1.9.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-all-1.9.6.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-annotations-2.9.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-annotations-2.9.0.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-core-2.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-core-2.9.2.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-databind-2.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-databind-2.9.2.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-dataformat-avro-2.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-dataformat-avro-2.9.2.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-dataformat-cbor-2.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-dataformat-cbor-2.9.2.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-dataformat-protobuf-2.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-dataformat-protobuf-2.9.2.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-dataformat-smile-2.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-dataformat-smile-2.9.2.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-dataformat-xml-2.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-dataformat-xml-2.9.2.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-dataformat-yaml-2.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-dataformat-yaml-2.9.2.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-jr-objects-2.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-jr-objects-2.9.2.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-module-afterburner-2.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-module-afterburner-2.9.2.jar -------------------------------------------------------------------------------- /tpc/lib/jackson-module-jaxb-annotations-2.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jackson-module-jaxb-annotations-2.9.2.jar -------------------------------------------------------------------------------- /tpc/lib/jakarta.xml.bind-api-2.3.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jakarta.xml.bind-api-2.3.3.jar -------------------------------------------------------------------------------- /tpc/lib/javassist-3.27.0-GA.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/javassist-3.27.0-GA.jar -------------------------------------------------------------------------------- /tpc/lib/javax.annotation-api-1.3.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/javax.annotation-api-1.3.2.jar -------------------------------------------------------------------------------- /tpc/lib/javax.json-1.0-b06.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/javax.json-1.0-b06.jar -------------------------------------------------------------------------------- /tpc/lib/javolution-5.5.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/javolution-5.5.1.jar -------------------------------------------------------------------------------- /tpc/lib/jboss-marshalling-2.0.9.Final.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jboss-marshalling-2.0.9.Final.jar -------------------------------------------------------------------------------- /tpc/lib/jboss-marshalling-river-2.0.9.Final.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jboss-marshalling-river-2.0.9.Final.jar -------------------------------------------------------------------------------- /tpc/lib/jboss-marshalling-serial-2.0.9.Final.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jboss-marshalling-serial-2.0.9.Final.jar -------------------------------------------------------------------------------- /tpc/lib/jboss-serialization-4.2.2.GA.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jboss-serialization-4.2.2.GA.jar -------------------------------------------------------------------------------- /tpc/lib/jopt-simple-3.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jopt-simple-3.2.jar -------------------------------------------------------------------------------- /tpc/lib/json-0.19-tpc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/json-0.19-tpc.jar -------------------------------------------------------------------------------- /tpc/lib/json-lib-2.4-jdk15.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/json-lib-2.4-jdk15.jar -------------------------------------------------------------------------------- /tpc/lib/json-smart-1.0.8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/json-smart-1.0.8.jar -------------------------------------------------------------------------------- /tpc/lib/json.org-ref-2011.06.21.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/json.org-ref-2011.06.21.jar -------------------------------------------------------------------------------- /tpc/lib/json_simple-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/json_simple-1.1.jar -------------------------------------------------------------------------------- /tpc/lib/jsonij-0.2.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jsonij-0.2.7.jar -------------------------------------------------------------------------------- /tpc/lib/jsonpath-2011.06.23.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/jsonpath-2011.06.23.jar -------------------------------------------------------------------------------- /tpc/lib/kryo-5.0.0-RC6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/kryo-5.0.0-RC6.jar -------------------------------------------------------------------------------- /tpc/lib/libthrift-0.13.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/libthrift-0.13.0.jar -------------------------------------------------------------------------------- /tpc/lib/log4j-1.2.17.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/log4j-1.2.17.jar -------------------------------------------------------------------------------- /tpc/lib/minlog-none-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/minlog-none-1.2.jar -------------------------------------------------------------------------------- /tpc/lib/msgpack-0.6.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/msgpack-0.6.9.jar -------------------------------------------------------------------------------- /tpc/lib/objenesis-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/objenesis-1.2.jar -------------------------------------------------------------------------------- /tpc/lib/obser-0.9.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/obser-0.9.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /tpc/lib/paranamer-1.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/paranamer-1.5.jar -------------------------------------------------------------------------------- /tpc/lib/protobuf-java-3.6.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/protobuf-java-3.6.1.jar -------------------------------------------------------------------------------- /tpc/lib/protostuff-api-1.5.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/protostuff-api-1.5.9.jar -------------------------------------------------------------------------------- /tpc/lib/protostuff-collectionschema-1.5.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/protostuff-collectionschema-1.5.9.jar -------------------------------------------------------------------------------- /tpc/lib/protostuff-compiler-1.5.9-jar-with-dependencies.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/protostuff-compiler-1.5.9-jar-with-dependencies.jar -------------------------------------------------------------------------------- /tpc/lib/protostuff-core-1.5.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/protostuff-core-1.5.9.jar -------------------------------------------------------------------------------- /tpc/lib/protostuff-json-1.5.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/protostuff-json-1.5.9.jar -------------------------------------------------------------------------------- /tpc/lib/protostuff-runtime-1.5.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/protostuff-runtime-1.5.9.jar -------------------------------------------------------------------------------- /tpc/lib/protostuff-xml-1.5.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/protostuff-xml-1.5.9.jar -------------------------------------------------------------------------------- /tpc/lib/reflectasm-1.05.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/reflectasm-1.05.jar -------------------------------------------------------------------------------- /tpc/lib/sbinary_2.11-0.4.3-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/sbinary_2.11-0.4.3-SNAPSHOT.jar -------------------------------------------------------------------------------- /tpc/lib/scala-library-2.13.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/scala-library-2.13.3.jar -------------------------------------------------------------------------------- /tpc/lib/scala-reflect-2.13.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/scala-reflect-2.13.3.jar -------------------------------------------------------------------------------- /tpc/lib/scala-xml_2.11-1.0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/scala-xml_2.11-1.0.2.jar -------------------------------------------------------------------------------- /tpc/lib/serializer-1.1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/serializer-1.1.2.jar -------------------------------------------------------------------------------- /tpc/lib/slf4j-api-1.7.14.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/slf4j-api-1.7.14.jar -------------------------------------------------------------------------------- /tpc/lib/slf4j-log4j12-1.7.14.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/slf4j-log4j12-1.7.14.jar -------------------------------------------------------------------------------- /tpc/lib/snakeyaml-1.18.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/snakeyaml-1.18.jar -------------------------------------------------------------------------------- /tpc/lib/stax-api-1.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/stax-api-1.0.1.jar -------------------------------------------------------------------------------- /tpc/lib/stax2-api-3.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/stax2-api-3.0.1.jar -------------------------------------------------------------------------------- /tpc/lib/stephenerialization-3.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/stephenerialization-3.0.0.jar -------------------------------------------------------------------------------- /tpc/lib/svenson-1.4.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/svenson-1.4.0.jar -------------------------------------------------------------------------------- /tpc/lib/trove-1.0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/trove-1.0.2.jar -------------------------------------------------------------------------------- /tpc/lib/velocity-1.7-dep.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/velocity-1.7-dep.jar -------------------------------------------------------------------------------- /tpc/lib/velocity-1.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/velocity-1.7.jar -------------------------------------------------------------------------------- /tpc/lib/wobly-core-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/wobly-core-1.0.jar -------------------------------------------------------------------------------- /tpc/lib/woodstox-core-5.0.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/woodstox-core-5.0.3.jar -------------------------------------------------------------------------------- /tpc/lib/xpp3_min-1.1.4c.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/xpp3_min-1.1.4c.jar -------------------------------------------------------------------------------- /tpc/lib/xstream-1.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/lib/xstream-1.3.1.jar -------------------------------------------------------------------------------- /tpc/mk-js-stats: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # ------------------------------------------------------------------------------ 3 | # Reads in the combined stats file (generated by mk-stats.sh) and writes to 4 | # a Javascript file (website/benchmarkResults.js) so the results can be viewed 5 | # with the dynamic results website (website/index.html). 6 | # ------------------------------------------------------------------------------ 7 | set -e 8 | 9 | input_file_rel="results/stats.txt" 10 | output_file_rel="website/benchmarkResults.js" 11 | 12 | # Locate the script file. Cross symlinks if necessary. 13 | loc="$0" 14 | while [ -h "$loc" ]; do 15 | ls=`ls -ld "$loc"` 16 | link=`expr "$ls" : '.*-> \(.*\)$'` 17 | if expr "$link" : '/.*' > /dev/null; then 18 | loc="$link" # Absolute link 19 | else 20 | loc="`dirname "$loc"`/$link" # Relative link 21 | fi 22 | done 23 | 24 | base_dir=`dirname "$loc"` 25 | 26 | if [ $# -ne 0 ]; then 27 | echo "Expecting no arguments, got $#." 1>&2 28 | exit 1 29 | fi 30 | 31 | input_file="$base_dir/$input_file_rel" 32 | if [ ! -f "$input_file" ]; then 33 | echo "Couldn't find input file \"$input_file\"." 1>&2 34 | echo "This file is typically generated by running \"./mk-stats.sh\"." 1>&2 35 | exit 1 36 | fi 37 | 38 | output_file="$base_dir/$output_file_rel" 39 | output_dir=$(dirname "$output_file") 40 | if [ ! -d "$output_dir" ]; then 41 | echo "Couldn't find output directory \"$output_dir\"." 1>&2 42 | exit 1 43 | fi 44 | 45 | # Build classpath. 46 | cpgen=$(cat build/gen-cp) 47 | cplib=$(cat build/lib-cp) 48 | sep=':' 49 | # cygwin 50 | case "`uname`" in 51 | CYGWIN*) sep=';' ;; 52 | esac 53 | cp="./build/bytecode/main$sep$cpgen$sep$cplib" 54 | 55 | echo "Writing results to: $output_file" 56 | java -cp "$cp" serializers.WriteResultsToJavascript "$input_file" "$output_file" 57 | echo "Open \"$output_dir/index.html\" in a web browser to see graphs." 58 | -------------------------------------------------------------------------------- /tpc/mk-stats.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | raw_result_dir="results/raw" 4 | combined_file="results/stats.txt" 5 | output_file="results/report.texfile" 6 | 7 | mkdir -p "$(dirname "$combined_input")" 8 | echo "" > "$combined_file" 9 | for f in "$raw_result_dir/"*"-result.txt"; do 10 | echo "Processing: $f" 11 | awk '/./{line=$0} END{print line}' "$f" >> "$combined_file" 12 | done 13 | 14 | cpgen=$(cat build/gen-cp) 15 | cplib=$(cat build/lib-cp) 16 | sep=':' 17 | # cygwin 18 | case "`uname`" in 19 | CYGWIN*) sep=';' ;; 20 | esac 21 | 22 | cp=./build/bytecode/main$sep$cpgen$sep$cplib 23 | 24 | echo "Writing results to: $output_file" 25 | exec java -cp $cp serializers.StatsCruncher "$combined_file" "$output_file" 26 | -------------------------------------------------------------------------------- /tpc/pregen/media.fbs/serializers/flatbuffers/media/Image.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package serializers.flatbuffers.media; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | @SuppressWarnings("unused") 11 | public final class Image extends Table { 12 | public static Image getRootAsImage(ByteBuffer _bb) { return getRootAsImage(_bb, new Image()); } 13 | public static Image getRootAsImage(ByteBuffer _bb, Image obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } 14 | public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } 15 | public Image __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } 16 | 17 | public String uri() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } 18 | public ByteBuffer uriAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } 19 | public ByteBuffer uriInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); } 20 | public String title() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; } 21 | public ByteBuffer titleAsByteBuffer() { return __vector_as_bytebuffer(6, 1); } 22 | public ByteBuffer titleInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); } 23 | public int width() { int o = __offset(8); return o != 0 ? bb.getInt(o + bb_pos) : 0; } 24 | public int height() { int o = __offset(10); return o != 0 ? bb.getInt(o + bb_pos) : 0; } 25 | public byte size() { int o = __offset(12); return o != 0 ? bb.get(o + bb_pos) : 0; } 26 | 27 | public static int createImage(FlatBufferBuilder builder, 28 | int uriOffset, 29 | int titleOffset, 30 | int width, 31 | int height, 32 | byte size) { 33 | builder.startObject(5); 34 | Image.addHeight(builder, height); 35 | Image.addWidth(builder, width); 36 | Image.addTitle(builder, titleOffset); 37 | Image.addUri(builder, uriOffset); 38 | Image.addSize(builder, size); 39 | return Image.endImage(builder); 40 | } 41 | 42 | public static void startImage(FlatBufferBuilder builder) { builder.startObject(5); } 43 | public static void addUri(FlatBufferBuilder builder, int uriOffset) { builder.addOffset(0, uriOffset, 0); } 44 | public static void addTitle(FlatBufferBuilder builder, int titleOffset) { builder.addOffset(1, titleOffset, 0); } 45 | public static void addWidth(FlatBufferBuilder builder, int width) { builder.addInt(2, width, 0); } 46 | public static void addHeight(FlatBufferBuilder builder, int height) { builder.addInt(3, height, 0); } 47 | public static void addSize(FlatBufferBuilder builder, byte size) { builder.addByte(4, size, 0); } 48 | public static int endImage(FlatBufferBuilder builder) { 49 | int o = builder.endObject(); 50 | builder.required(o, 4); // uri 51 | return o; 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /tpc/pregen/media.fbs/serializers/flatbuffers/media/MediaContent.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package serializers.flatbuffers.media; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | @SuppressWarnings("unused") 11 | public final class MediaContent extends Table { 12 | public static MediaContent getRootAsMediaContent(ByteBuffer _bb) { return getRootAsMediaContent(_bb, new MediaContent()); } 13 | public static MediaContent getRootAsMediaContent(ByteBuffer _bb, MediaContent obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } 14 | public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } 15 | public MediaContent __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } 16 | 17 | public Image images(int j) { return images(new Image(), j); } 18 | public Image images(Image obj, int j) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; } 19 | public int imagesLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; } 20 | public Media media() { return media(new Media()); } 21 | public Media media(Media obj) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; } 22 | 23 | public static int createMediaContent(FlatBufferBuilder builder, 24 | int imagesOffset, 25 | int mediaOffset) { 26 | builder.startObject(2); 27 | MediaContent.addMedia(builder, mediaOffset); 28 | MediaContent.addImages(builder, imagesOffset); 29 | return MediaContent.endMediaContent(builder); 30 | } 31 | 32 | public static void startMediaContent(FlatBufferBuilder builder) { builder.startObject(2); } 33 | public static void addImages(FlatBufferBuilder builder, int imagesOffset) { builder.addOffset(0, imagesOffset, 0); } 34 | public static int createImagesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); } 35 | public static void startImagesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); } 36 | public static void addMedia(FlatBufferBuilder builder, int mediaOffset) { builder.addOffset(1, mediaOffset, 0); } 37 | public static int endMediaContent(FlatBufferBuilder builder) { 38 | int o = builder.endObject(); 39 | builder.required(o, 4); // images 40 | builder.required(o, 6); // media 41 | return o; 42 | } 43 | public static void finishMediaContentBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset); } 44 | public static void finishSizePrefixedMediaContentBuffer(FlatBufferBuilder builder, int offset) { builder.finishSizePrefixed(offset); } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /tpc/pregen/media.fbs/serializers/flatbuffers/media/Player.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package serializers.flatbuffers.media; 4 | 5 | public final class Player { 6 | private Player() { } 7 | public static final byte JAVA = 0; 8 | public static final byte FLASH = 1; 9 | 10 | public static final String[] names = { "JAVA", "FLASH", }; 11 | 12 | public static String name(int e) { return names[e]; } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /tpc/pregen/media.fbs/serializers/flatbuffers/media/Size.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package serializers.flatbuffers.media; 4 | 5 | public final class Size { 6 | private Size() { } 7 | public static final byte SMALL = 0; 8 | public static final byte LARGE = 1; 9 | 10 | public static final String[] names = { "SMALL", "LARGE", }; 11 | 12 | public static String name(int e) { return names[e]; } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /tpc/pregen/media.thrift/gen-javabean/serializers/thrift/media/Player.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Autogenerated by Thrift Compiler (0.13.0) 3 | * 4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | * @generated 6 | */ 7 | package serializers.thrift.media; 8 | 9 | 10 | @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.13.0)", date = "2020-07-03") 11 | public enum Player implements org.apache.thrift.TEnum { 12 | JAVA(0), 13 | FLASH(1); 14 | 15 | private final int value; 16 | 17 | private Player(int value) { 18 | this.value = value; 19 | } 20 | 21 | /** 22 | * Get the integer value of this enum value, as defined in the Thrift IDL. 23 | */ 24 | public int getValue() { 25 | return value; 26 | } 27 | 28 | /** 29 | * Find a the enum type by its integer value, as defined in the Thrift IDL. 30 | * @return null if the value is not found. 31 | */ 32 | @org.apache.thrift.annotation.Nullable 33 | public static Player findByValue(int value) { 34 | switch (value) { 35 | case 0: 36 | return JAVA; 37 | case 1: 38 | return FLASH; 39 | default: 40 | return null; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tpc/pregen/media.thrift/gen-javabean/serializers/thrift/media/Size.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Autogenerated by Thrift Compiler (0.13.0) 3 | * 4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | * @generated 6 | */ 7 | package serializers.thrift.media; 8 | 9 | 10 | @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.13.0)", date = "2020-07-03") 11 | public enum Size implements org.apache.thrift.TEnum { 12 | SMALL(0), 13 | LARGE(1); 14 | 15 | private final int value; 16 | 17 | private Size(int value) { 18 | this.value = value; 19 | } 20 | 21 | /** 22 | * Get the integer value of this enum value, as defined in the Thrift IDL. 23 | */ 24 | public int getValue() { 25 | return value; 26 | } 27 | 28 | /** 29 | * Find a the enum type by its integer value, as defined in the Thrift IDL. 30 | * @return null if the value is not found. 31 | */ 32 | @org.apache.thrift.annotation.Nullable 33 | public static Size findByValue(int value) { 34 | switch (value) { 35 | case 0: 36 | return SMALL; 37 | case 1: 38 | return LARGE; 39 | default: 40 | return null; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tpc/run-bench.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | set -e 3 | 4 | raw_result_dir="results/raw" 5 | 6 | mem=-Xmx256m 7 | clz=serializers.BenchmarkRunner 8 | 9 | cpgen=$(cat build/gen-cp) 10 | cplib=$(cat build/lib-cp) 11 | sep=':' 12 | # cygwin 13 | case "`uname`" in 14 | CYGWIN*) sep=';' ;; 15 | esac 16 | 17 | cp=./build/bytecode/main$sep$cpgen$sep$cplib 18 | 19 | # for low run-to-run jitter (anyway expect ~3% run-to-run jitter) 20 | # testTime=60000 21 | # warmupTime=60000 22 | # turn off turbo boost and any other kind of dynamic clock scaling 23 | 24 | testTime=10000 25 | warmupTime=15000 26 | iter=2000 27 | 28 | if [ $# -eq 0 ]; then 29 | if [ -e "$raw_result_dir" ]; then 30 | rm -r "$raw_result_dir" 31 | fi 32 | sentence=$(java -cp $cp serializers.BenchmarkExporter) # just grab all serializers 33 | elif [ $# -eq 1 ]; then 34 | sentence=$1 35 | else 36 | echo "Expecting zero or one argument, got $#." 1>&2 37 | exit 1 38 | fi 39 | 40 | mkdir -p "$raw_result_dir" 41 | 42 | sentence=${sentence//,/$'\n'} # change the colons to white space 43 | for word in $sentence 44 | do 45 | echo "running $word .." 46 | file=$word-result.txt 47 | file="$raw_result_dir"/${file//\//-} # change '/' to '-' 48 | echo $word > $file 49 | java $mem -cp $cp $clz -iterations=$iter -warmup-time=$warmupTime -testRunMillis=$testTime -include=$word data/media.1.json >> $file || code=$? 50 | if [[ $code -ne 0 ]]; then 51 | echo "ERROR: exit code $code" 52 | exit $code 53 | fi 54 | done 55 | 56 | # find files with no numbers => errors 57 | echo "" 58 | echo "=====================================================================================" 59 | echo "errors:" 60 | find ./results/raw/. -print -type f -name "*.txt" -exec tail -1 {} \; | grep -B 1 create 61 | echo "=====================================================================================" 62 | echo "" 63 | 64 | exec ./mk-stats.sh 65 | -------------------------------------------------------------------------------- /tpc/schema/media.activemq.proto: -------------------------------------------------------------------------------- 1 | // See README.txt for information and build instructions. 2 | 3 | package serializers.activemq.media; 4 | 5 | option java_package = "serializers.activemq.media"; 6 | option java_outer_classname = "MediaContentHolder"; 7 | option optimize_for = SPEED; 8 | 9 | message Image { 10 | required string uri = 1; //url to the thumbnail 11 | optional string title = 2; //used in the html ALT 12 | required int32 width = 3; // of the image 13 | required int32 height = 4; // of the image 14 | enum Size { 15 | SMALL = 0; 16 | LARGE = 1; 17 | } 18 | required Size size = 5; // of the image (in relative terms, provided by cnbc for example) 19 | } 20 | 21 | message Media { 22 | required string uri = 1; //uri to the video, may not be an actual URL 23 | optional string title = 2; //used in the html ALT 24 | required int32 width = 3; // of the video 25 | required int32 height = 4; // of the video 26 | required string format = 5; //avi, jpg, youtube, cnbc, audio/mpeg formats ... 27 | required int64 duration = 6; //time in miliseconds 28 | required int64 size = 7; //file size 29 | optional int32 bitrate = 8; //video 30 | repeated string person = 9; //name of a person featured in the video 31 | enum Player { 32 | JAVA = 0; 33 | FLASH = 1; 34 | } 35 | required Player player = 10; //in case of a player specific media 36 | optional string copyright = 11;//media copyright 37 | } 38 | 39 | message MediaContent { 40 | repeated Image image = 1; 41 | required Media media = 2; 42 | } 43 | -------------------------------------------------------------------------------- /tpc/schema/media.avro: -------------------------------------------------------------------------------- 1 | {"type": "record", "name": "MediaContent", "namespace": "serializers.avro.media", "fields": [ 2 | {"name": "images", "type": {"type": "array", 3 | "items": {"type": "record", "name": "Image", 4 | "fields": [ 5 | {"name": "uri", "type": "string"}, 6 | {"name": "title", "type": ["null", "string"]}, 7 | {"name": "width", "type": "int"}, 8 | {"name": "height", "type": "int"}, 9 | {"name": "size", "type": "int"} 10 | ] 11 | } 12 | }}, 13 | {"name": "media", 14 | "type": {"type": "record", "name": "Media", 15 | "fields": [ 16 | {"name": "uri", "type": "string"}, 17 | {"name": "title", "type": ["null", "string"]}, 18 | {"name": "width", "type": "int"}, 19 | {"name": "height", "type": "int"}, 20 | {"name": "format", "type": "string"}, 21 | {"name": "duration", "type": "long"}, 22 | {"name": "size", "type": "long"}, 23 | {"name": "bitrate", "type": ["null", "int"]}, 24 | {"name": "persons", "type": {"type": "array", "items": "string"}}, 25 | {"name": "player", "type": "int"}, 26 | {"name": "copyright", "type": ["null", "string"]} 27 | ] 28 | } 29 | } 30 | ]} 31 | -------------------------------------------------------------------------------- /tpc/schema/media.capnp: -------------------------------------------------------------------------------- 1 | @0xfdb08e6f13e7cf36; 2 | using Java = import "/java.capnp"; 3 | $Java.package("serializers.capnproto.media"); 4 | $Java.outerClassname("Mediacontent"); 5 | 6 | struct Image { 7 | uri @0 :Text; 8 | title @1 :Text; 9 | width @2 :Int32; 10 | height @3 :Int32; 11 | enum Size { 12 | small @0; 13 | large @1; 14 | } 15 | size @4 :Size; 16 | } 17 | 18 | struct Media { 19 | uri @0 :Text; 20 | title @1 :Text; 21 | width @2 :Int32; 22 | height @3 :Int32; 23 | format @4 :Text; 24 | duration @5 :Int64; 25 | size @6 :Int64; 26 | bitrate @7 :Int32; 27 | persons @8 :List(Text); 28 | enum Player { 29 | java @0; 30 | flash @1; 31 | } 32 | player @9 :Player; 33 | copyright @10 :Text; 34 | } 35 | 36 | struct MediaContent { 37 | images @0 :List(Image); 38 | media @1 :Media; 39 | } 40 | -------------------------------------------------------------------------------- /tpc/schema/media.colf: -------------------------------------------------------------------------------- 1 | package media 2 | 3 | type mediaContent struct { 4 | images []image 5 | media media 6 | } 7 | 8 | type image struct { 9 | uri text 10 | title text 11 | width int32 12 | height int32 13 | small bool 14 | large bool 15 | } 16 | 17 | type media struct { 18 | uri text 19 | title text 20 | width int32 21 | height int32 22 | format text 23 | duration int64 24 | size int64 25 | persons []text 26 | copyright text 27 | bitrate int32 28 | hasBitrate bool 29 | flashPlay bool 30 | javaPlay bool 31 | } 32 | -------------------------------------------------------------------------------- /tpc/schema/media.fbs: -------------------------------------------------------------------------------- 1 | namespace serializers.flatbuffers.media; 2 | 3 | enum Size:byte { 4 | SMALL = 0, 5 | LARGE = 1 6 | } 7 | enum Player:byte { 8 | JAVA = 0, 9 | FLASH = 1 10 | } 11 | 12 | table Image { 13 | uri:string (id: 0, required); 14 | title:string (id: 1); 15 | width:int (id: 2); 16 | height:int (id: 3); 17 | size:Size (id: 4); 18 | } 19 | 20 | table Media { 21 | uri:string (id: 0, required); 22 | title:string (id: 1); 23 | width:int (id: 2); 24 | height:int (id: 3); 25 | format:string (id: 4, required); 26 | duration:long (id: 5); 27 | size:long (id: 6); 28 | bitrate:int (id: 7); 29 | persons:[string] (id: 8, required); 30 | player:Player (id: 9); 31 | copyright:string (id: 10); 32 | } 33 | 34 | table MediaContent { 35 | images:[Image] (id: 0, required); 36 | media:Media (id: 1, required); 37 | } 38 | 39 | root_type MediaContent; -------------------------------------------------------------------------------- /tpc/schema/media.proto: -------------------------------------------------------------------------------- 1 | // See README.txt for information and build instructions. 2 | 3 | package serializers.protobuf.media; 4 | 5 | option java_package = "serializers.protobuf.media"; 6 | option java_outer_classname = "MediaContentHolder"; 7 | option optimize_for = SPEED; 8 | 9 | message Image { 10 | required string uri = 1; //url to the thumbnail 11 | optional string title = 2; //used in the html ALT 12 | required int32 width = 3; // of the image 13 | required int32 height = 4; // of the image 14 | enum Size { 15 | SMALL = 0; 16 | LARGE = 1; 17 | } 18 | required Size size = 5; // of the image (in relative terms, provided by cnbc for example) 19 | } 20 | 21 | message Media { 22 | required string uri = 1; //uri to the video, may not be an actual URL 23 | optional string title = 2; //used in the html ALT 24 | required int32 width = 3; // of the video 25 | required int32 height = 4; // of the video 26 | required string format = 5; //avi, jpg, youtube, cnbc, audio/mpeg formats ... 27 | required int64 duration = 6; //time in miliseconds 28 | required int64 size = 7; //file size 29 | optional int32 bitrate = 8; //video 30 | repeated string person = 9; //name of a person featured in the video 31 | enum Player { 32 | JAVA = 0; 33 | FLASH = 1; 34 | } 35 | required Player player = 10; //in case of a player specific media 36 | optional string copyright = 11;//media copyright 37 | } 38 | 39 | message MediaContent { 40 | repeated Image image = 1; 41 | required Media media = 2; 42 | } 43 | -------------------------------------------------------------------------------- /tpc/schema/media.proto.jackson: -------------------------------------------------------------------------------- 1 | // See README.txt for information and build instructions. 2 | 3 | package serializers.protobuf.media; 4 | 5 | option java_package = "serializers.protobuf.media"; 6 | option java_outer_classname = "MediaContentHolder"; 7 | option optimize_for = SPEED; 8 | 9 | message Image { 10 | required string uri = 1; //url to the thumbnail 11 | optional string title = 2; //used in the html ALT 12 | required int32 width = 3; // of the image 13 | required int32 height = 4; // of the image 14 | enum Size { 15 | SMALL = 0; 16 | LARGE = 1; 17 | } 18 | required Size size = 5; // of the image (in relative terms, provided by cnbc for example) 19 | } 20 | 21 | message Media { 22 | required string uri = 1; //uri to the video, may not be an actual URL 23 | optional string title = 2; //used in the html ALT 24 | required int32 width = 3; // of the video 25 | required int32 height = 4; // of the video 26 | required string format = 5; //avi, jpg, youtube, cnbc, audio/mpeg formats ... 27 | required int64 duration = 6; //time in miliseconds 28 | required int64 size = 7; //file size 29 | optional int32 bitrate = 8; //video 30 | repeated string persons = 9; //names of persons featured in the video 31 | enum Player { 32 | JAVA = 0; 33 | FLASH = 1; 34 | } 35 | required Player player = 10; //in case of a player specific media 36 | optional string copyright = 11;//media copyright 37 | } 38 | 39 | message MediaContent { 40 | repeated Image images = 1; 41 | required Media media = 2; 42 | } 43 | -------------------------------------------------------------------------------- /tpc/schema/media.protostuff.proto: -------------------------------------------------------------------------------- 1 | // See README.txt for information and build instructions. 2 | 3 | package serializers.protostuff.media; 4 | 5 | option java_package = "serializers.protostuff.media"; 6 | option java_outer_classname = "MediaContentHolder"; 7 | option optimize_for = SPEED; 8 | 9 | message Image { 10 | required string uri = 1; //url to the thumbnail 11 | optional string title = 2; //used in the html ALT 12 | required int32 width = 3; // of the image 13 | required int32 height = 4; // of the image 14 | enum Size { 15 | SMALL = 0; 16 | LARGE = 1; 17 | } 18 | required Size size = 5; // of the image (in relative terms, provided by cnbc for example) 19 | } 20 | 21 | message Media { 22 | required string uri = 1; //uri to the video, may not be an actual URL 23 | optional string title = 2; //used in the html ALT 24 | required int32 width = 3; // of the video 25 | required int32 height = 4; // of the video 26 | required string format = 5; //avi, jpg, youtube, cnbc, audio/mpeg formats ... 27 | required int64 duration = 6; //time in miliseconds 28 | required int64 size = 7; //file size 29 | optional int32 bitrate = 8; //video 30 | repeated string person = 9; //name of a person featured in the video 31 | enum Player { 32 | JAVA = 0; 33 | FLASH = 1; 34 | } 35 | required Player player = 10; //in case of a player specific media 36 | optional string copyright = 11;//media copyright 37 | } 38 | 39 | message MediaContent { 40 | repeated Image image = 1; 41 | required Media media = 2; 42 | } 43 | -------------------------------------------------------------------------------- /tpc/schema/media.thrift: -------------------------------------------------------------------------------- 1 | namespace java serializers.thrift.media 2 | 3 | typedef i32 int 4 | typedef i64 long 5 | 6 | enum Size { 7 | SMALL = 0, 8 | LARGE = 1, 9 | } 10 | 11 | enum Player { 12 | JAVA = 0, 13 | FLASH = 1, 14 | } 15 | 16 | /** 17 | * Some comment... 18 | */ 19 | struct Image { 20 | 1: string uri, //url to the images 21 | 2: optional string title, 22 | 3: required int width, 23 | 4: required int height, 24 | 5: required Size size, 25 | } 26 | 27 | struct Media { 28 | 1: string uri, //url to the thumbnail 29 | 2: optional string title, 30 | 3: required int width, 31 | 4: required int height, 32 | 5: required string format, 33 | 6: required long duration, 34 | 7: required long size, 35 | 8: optional int bitrate, 36 | 9: required list person, 37 | 10: required Player player, 38 | 11: optional string copyright, 39 | } 40 | 41 | struct MediaContent { 42 | 1: required list image, 43 | 2: required Media media, 44 | } 45 | -------------------------------------------------------------------------------- /tpc/src/data/ReprUtil.java: -------------------------------------------------------------------------------- 1 | package data; 2 | 3 | public class ReprUtil 4 | { 5 | public static String repr(String s) 6 | { 7 | if (s == null) return "null"; 8 | return '"' + s + '"'; 9 | } 10 | 11 | public static String repr(Iterable it) 12 | { 13 | StringBuilder buf = new StringBuilder(); 14 | buf.append('['); 15 | String sep = ""; 16 | for (String s : it) { 17 | buf.append(sep); sep = ", "; 18 | buf.append(repr(s)); 19 | } 20 | buf.append(']'); 21 | return buf.toString(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tpc/src/data/media/Image.java: -------------------------------------------------------------------------------- 1 | package data.media; 2 | 3 | import com.dslplatform.json.CompiledJson; 4 | import com.dslplatform.json.JsonAttribute; 5 | 6 | import javax.xml.bind.annotation.XmlAccessType; 7 | import javax.xml.bind.annotation.XmlAccessorType; 8 | 9 | import static data.ReprUtil.repr; 10 | 11 | @XmlAccessorType(XmlAccessType.FIELD) 12 | @CompiledJson(formats = {CompiledJson.Format.ARRAY, CompiledJson.Format.OBJECT}) 13 | public class Image implements java.io.Serializable 14 | { 15 | private static final long serialVersionUID = 1L; 16 | 17 | public enum Size { 18 | SMALL, LARGE 19 | } 20 | 21 | public String uri; 22 | 23 | public String title; // Can be null 24 | public int width; 25 | public int height; 26 | public Size size; 27 | 28 | public Image() {} 29 | 30 | public Image (String uri, String title, int width, int height, Size size) { 31 | this.height = height; 32 | this.title = title; 33 | this.uri = uri; 34 | this.width = width; 35 | this.size = size; 36 | } 37 | 38 | @Override 39 | public boolean equals(Object o) 40 | { 41 | if (this == o) return true; 42 | if (o == null || getClass() != o.getClass()) return false; 43 | 44 | Image image = (Image) o; 45 | 46 | if (height != image.height) return false; 47 | if (width != image.width) return false; 48 | if (size != image.size) return false; 49 | if (title != null ? !title.equals(image.title) : image.title != null) return false; 50 | if (uri != null ? !uri.equals(image.uri) : image.uri != null) return false; 51 | 52 | return true; 53 | } 54 | 55 | @Override 56 | public int hashCode() 57 | { 58 | int result = uri != null ? uri.hashCode() : 0; 59 | result = 31 * result + (title != null ? title.hashCode() : 0); 60 | result = 31 * result + width; 61 | result = 31 * result + height; 62 | result = 31 * result + (size != null ? size.hashCode() : 0); 63 | return result; 64 | } 65 | 66 | public String toString () { 67 | StringBuilder sb = new StringBuilder(); 68 | sb.append("[Image "); 69 | sb.append("uri=").append(repr(uri)); 70 | sb.append(", title=").append(repr(title)); 71 | sb.append(", width=").append(width); 72 | sb.append(", height=").append(height); 73 | sb.append(", size=").append(size); 74 | sb.append("]"); 75 | return sb.toString(); 76 | } 77 | 78 | public void setUri(String uri) { 79 | this.uri = uri; 80 | } 81 | 82 | public void setTitle(String title) { 83 | this.title = title; 84 | } 85 | 86 | public void setWidth(int width) { 87 | this.width = width; 88 | } 89 | 90 | public void setHeight(int height) { 91 | this.height = height; 92 | } 93 | 94 | public void setSize(Size size) { 95 | this.size = size; 96 | } 97 | 98 | @JsonAttribute(index = 1) 99 | public String getUri() { 100 | return uri; 101 | } 102 | 103 | @JsonAttribute(index = 2) 104 | public String getTitle() { 105 | return title; 106 | } 107 | 108 | @JsonAttribute(index = 3) 109 | public int getWidth() { 110 | return width; 111 | } 112 | 113 | @JsonAttribute(index = 4) 114 | public int getHeight() { 115 | return height; 116 | } 117 | 118 | @JsonAttribute(index = 5) 119 | public Size getSize() { 120 | return size; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /tpc/src/data/media/MediaContent.java: -------------------------------------------------------------------------------- 1 | package data.media; 2 | 3 | import com.dslplatform.json.CompiledJson; 4 | import com.dslplatform.json.JsonAttribute; 5 | 6 | import javax.xml.bind.annotation.XmlAccessType; 7 | import javax.xml.bind.annotation.XmlAccessorType; 8 | import javax.xml.bind.annotation.XmlRootElement; 9 | import java.util.List; 10 | 11 | @SuppressWarnings("serial") 12 | @XmlRootElement 13 | @XmlAccessorType(XmlAccessType.FIELD) 14 | @CompiledJson(formats = {CompiledJson.Format.ARRAY, CompiledJson.Format.OBJECT}) 15 | public class MediaContent implements java.io.Serializable 16 | { 17 | public Media media; 18 | public List images; 19 | 20 | public MediaContent() {} 21 | 22 | public MediaContent (Media media, List images) { 23 | this.media = media; 24 | this.images = images; 25 | } 26 | 27 | @Override 28 | public boolean equals(Object o) 29 | { 30 | if (this == o) return true; 31 | if (o == null || getClass() != o.getClass()) return false; 32 | 33 | MediaContent that = (MediaContent) o; 34 | 35 | if (images != null ? !images.equals(that.images) : that.images != null) return false; 36 | if (media != null ? !media.equals(that.media) : that.media != null) return false; 37 | 38 | return true; 39 | } 40 | 41 | @Override 42 | public int hashCode() 43 | { 44 | int result = media != null ? media.hashCode() : 0; 45 | result = 31 * result + (images != null ? images.hashCode() : 0); 46 | return result; 47 | } 48 | 49 | public String toString() { 50 | StringBuilder sb = new StringBuilder(); 51 | sb.append("[MediaContent: "); 52 | sb.append("media=").append(media); 53 | sb.append(", images=").append(images); 54 | sb.append("]"); 55 | return sb.toString(); 56 | } 57 | 58 | public void setMedia(Media media) { 59 | this.media = media; 60 | } 61 | 62 | public void setImages(List images) { 63 | this.images = images; 64 | } 65 | 66 | @JsonAttribute(index = 1) 67 | public Media getMedia() { 68 | return media; 69 | } 70 | 71 | @JsonAttribute(index = 2) 72 | public List getImages() { 73 | return images; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /tpc/src/data/media/MediaTransformer.java: -------------------------------------------------------------------------------- 1 | package data.media; 2 | 3 | import serializers.Transformer; 4 | 5 | public abstract class MediaTransformer extends Transformer 6 | { 7 | public MediaContent[] sourceArray(int size) { return new MediaContent[size]; } 8 | 9 | // just defined to work around Scala issue 10 | public B[] resultArray(int size) { throw new UnsupportedOperationException("Please implement for "+getClass().getName()); } 11 | } 12 | -------------------------------------------------------------------------------- /tpc/src/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tpc/src/serializers/BenchmarkExporter.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | /** 4 | * Copyright (c) 2012, Ruediger Moeller. All rights reserved. 5 | *

6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | *

11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | *

16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 | * MA 02110-1301 USA 20 | *

21 | * Date: 09.03.14 22 | * Time: 10:09 23 | * To change this template use File | Settings | File Templates. 24 | */ 25 | 26 | import java.util.ArrayList; 27 | import java.util.HashMap; 28 | import java.util.Iterator; 29 | import java.util.Set; 30 | 31 | /** 32 | * tweak to generate a string containing all registered benchmarks and extract bench feature data. called by run script 33 | */ 34 | public class BenchmarkExporter extends BenchmarkRunner { 35 | 36 | String alltests = ""; // ',' separated 37 | HashMap featureMap = new HashMap(); // have to map back after running .. sigh 38 | 39 | public BenchmarkExporter() { 40 | runBenchmark(new String[0]); 41 | } 42 | 43 | protected void runBenchmark(String[] args) 44 | { 45 | TestGroups groups = new TestGroups(); 46 | addTests(groups); 47 | Set media = groups.groupMap.get("media").entries.keySet(); 48 | for (Iterator iterator = media.iterator(); iterator.hasNext(); ) { 49 | String next = iterator.next().trim(); 50 | if ( ! next.equals("cks") && ! next.equals("cks-text") ) // used to read data, exclude 51 | alltests += next+ (iterator.hasNext() ? "," : ""); 52 | SerFeatures features = groups.groupMap.get("media").entries.get(next).serializer.getFeatures(); 53 | // System.out.println("serializer:"+next+" miscFeatures: "+miscFeatures); 54 | featureMap.put(next, features); 55 | } 56 | } 57 | 58 | public String getAlltests() { 59 | return alltests; 60 | } 61 | 62 | public HashMap getFeatureMap() { 63 | return featureMap; 64 | } 65 | 66 | public static void main(String arg[]) { 67 | System.out.println(new BenchmarkExporter().getAlltests()); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /tpc/src/serializers/Hessian.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.Array; 5 | 6 | import data.media.MediaContent; 7 | 8 | import com.caucho.hessian.io.*; 9 | 10 | public class Hessian 11 | { 12 | public static void register(TestGroups groups) 13 | { 14 | groups.media.add(JavaBuiltIn.mediaTransformer, new HessianSerializer(MediaContent.class), 15 | new SerFeatures( 16 | SerFormat.BIN_CROSSLANG, 17 | SerGraph.FULL_GRAPH, 18 | SerClass.ZERO_KNOWLEDGE,"" 19 | ) 20 | ); 21 | } 22 | 23 | // ------------------------------------------------------------ 24 | // Serializer (just one) 25 | 26 | public final static class HessianSerializer extends Serializer 27 | { 28 | private final Class clz; 29 | 30 | public HessianSerializer(Class c) { clz = c; } 31 | 32 | public String getName() { return "hessian"; } 33 | 34 | @SuppressWarnings("unchecked") 35 | public T deserialize(byte[] array) throws Exception 36 | { 37 | ByteArrayInputStream in = new ByteArrayInputStream(array); 38 | Hessian2StreamingInput hin = new Hessian2StreamingInput(in); 39 | return (T) hin.readObject(); 40 | } 41 | 42 | public byte[] serialize(T data) throws java.io.IOException 43 | { 44 | ByteArrayOutputStream out = outputStream(data); 45 | Hessian2StreamingOutput hout = new Hessian2StreamingOutput(out); 46 | hout.writeObject(data); 47 | return out.toByteArray(); 48 | } 49 | 50 | @Override 51 | public final void serializeItems(T[] items, OutputStream out) throws Exception 52 | { 53 | Hessian2StreamingOutput hout = new Hessian2StreamingOutput(out); 54 | for (Object item : items) { 55 | hout.writeObject(item); 56 | } 57 | hout.flush(); 58 | hout.close(); 59 | } 60 | 61 | @SuppressWarnings("unchecked") 62 | @Override 63 | public T[] deserializeItems(InputStream in, int numberOfItems) throws Exception 64 | { 65 | Hessian2StreamingInput hin = new Hessian2StreamingInput(in); 66 | T[] result = (T[]) Array.newInstance(clz, numberOfItems); 67 | for (int i = 0; i < numberOfItems; ++i) { 68 | result[i] = (T) hin.readObject(); 69 | } 70 | hin.close(); 71 | return result; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /tpc/src/serializers/JBossSerialization.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.io.OutputStream; 8 | import java.lang.reflect.Array; 9 | 10 | import org.jboss.serial.io.JBossObjectInputStream; 11 | import org.jboss.serial.io.JBossObjectOutputStream; 12 | import org.jboss.serial.util.StringUtilBuffer; 13 | 14 | import data.media.MediaContent; 15 | 16 | public class JBossSerialization { 17 | 18 | public static void register(final TestGroups groups) { 19 | groups.media.add( 20 | JavaBuiltIn.mediaTransformer, 21 | new JBossSerializationSerializer(MediaContent.class) 22 | , 23 | new SerFeatures( 24 | SerFormat.BINARY, 25 | SerGraph.FULL_GRAPH, 26 | SerClass.ZERO_KNOWLEDGE, 27 | "" 28 | ) 29 | ); 30 | } 31 | 32 | private static final class JBossSerializationSerializer 33 | extends Serializer { 34 | 35 | private final Class clz; 36 | 37 | public JBossSerializationSerializer(final Class c) { 38 | clz = c; 39 | } 40 | 41 | @Override 42 | public String getName() { 43 | return "jboss-serialization"; 44 | } 45 | 46 | @Override 47 | @SuppressWarnings("unchecked") 48 | public T deserialize(final byte[] array) throws Exception { 49 | ByteArrayInputStream bais = new ByteArrayInputStream(array); 50 | JBossObjectInputStream jois = new JBossObjectInputStream( 51 | bais, 52 | new StringUtilBuffer(BUFFER_SIZE, BUFFER_SIZE) 53 | ); 54 | return (T) jois.readObject(); 55 | } 56 | 57 | @Override 58 | public byte[] serialize(final T data) throws IOException { 59 | ByteArrayOutputStream baos = outputStream(data); 60 | JBossObjectOutputStream joos = new JBossObjectOutputStream( 61 | baos, 62 | new StringUtilBuffer(BUFFER_SIZE, BUFFER_SIZE) 63 | ); 64 | joos.writeObject(data); 65 | return baos.toByteArray(); 66 | } 67 | 68 | @Override 69 | public final void serializeItems(final T[] items, final OutputStream os) 70 | throws Exception { 71 | JBossObjectOutputStream jous = new JBossObjectOutputStream(os); 72 | for (Object item : items) { 73 | jous.writeObject(item); 74 | } 75 | jous.flush(); 76 | jous.close(); 77 | } 78 | 79 | @SuppressWarnings("unchecked") 80 | @Override 81 | public T[] deserializeItems(final InputStream in, final int numOfItems) 82 | throws Exception { 83 | JBossObjectInputStream jois = new JBossObjectInputStream(in); 84 | T[] result = (T[]) Array.newInstance(clz, numOfItems); 85 | for (int i = 0; i < numOfItems; ++i) { 86 | result[i] = (T) jois.readObject(); 87 | } 88 | jois.close(); 89 | return result; 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /tpc/src/serializers/MiscFeatures.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | /** 4 | * Copyright (c) 2012, Ruediger Moeller. All rights reserved. 5 | *

6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | *

11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | *

16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 | * MA 02110-1301 USA 20 | *

21 | * Date: 11.03.14 22 | * Time: 19:48 23 | * To change this template use File | Settings | File Templates. 24 | */ 25 | 26 | /** 27 | * describes misc miscFeatures a serializer might have. 28 | */ 29 | public enum MiscFeatures { 30 | VERSIONING_BACKWARD_COMPATIBLE, 31 | VERSIONING_FORWARD_COMPATIBLE, 32 | VERSIONING_MISMATCH_DETECTION, 33 | CONTAINS_SCHEMA, 34 | OPTIMIZATION_BY_ANNOTATION 35 | } 36 | -------------------------------------------------------------------------------- /tpc/src/serializers/SerClass.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | /** 4 | * Copyright (c) 2012, Ruediger Moeller. All rights reserved. 5 | *

6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | *

11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | *

16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 | * MA 02110-1301 USA 20 | *

21 | * Date: 09.03.14 22 | * Time: 11:31 23 | * To change this template use File | Settings | File Templates. 24 | */ 25 | public enum SerClass { 26 | /** 27 | * nothing must be known in advance or language built-in (e.g. JDK Serializable) 28 | */ 29 | ZERO_KNOWLEDGE, 30 | /** 31 | * requires knowledge in advance which classes can be serialized. Preconfiguration/Code Generation required 32 | */ 33 | CLASSES_KNOWN, 34 | /** 35 | * requires knowledge in advance which classes can be serialized. Preconfiguration/Code Generation required 36 | * additionally field specific manually written read/write code 37 | */ 38 | MANUAL_OPT, 39 | /** 40 | * add new category if you fall into this :-) 41 | */ 42 | MISC 43 | } 44 | -------------------------------------------------------------------------------- /tpc/src/serializers/SerFeatures.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | import java.util.EnumSet; 4 | import java.util.Formatter; 5 | 6 | /** 7 | * Copyright (c) 2012, Ruediger Moeller. All rights reserved. 8 | *

9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | *

14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | *

19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 | * MA 02110-1301 USA 23 | *

24 | * Date: 09.03.14 25 | * Time: 11:41 26 | * To change this template use File | Settings | File Templates. 27 | */ 28 | public class SerFeatures { 29 | SerFormat format = SerFormat.MISC; 30 | SerGraph graph = SerGraph.UNKNOWN; 31 | SerClass clz = SerClass.MISC; 32 | // FIXME: should have used one EnumSet from the beginning so we could get rid of 33 | // SerFormat,SerGraph,SerClass .. sigh. Too lazy to change this now :-). ruediger 34 | EnumSet miscFeatures = EnumSet.noneOf(MiscFeatures.class); 35 | String description; 36 | 37 | public SerFeatures() { 38 | } 39 | 40 | public SerFeatures(SerFormat format, SerGraph graph, SerClass clz) { 41 | this.format = format; 42 | this.graph = graph; 43 | this.clz = clz; 44 | } 45 | 46 | public SerFeatures(SerFormat format, SerGraph graph, SerClass clz, String description) { 47 | this.format = format; 48 | this.graph = graph; 49 | this.clz = clz; 50 | this.description = description; 51 | } 52 | 53 | public SerFeatures(SerFormat format, SerGraph graph, SerClass clz, String description, EnumSet features) { 54 | this.format = format; 55 | this.graph = graph; 56 | this.clz = clz; 57 | this.miscFeatures = features; 58 | this.description = description; 59 | } 60 | 61 | public EnumSet getMiscFeatures() { 62 | return miscFeatures; 63 | } 64 | 65 | public void setMiscFeatures(EnumSet miscFeatures) { 66 | this.miscFeatures = miscFeatures; 67 | } 68 | 69 | public String toString(String name) { 70 | Formatter format = new Formatter().format( 71 | "%-34s %-15s %-14s %-10s %-60s", 72 | name, 73 | getClz(), 74 | getFormat(), 75 | getGraph(), 76 | getMiscFeatures()+" "+getDescription() 77 | ); 78 | return format.toString(); 79 | } 80 | 81 | 82 | public String getDescription() { 83 | return description; 84 | } 85 | 86 | public void setDescription(String description) { 87 | this.description = description; 88 | } 89 | 90 | public SerFormat getFormat() { 91 | return format; 92 | } 93 | 94 | public void setFormat(SerFormat format) { 95 | this.format = format; 96 | } 97 | 98 | public SerGraph getGraph() { 99 | return graph; 100 | } 101 | 102 | public void setGraph(SerGraph graph) { 103 | this.graph = graph; 104 | } 105 | 106 | public SerClass getClz() { 107 | return clz; 108 | } 109 | 110 | public void setClz(SerClass clz) { 111 | this.clz = clz; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /tpc/src/serializers/SerFormat.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | /** 4 | * Copyright (c) 2012, Ruediger Moeller. All rights reserved. 5 | *

6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | *

11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | *

16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 | * MA 02110-1301 USA 20 | *

21 | * Date: 09.03.14 22 | * Time: 11:29 23 | */ 24 | public enum SerFormat { 25 | /** 26 | * unspecified binary format (e.g. JDK serialization) 27 | */ 28 | BINARY, 29 | /** 30 | * specified binary format which might be read by another language/implementation 31 | */ 32 | BIN_CROSSLANG, 33 | /** 34 | * text based JSon format 35 | */ 36 | JSON, 37 | /** 38 | * text based XML format 39 | */ 40 | XML, 41 | /** 42 | * none of the above 43 | */ 44 | MISC 45 | } 46 | 47 | -------------------------------------------------------------------------------- /tpc/src/serializers/SerGraph.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | /** 4 | * Copyright (c) 2012, Ruediger Moeller. All rights reserved. 5 | *

6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | *

11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | *

16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 | * MA 02110-1301 USA 20 | *

21 | * Date: 09.03.14 22 | * Time: 11:36 23 | * To change this template use File | Settings | File Templates. 24 | */ 25 | public enum SerGraph { 26 | /** 27 | * cannot process object graphs containing cyclic references (flat tree only) 28 | */ 29 | FLAT_TREE, 30 | /** 31 | * capable of read/write fully linked object graphs with reference restauration 32 | */ 33 | FULL_GRAPH, 34 | UNKNOWN 35 | } 36 | -------------------------------------------------------------------------------- /tpc/src/serializers/Serializer.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | import java.io.*; 4 | 5 | public abstract class Serializer 6 | { 7 | /** 8 | * Buffer size for serializers. Defaults to 1024 and can be changed 9 | * via system properties. Minimum set to 256. 10 | */ 11 | public static final int BUFFER_SIZE = Math.max( 12 | Integer.getInteger("buffer_size", 1024), 256); 13 | 14 | public abstract S deserialize(byte[] array) throws Exception; 15 | public abstract byte[] serialize(S content) throws Exception; 16 | public abstract String getName(); 17 | 18 | SerFeatures features = new SerFeatures(); // ruediger: everything misc by default. 19 | 20 | public ByteArrayOutputStream outputStream (S content) { 21 | return new ByteArrayOutputStream(BUFFER_SIZE); 22 | } 23 | 24 | public SerFeatures getFeatures() { 25 | return features; 26 | } 27 | 28 | public void setFeatures(SerFeatures features) { 29 | this.features = features; 30 | } 31 | 32 | // And then bit bigger default when serializing a list or array 33 | public ByteArrayOutputStream outputStreamForList (S[] items) { 34 | return new ByteArrayOutputStream(BUFFER_SIZE * items.length); 35 | } 36 | 37 | // Multi-item interfaces 38 | 39 | public S[] deserializeItems(InputStream in, int numberOfItems) throws Exception { 40 | throw new UnsupportedOperationException("Not implemented"); 41 | } 42 | 43 | public void serializeItems(S[] items, OutputStream out) throws Exception { 44 | throw new UnsupportedOperationException("Not implemented"); 45 | } 46 | 47 | @SuppressWarnings("resource") 48 | public final byte[] serializeAsBytes(S[] items) throws Exception { 49 | ByteArrayOutputStream bytes = outputStreamForList(items); 50 | serializeItems(items, bytes); 51 | return bytes.toByteArray(); 52 | } 53 | 54 | // // // Helper methods 55 | 56 | protected byte[] readAll(InputStream in) throws IOException 57 | { 58 | ByteArrayOutputStream bytes = new ByteArrayOutputStream(4000); 59 | byte[] buffer = new byte[4000]; 60 | int count; 61 | 62 | while ((count = in.read(buffer)) >= 0) { 63 | bytes.write(buffer, 0, count); 64 | } 65 | in.close(); 66 | return bytes.toByteArray(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /tpc/src/serializers/SimpleClassLoader.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | import java.util.zip.*; 6 | 7 | /** 8 | * Class loader to use for loading non-shared implementation classes. This is necessary so 9 | * that implementation classes can be loaded in, and as importantly, swapped out, 10 | * before and after test run. 11 | * 12 | * @author tatu 13 | */ 14 | public class SimpleClassLoader 15 | extends ClassLoader 16 | { 17 | private final HashMap loadedByteCode = new HashMap(); 18 | 19 | public SimpleClassLoader(ClassLoader parent, File dir) throws IOException 20 | { 21 | ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 22 | byte[] buffer = new byte[8000]; 23 | 24 | for (File file : dir.listFiles()) { 25 | if (!file.getName().endsWith(".jar")) continue; 26 | ZipInputStream zis = new ZipInputStream(new FileInputStream(file)); 27 | ZipEntry entry; 28 | 29 | while ((entry = zis.getNextEntry()) != null) { 30 | String name = entry.getName(); 31 | if (name.endsWith(".class")) { 32 | // strip out ".class"; replace '/' with '.' 33 | String className = name.substring(0, name.length()-6); 34 | className = className.replace('/', '.'); 35 | byte[] data = readAll(zis, buffer, bytes); 36 | if (loadedByteCode.put(name, data) != null) { 37 | throw new IllegalArgumentException("Duplicate class '"+className+"' (from jar '"+file.getPath()+"')"); 38 | } 39 | } 40 | } 41 | } 42 | } 43 | 44 | @Override 45 | public Class findClass(String name) 46 | { 47 | byte[] bytecode = loadedByteCode.get(name); 48 | if (bytecode == null) return null; 49 | return defineClass(name, bytecode, 0, bytecode.length); 50 | } 51 | 52 | private final byte[] readAll(InputStream in, byte[] buffer, ByteArrayOutputStream bytes) throws IOException 53 | { 54 | bytes.reset(); 55 | 56 | int count; 57 | 58 | while ((count = in.read(buffer)) > 0) { 59 | bytes.write(buffer, 0, count); 60 | } 61 | return bytes.toByteArray(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /tpc/src/serializers/TestCase.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | public abstract class TestCase 4 | { 5 | /** 6 | * @return avg time cost every iteration, measure in nanosecond unit 7 | */ 8 | public abstract double run(Transformer transformer, Serializer serializer, J value, int iterations) throws Exception; 9 | } 10 | -------------------------------------------------------------------------------- /tpc/src/serializers/TestGroup.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | import java.util.HashMap; 4 | import java.util.LinkedHashMap; 5 | import java.util.Map; 6 | 7 | public final class TestGroup 8 | { 9 | public final Map> entries = new LinkedHashMap>(); 10 | public final Map> extensionHandlers = new HashMap>(); 11 | 12 | public void add(Transformer transformer, Serializer serializer) 13 | { 14 | add(transformer,serializer,(SerFeatures)null); 15 | } 16 | 17 | public void add(Transformer transformer, Serializer serializer, SerFeatures features) 18 | { 19 | if ( features != null ) 20 | serializer.setFeatures(features); 21 | add_(transformer, serializer); 22 | } 23 | 24 | public Entry add_(Transformer transformer, Serializer serializer) 25 | { 26 | Entry entry = new Entry(transformer, serializer); 27 | 28 | @SuppressWarnings("unchecked") 29 | Entry entry_ = (Entry) entry; 30 | 31 | String name = entry_.serializer.getName(); 32 | Object displaced = entries.put(name, entry_); 33 | if (displaced != null) { 34 | throw new AssertionError("duplicate serializer name \"" + name + "\""); 35 | } 36 | 37 | return entry_; 38 | } 39 | 40 | public void addExtensionHandler(String extension, Transformer transformer, Serializer serializer) 41 | { 42 | Entry entry = new Entry(transformer, serializer); 43 | 44 | @SuppressWarnings("unchecked") 45 | Entry entry_ = (Entry) entry; 46 | 47 | Object displaced = extensionHandlers.put(extension, entry_); 48 | if (displaced != null) { 49 | throw new AssertionError("duplicate handler for extension \"" + extension + "\""); 50 | } 51 | } 52 | 53 | public static final class Entry 54 | { 55 | public final Transformer transformer; 56 | public final Serializer serializer; 57 | 58 | public Entry(Transformer transformer, Serializer serializer) 59 | { 60 | this.transformer = transformer; 61 | this.serializer = serializer; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /tpc/src/serializers/TestGroups.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.fasterxml.jackson.core.JsonFactory; 7 | import com.fasterxml.jackson.core.JsonParser; 8 | import serializers.jackson.JacksonJsonManual; 9 | 10 | public final class TestGroups 11 | { 12 | public final TestGroup media = new TestGroup(); 13 | { 14 | media.addExtensionHandler( 15 | "json", 16 | JavaBuiltIn.mediaTransformer, 17 | new JacksonJsonManual("", (JsonFactory) new JsonFactory().enable(JsonParser.Feature.ALLOW_COMMENTS))); 18 | } 19 | 20 | public final Map> groupMap = new HashMap>(); 21 | 22 | { 23 | groupMap.put("media", media); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tpc/src/serializers/Transformer.java: -------------------------------------------------------------------------------- 1 | package serializers; 2 | 3 | public abstract class Transformer 4 | { 5 | public abstract B forward(A a); 6 | public abstract A reverse(B a); 7 | public abstract A shallowReverse(B a); 8 | 9 | public abstract A[] sourceArray(int size); 10 | public abstract B[] resultArray(int size); 11 | 12 | public B[] forwardAll(A[] a) 13 | { 14 | // this is unfortunate shuffling around type variables, but has to do: 15 | B[] b = resultArray(a.length); 16 | forward(a, b); 17 | return b; 18 | } 19 | 20 | /** 21 | * Method called to convert an array of items from custom representation to standard one 22 | */ 23 | public void forward(A[] a, B[] b) 24 | { 25 | for (int i = 0, len = a.length; i < len; ++i) { 26 | b[i] = forward(a[i]); 27 | } 28 | } 29 | 30 | public A[] reverseAll(B[] b) 31 | { 32 | A[] a = sourceArray(b.length); 33 | for (int i = 0, len = b.length; i < len; ++i) { 34 | a[i] = reverse(b[i]); 35 | } 36 | return a; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tpc/src/serializers/avro/Avro.java: -------------------------------------------------------------------------------- 1 | package serializers.avro; 2 | 3 | import java.util.EnumSet; 4 | import org.apache.avro.Schema; 5 | import serializers.MiscFeatures; 6 | 7 | 8 | public class Avro 9 | { 10 | public static final EnumSet miscFeatures = EnumSet.of( 11 | MiscFeatures.VERSIONING_BACKWARD_COMPATIBLE, 12 | MiscFeatures.VERSIONING_FORWARD_COMPATIBLE, 13 | MiscFeatures.VERSIONING_MISMATCH_DETECTION); 14 | 15 | // ------------------------------------------------------------- 16 | // Media 17 | 18 | public static final class Media 19 | { 20 | public static final Schema sMediaContent = serializers.avro.media.MediaContent.SCHEMA$; 21 | public static final Schema sMedia = serializers.avro.media.Media.SCHEMA$; 22 | public static final Schema sImage = serializers.avro.media.Image.SCHEMA$; 23 | 24 | public static final Schema sImages = sMediaContent.getField("images").schema(); 25 | public static final Schema sPersons = sMedia.getField("persons").schema(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /tpc/src/serializers/dsljson/DSLJson.java: -------------------------------------------------------------------------------- 1 | package serializers.dsljson; 2 | 3 | import data.media.MediaContent; 4 | import serializers.*; 5 | 6 | import com.dslplatform.json.*; 7 | import com.dslplatform.json.runtime.Settings; 8 | 9 | public class DSLJson { 10 | 11 | public static void register(final TestGroups groups) { 12 | groups.media.add(JavaBuiltIn.mediaTransformer, new DSLJsonSerializer(false), new SerFeatures( 13 | SerFormat.JSON, SerGraph.FLAT_TREE, SerClass.CLASSES_KNOWN, "Serializes all properties with exact names.")); 14 | groups.media.add(JavaBuiltIn.mediaTransformer, new DSLJsonSerializer(true), new SerFeatures( 15 | SerFormat.JSON, SerGraph.FLAT_TREE, SerClass.CLASSES_KNOWN, 16 | "JSON array format - all properties without names.")); 17 | } 18 | 19 | static class DSLJsonSerializer extends Serializer { 20 | private final JsonWriter writer; 21 | private final JsonReader reader; 22 | private final JsonWriter.WriteObject encoder; 23 | private final JsonReader.ReadObject decoder; 24 | private final boolean asArray; 25 | 26 | DSLJsonSerializer(boolean asArray) { 27 | DslJson dslJson = new DslJson<>(Settings.withRuntime().allowArrayFormat(asArray).includeServiceLoader()); 28 | this.writer = dslJson.newWriter(); 29 | this.reader = dslJson.newReader(); 30 | this.encoder = dslJson.tryFindWriter(MediaContent.class); 31 | this.decoder = dslJson.tryFindReader(MediaContent.class); 32 | this.asArray = asArray; 33 | } 34 | 35 | @Override 36 | public String getName() { 37 | return asArray ? "json-array/dsl-json/databind" : "json/dsl-json/databind"; 38 | } 39 | 40 | @Override 41 | public MediaContent deserialize(final byte[] array) throws Exception { 42 | reader.process(array, array.length).read(); 43 | return decoder.read(reader); 44 | } 45 | 46 | @Override 47 | public byte[] serialize(final MediaContent content) throws Exception { 48 | writer.reset(); 49 | encoder.write(writer, content); 50 | return writer.toByteArray(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/AsArrayIntrospector.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.databind.introspect.Annotated; 5 | import com.fasterxml.jackson.databind.introspect.AnnotatedClass; 6 | import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; 7 | 8 | /** 9 | * Helper class used to force conditional "as-array" serialization 10 | * without requiring value classes to be annotated. 11 | */ 12 | class AsArrayIntrospector extends JacksonAnnotationIntrospector 13 | { 14 | private static final long serialVersionUID = 1L; 15 | 16 | @Override 17 | public JsonFormat.Value findFormat(Annotated ann) { 18 | // 2.4 frowns upon trying to use this for Enums, so avoid those 19 | // also, limit to just claiming classes (POJOs) require it, not properties 20 | if (ann instanceof AnnotatedClass) { 21 | AnnotatedClass ac = (AnnotatedClass) ann; 22 | if (ac.getAnnotated().isEnum()) { 23 | return null; 24 | } 25 | return JsonFormat.Value.forShape(JsonFormat.Shape.ARRAY); 26 | } 27 | return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/BaseJacksonDataBind.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import java.io.*; 4 | 5 | import com.fasterxml.jackson.core.*; 6 | import com.fasterxml.jackson.databind.JavaType; 7 | import com.fasterxml.jackson.databind.ObjectMapper; 8 | import com.fasterxml.jackson.databind.ObjectReader; 9 | import com.fasterxml.jackson.databind.ObjectWriter; 10 | 11 | public abstract class BaseJacksonDataBind extends BaseJacksonDriver 12 | { 13 | protected final JavaType type; 14 | protected final ObjectMapper mapper; 15 | protected final ObjectReader reader; 16 | protected final ObjectWriter writer; 17 | 18 | protected BaseJacksonDataBind(String name, Class clazz, ObjectMapper mapper) 19 | { 20 | super(name); 21 | type = mapper.getTypeFactory().constructType(clazz); 22 | this.mapper = mapper; 23 | reader = mapper.readerFor(type); 24 | writer = mapper.writerFor(type); 25 | } 26 | 27 | protected BaseJacksonDataBind(String name, JavaType type, 28 | ObjectMapper mapper, ObjectReader reader, ObjectWriter writer) 29 | { 30 | super(name); 31 | this.type = type; 32 | this.mapper = mapper; 33 | this.reader = reader; 34 | this.writer = writer; 35 | } 36 | 37 | protected final JsonParser constructParser(byte[] data) throws IOException { 38 | return mapper.getFactory().createParser(data, 0, data.length); 39 | } 40 | 41 | protected final JsonParser constructParser(InputStream in) throws IOException { 42 | return mapper.getFactory().createParser(in); 43 | } 44 | 45 | protected final JsonGenerator constructGenerator(OutputStream out) throws IOException { 46 | return mapper.getFactory().createGenerator(out, JsonEncoding.UTF8); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/BaseJacksonDriver.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.io.OutputStream; 6 | 7 | import serializers.Serializer; 8 | 9 | abstract class BaseJacksonDriver extends Serializer 10 | { 11 | protected final String name; 12 | 13 | protected BaseJacksonDriver(String n) 14 | { 15 | name = n; 16 | } 17 | 18 | @Override 19 | public final String getName() { 20 | return name; 21 | } 22 | 23 | @Override 24 | public abstract byte[] serialize(T data) throws IOException; 25 | 26 | @Override 27 | public abstract T deserialize(byte[] array) throws IOException; 28 | 29 | // // Future extensions for testing performance for item sequences 30 | 31 | @Override 32 | public abstract void serializeItems(T[] items, OutputStream out) throws Exception; 33 | 34 | @Override 35 | public abstract T[] deserializeItems(InputStream in, int numberOfItems) throws IOException; 36 | } 37 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/JacksonAvroDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import serializers.*; 4 | import serializers.avro.Avro; 5 | 6 | import com.fasterxml.jackson.databind.JavaType; 7 | import com.fasterxml.jackson.databind.ObjectMapper; 8 | import com.fasterxml.jackson.databind.ObjectReader; 9 | import com.fasterxml.jackson.databind.ObjectWriter; 10 | import com.fasterxml.jackson.databind.SerializationFeature; 11 | import com.fasterxml.jackson.dataformat.avro.AvroFactory; 12 | import com.fasterxml.jackson.dataformat.avro.AvroSchema; 13 | 14 | import data.media.MediaContent; 15 | 16 | public class JacksonAvroDatabind 17 | { 18 | public static void register(TestGroups groups) 19 | { 20 | ObjectMapper mapper = new ObjectMapper(new AvroFactory()); 21 | mapper.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX); 22 | JavaType type = mapper.constructType(MediaContent.class); 23 | AvroSchema schema = new AvroSchema(Avro.Media.sMediaContent); 24 | ObjectReader reader = mapper.readerFor(type).with(schema); 25 | ObjectWriter writer = mapper.writerFor(type).with(schema); 26 | groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind 27 | ("avro/jackson/databind", type, mapper, reader, writer), 28 | new SerFeatures( 29 | SerFormat.JSON, 30 | SerGraph.FLAT_TREE, 31 | SerClass.ZERO_KNOWLEDGE, 32 | "" 33 | ) 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/JacksonCBORDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.fasterxml.jackson.dataformat.cbor.*; 5 | 6 | import serializers.JavaBuiltIn; 7 | import serializers.SerClass; 8 | import serializers.SerFeatures; 9 | import serializers.SerFormat; 10 | import serializers.SerGraph; 11 | import serializers.TestGroups; 12 | import data.media.MediaContent; 13 | 14 | public class JacksonCBORDatabind 15 | { 16 | public static void register(TestGroups groups) { // Jackson Smile defaults: share names, not values 17 | register(groups, true, false); 18 | } 19 | 20 | public static void register(TestGroups groups, boolean sharedNames, boolean sharedValues) 21 | { 22 | CBORFactory factory = new CBORFactory(); 23 | // no point in using enum names with binary format, so: 24 | ObjectMapper mapper = new ObjectMapper(factory); 25 | groups.media.add(JavaBuiltIn.mediaTransformer, 26 | new StdJacksonDataBind("cbor/jackson/databind", MediaContent.class, mapper), 27 | new SerFeatures(SerFormat.BIN_CROSSLANG, 28 | SerGraph.FLAT_TREE, 29 | SerClass.ZERO_KNOWLEDGE, 30 | "" 31 | )); 32 | 33 | groups.media.add(JavaBuiltIn.mediaTransformer, 34 | new JacksonJsonManual("cbor/jackson/manual", factory), 35 | new SerFeatures(SerFormat.BIN_CROSSLANG, 36 | SerGraph.FLAT_TREE, 37 | SerClass.MANUAL_OPT, 38 | "" 39 | )); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/JacksonJrDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.io.OutputStream; 6 | import java.lang.reflect.Array; 7 | 8 | import com.fasterxml.jackson.core.JsonGenerator; 9 | import com.fasterxml.jackson.core.JsonParser; 10 | import com.fasterxml.jackson.jr.ob.JSON; 11 | 12 | import data.media.MediaContent; 13 | import serializers.*; 14 | 15 | public class JacksonJrDatabind 16 | { 17 | public static void register(TestGroups groups) { 18 | groups.media.add(JavaBuiltIn.mediaTransformer, new JrSerializer(MediaContent.class), 19 | new SerFeatures( 20 | SerFormat.JSON, 21 | SerGraph.FLAT_TREE, 22 | SerClass.ZERO_KNOWLEDGE, 23 | "" 24 | ) 25 | ); 26 | } 27 | 28 | public final static class JrSerializer extends Serializer 29 | { 30 | private final Class type; 31 | private final JSON json; 32 | 33 | protected JrSerializer(Class t) 34 | { 35 | type = t; 36 | json = JSON.std; 37 | } 38 | 39 | @Override 40 | public String getName() { return "json/jackson-jr/databind"; } 41 | 42 | @Override 43 | public T deserialize(byte[] array) throws Exception { 44 | return json.beanFrom(type, array); 45 | } 46 | 47 | @Override 48 | public byte[] serialize(T content) throws Exception { 49 | return json.asBytes(content); 50 | } 51 | 52 | @Override 53 | public final void serializeItems(T[] items, OutputStream out) throws IOException 54 | { 55 | JsonGenerator g = json.getStreamingFactory().createGenerator(out); 56 | // JSON allows simple sequences, so: 57 | for (int i = 0, len = items.length; i < len; ++i) { 58 | json.write(items[i], g); 59 | } 60 | g.close(); 61 | } 62 | 63 | @Override 64 | public T[] deserializeItems(InputStream in, int numberOfItems) throws IOException 65 | { 66 | @SuppressWarnings("unchecked") 67 | T[] result = (T[]) Array.newInstance(type, numberOfItems); 68 | JsonParser p = json.getStreamingFactory().createParser(in); 69 | for (int i = 0; i < numberOfItems; ++i) { 70 | result[i] = json.beanFrom(type, p); 71 | } 72 | p.close(); 73 | return result; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/JacksonJsonDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import data.media.MediaContent; 4 | import serializers.*; 5 | 6 | import com.fasterxml.jackson.databind.*; 7 | 8 | /** 9 | * This serializer uses Jackson in full automated data binding mode, which 10 | * can handle typical Java POJOs (esp. beans; otherwise may need to annotate 11 | * to configure) 12 | */ 13 | public class JacksonJsonDatabind 14 | { 15 | public static void register(TestGroups groups) 16 | { 17 | ObjectMapper mapper = new ObjectMapper(); 18 | // note: could also force static typing; left out to keep defaults 19 | groups.media.add(JavaBuiltIn.mediaTransformer, 20 | new StdJacksonDataBind("json/jackson/databind", MediaContent.class, mapper), 21 | new SerFeatures( 22 | SerFormat.JSON, 23 | SerGraph.FLAT_TREE, 24 | SerClass.ZERO_KNOWLEDGE, 25 | "" 26 | ) 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/JacksonProtobufDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import java.io.*; 4 | 5 | import com.fasterxml.jackson.databind.JavaType; 6 | import com.fasterxml.jackson.databind.SerializationFeature; 7 | import com.fasterxml.jackson.dataformat.protobuf.*; 8 | import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; 9 | import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; 10 | import com.fasterxml.jackson.module.afterburner.AfterburnerModule; 11 | 12 | import serializers.*; 13 | import data.media.MediaContent; 14 | 15 | public class JacksonProtobufDatabind 16 | { 17 | public static void register(TestGroups groups) { 18 | ProtobufMapper mapper = new ProtobufMapper(); 19 | ProtobufSchema schema; 20 | try { 21 | schema = new ProtobufSchemaLoader().load(new File("schema/media.proto.jackson"), 22 | "MediaContent"); 23 | //"schema/media.proto")); 24 | } catch (IOException e) { 25 | throw new RuntimeException(e); 26 | } 27 | // not sure if using (or not) of index actually makes much diff but: 28 | mapper.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX); 29 | final JavaType type = mapper.constructType(MediaContent.class); 30 | 31 | groups.media.add(JavaBuiltIn.mediaTransformer, 32 | new StdJacksonDataBind("protobuf/jackson/databind", type, mapper, 33 | mapper.readerFor(MediaContent.class).with(schema), 34 | mapper.writerFor(MediaContent.class).with(schema)), 35 | new SerFeatures( 36 | SerFormat.BINARY, 37 | SerGraph.FLAT_TREE, 38 | SerClass.CLASSES_KNOWN, 39 | "" 40 | ) 41 | ); 42 | 43 | mapper = new ProtobufMapper(); 44 | mapper.registerModule(new AfterburnerModule()); 45 | mapper.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX); 46 | 47 | groups.media.add(JavaBuiltIn.mediaTransformer, 48 | new StdJacksonDataBind("protobuf/jackson+afterburner/databind", type, mapper, 49 | mapper.readerFor(MediaContent.class).with(schema), 50 | mapper.writerFor(MediaContent.class).with(schema)), 51 | new SerFeatures( 52 | SerFormat.BINARY, 53 | SerGraph.FLAT_TREE, 54 | SerClass.CLASSES_KNOWN, 55 | "" 56 | ) 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/JacksonSmileDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.fasterxml.jackson.databind.SerializationFeature; 5 | 6 | import com.fasterxml.jackson.dataformat.smile.*; 7 | 8 | import serializers.*; 9 | 10 | import data.media.MediaContent; 11 | 12 | public class JacksonSmileDatabind 13 | { 14 | public static void register(TestGroups groups) { // Jackson Smile defaults: share names, not values 15 | register(groups, true, false); 16 | } 17 | 18 | public static void register(TestGroups groups, boolean sharedNames, boolean sharedValues) 19 | { 20 | SmileFactory factory = new SmileFactory(); 21 | factory.configure(SmileGenerator.Feature.CHECK_SHARED_NAMES, sharedNames); 22 | factory.configure(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES, sharedValues); 23 | // no point in using enum names with binary format, so: 24 | ObjectMapper mapper = new ObjectMapper(factory); 25 | mapper.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX); 26 | 27 | groups.media.add(JavaBuiltIn.mediaTransformer, 28 | new StdJacksonDataBind("smile/jackson/databind", 29 | MediaContent.class, mapper), 30 | new SerFeatures( 31 | SerFormat.BINARY, 32 | SerGraph.FLAT_TREE, 33 | SerClass.ZERO_KNOWLEDGE, 34 | "" 35 | ) 36 | ); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/JacksonSmileManual.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import com.fasterxml.jackson.dataformat.smile.*; 4 | 5 | import serializers.*; 6 | 7 | public class JacksonSmileManual 8 | { 9 | public static void register(TestGroups groups) { // Jackson Smile defaults: share names, not values 10 | register(groups, true, false); 11 | } 12 | 13 | public static void register(TestGroups groups, boolean sharedNames, boolean sharedValues) 14 | { 15 | SmileFactory factory = new SmileFactory(); 16 | factory.configure(SmileGenerator.Feature.CHECK_SHARED_NAMES, sharedNames); 17 | factory.configure(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES, sharedValues); 18 | groups.media.add(JavaBuiltIn.mediaTransformer, new JacksonJsonManual("smile/jackson/manual", factory), 19 | new SerFeatures( 20 | SerFormat.BINARY, 21 | SerGraph.FLAT_TREE, 22 | SerClass.MANUAL_OPT, 23 | "" 24 | ) 25 | ); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/JacksonWithAfterburner.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import serializers.JavaBuiltIn; 4 | import serializers.SerClass; 5 | import serializers.SerFeatures; 6 | import serializers.SerFormat; 7 | import serializers.SerGraph; 8 | import serializers.TestGroups; 9 | 10 | import com.fasterxml.jackson.core.JsonFactory; 11 | import com.fasterxml.jackson.databind.ObjectMapper; 12 | import com.fasterxml.jackson.dataformat.cbor.CBORFactory; 13 | import com.fasterxml.jackson.dataformat.smile.SmileFactory; 14 | import com.fasterxml.jackson.dataformat.smile.SmileGenerator; 15 | import com.fasterxml.jackson.module.afterburner.AfterburnerModule; 16 | 17 | import data.media.MediaContent; 18 | 19 | /** 20 | * Class for registering variants of Jackson-based tests that use Afterburner 21 | * for generating byte code to avoid use of Reflection for calling methods 22 | * and constructing objects. 23 | */ 24 | public class JacksonWithAfterburner 25 | { 26 | final static String STD_DESC = "uses bytecode generation to reduce overhead"; 27 | 28 | public static void registerAll(TestGroups groups) 29 | { 30 | registerJSON(groups); 31 | registerSmile(groups); 32 | registerCBOR(groups); 33 | } 34 | 35 | public static void registerJSON(TestGroups groups) 36 | { 37 | ObjectMapper mapper = new ObjectMapper(new JsonFactory()); 38 | mapper.registerModule(new AfterburnerModule()); 39 | groups.media.add(JavaBuiltIn.mediaTransformer, 40 | new StdJacksonDataBind("json/jackson+afterburner/databind", MediaContent.class, mapper), 41 | new SerFeatures(SerFormat.BINARY, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, STD_DESC)); 42 | } 43 | 44 | public static void registerCBOR(TestGroups groups) 45 | { 46 | ObjectMapper mapper = new ObjectMapper(new CBORFactory()); 47 | mapper.registerModule(new AfterburnerModule()); 48 | groups.media.add(JavaBuiltIn.mediaTransformer, 49 | new StdJacksonDataBind("cbor/jackson+afterburner/databind", MediaContent.class, mapper), 50 | new SerFeatures(SerFormat.BINARY, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, STD_DESC)); 51 | } 52 | 53 | public static void registerSmile(TestGroups groups) { 54 | // use defaults: shared names, not values (but set explicitly just in case) 55 | // sharing can reduce size, but also adds some processing overhead -- typically name sharing 56 | // cheap, value sharing bit more expensive; hence the defaults 57 | registerSmile(groups, true, false); 58 | } 59 | 60 | public static void registerSmile(TestGroups groups, boolean shareNames, boolean shareValues) 61 | { 62 | SmileFactory f = new SmileFactory(); 63 | f.configure(SmileGenerator.Feature.CHECK_SHARED_NAMES, shareNames); 64 | f.configure(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES, shareValues); 65 | ObjectMapper smileMapper = new ObjectMapper(f); 66 | 67 | smileMapper.registerModule(new AfterburnerModule()); 68 | groups.media.add(JavaBuiltIn.mediaTransformer, 69 | new StdJacksonDataBind("smile/jackson+afterburner/databind", MediaContent.class, smileMapper), 70 | new SerFeatures(SerFormat.BINARY, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, STD_DESC)); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/JacksonWithColumnsDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import serializers.*; 4 | 5 | import com.fasterxml.jackson.databind.*; 6 | 7 | import data.media.MediaContent; 8 | 9 | /** 10 | * Codec(s) for serializing logical JSON content as JSON Array instead 11 | * of the usual JSON Object; this condenses data size significantly and 12 | * typically improves performance similarly. 13 | */ 14 | public class JacksonWithColumnsDatabind 15 | { 16 | private final static String STD_DESC = "uses positional (column) layout to eliminate use of names"; 17 | 18 | public static void registerAll(TestGroups groups) 19 | { 20 | registerJSON(groups); 21 | registerSmile(groups); 22 | registerCBOR(groups); 23 | } 24 | 25 | public static void registerCBOR(TestGroups groups) 26 | { 27 | ObjectMapper cborMapper = new ObjectMapper(new com.fasterxml.jackson.dataformat.cbor.CBORFactory()); 28 | cborMapper.setAnnotationIntrospector(new AsArrayIntrospector()); 29 | groups.media.add(JavaBuiltIn.mediaTransformer, 30 | new StdJacksonDataBind("cbor-col/jackson/databind", MediaContent.class, cborMapper), 31 | new SerFeatures(SerFormat.JSON,SerGraph.FLAT_TREE,SerClass.ZERO_KNOWLEDGE,STD_DESC)); 32 | } 33 | 34 | public static void registerJSON(TestGroups groups) 35 | { 36 | ObjectMapper jsonMapper = new ObjectMapper(); 37 | jsonMapper.setAnnotationIntrospector(new AsArrayIntrospector()); 38 | groups.media.add(JavaBuiltIn.mediaTransformer, 39 | new StdJacksonDataBind("json-col/jackson/databind", MediaContent.class, jsonMapper), 40 | new SerFeatures(SerFormat.JSON,SerGraph.FLAT_TREE,SerClass.ZERO_KNOWLEDGE,STD_DESC)); 41 | } 42 | 43 | public static void registerSmile(TestGroups groups) 44 | { 45 | ObjectMapper smileMapper = new ObjectMapper(new com.fasterxml.jackson.dataformat.smile.SmileFactory()); 46 | smileMapper.setAnnotationIntrospector(new AsArrayIntrospector()); 47 | groups.media.add(JavaBuiltIn.mediaTransformer, 48 | new StdJacksonDataBind("smile-col/jackson/databind", MediaContent.class, smileMapper), 49 | new SerFeatures(SerFormat.JSON,SerGraph.FLAT_TREE,SerClass.ZERO_KNOWLEDGE,STD_DESC)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/JacksonXmlDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import serializers.*; 4 | 5 | import com.fasterxml.aalto.stax.InputFactoryImpl; 6 | import com.fasterxml.aalto.stax.OutputFactoryImpl; 7 | 8 | import com.fasterxml.jackson.dataformat.xml.*; 9 | 10 | import data.media.MediaContent; 11 | 12 | /** 13 | * Test for handling XML using "jackson-xml-databind" codec 14 | * (https://github.com/FasterXML/jackson-xml-databind) 15 | * with Aalto Stax XML parser. 16 | */ 17 | public class JacksonXmlDatabind 18 | { 19 | public static void register(TestGroups groups) 20 | { 21 | XmlMapper mapper = new XmlMapper(new XmlFactory( 22 | new InputFactoryImpl(), new OutputFactoryImpl())); 23 | groups.media.add(JavaBuiltIn.mediaTransformer, 24 | new StdJacksonDataBind("xml/jackson/databind", 25 | MediaContent.class, mapper), 26 | new SerFeatures( 27 | SerFormat.XML, 28 | SerGraph.FLAT_TREE, 29 | SerClass.ZERO_KNOWLEDGE, 30 | "" 31 | ) 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tpc/src/serializers/jackson/StdJacksonDataBind.java: -------------------------------------------------------------------------------- 1 | package serializers.jackson; 2 | 3 | import java.io.*; 4 | 5 | import com.fasterxml.jackson.core.JsonGenerator; 6 | import com.fasterxml.jackson.core.JsonParser; 7 | 8 | import com.fasterxml.jackson.databind.JavaType; 9 | import com.fasterxml.jackson.databind.ObjectMapper; 10 | import com.fasterxml.jackson.databind.ObjectReader; 11 | import com.fasterxml.jackson.databind.ObjectWriter; 12 | 13 | public final class StdJacksonDataBind extends BaseJacksonDataBind 14 | { 15 | public StdJacksonDataBind(String name, Class clazz, ObjectMapper mapper) { 16 | super(name, clazz, mapper); 17 | } 18 | 19 | public StdJacksonDataBind(String name, JavaType type, 20 | ObjectMapper mapper, ObjectReader reader, ObjectWriter writer) 21 | { 22 | super(name, type, mapper, reader, writer); 23 | } 24 | 25 | @Override 26 | public byte[] serialize(T data) throws IOException 27 | { 28 | return writer.writeValueAsBytes(data); 29 | } 30 | 31 | @Override 32 | @SuppressWarnings("unchecked") 33 | public T deserialize(byte[] array) throws IOException 34 | { 35 | return (T) reader.readValue(array, 0, array.length); 36 | } 37 | 38 | // // Future extensions for testing performance for item sequences 39 | 40 | @Override 41 | public void serializeItems(T[] items, OutputStream out) throws IOException 42 | { 43 | JsonGenerator generator = constructGenerator(out); 44 | // JSON allows simple sequences, so: 45 | for (int i = 0, len = items.length; i < len; ++i) { 46 | writer.writeValue(generator, items[i]); 47 | } 48 | generator.close(); 49 | } 50 | 51 | @Override 52 | @SuppressWarnings("unchecked") 53 | public T[] deserializeItems(InputStream in, int numberOfItems) throws IOException 54 | { 55 | T[] result = (T[]) new Object[numberOfItems]; 56 | JsonParser parser = constructParser(in); 57 | for (int i = 0; i < numberOfItems; ++i) { 58 | result[i] = (T) reader.readValue(parser, type); 59 | } 60 | parser.close(); 61 | return result; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /tpc/src/serializers/java/Image.java: -------------------------------------------------------------------------------- 1 | package serializers.java; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.twolattes.json.Entity; 6 | import com.twolattes.json.Value; 7 | 8 | import data.media.FieldMapping; 9 | 10 | @Entity 11 | public class Image implements Serializable 12 | { 13 | private static final long serialVersionUID = 1L; 14 | 15 | public enum Size 16 | { 17 | SMALL, LARGE 18 | } 19 | 20 | private @Value(name=FieldMapping.FULL_FIELD_NAME_URI) String _uri; 21 | private @Value(name=FieldMapping.FULL_FIELD_NAME_TITLE) String _title; 22 | private @Value(name=FieldMapping.FULL_FIELD_NAME_WIDTH) int _width; 23 | private @Value(name=FieldMapping.FULL_FIELD_NAME_HEIGHT) int _height; 24 | private @Value(name=FieldMapping.FULL_FIELD_NAME_SIZE, ordinal = true) Size _size; 25 | 26 | public Image(){} 27 | 28 | public Image (int height, String title, String uri, int width, Size size) 29 | { 30 | super(); 31 | _height = height; 32 | _title = title; 33 | _uri = uri; 34 | _width = width; 35 | _size = size; 36 | } 37 | 38 | public String getUri () 39 | { 40 | return _uri; 41 | } 42 | 43 | public void setUri (String uri) 44 | { 45 | _uri = uri; 46 | } 47 | 48 | public String getTitle () 49 | { 50 | return _title; 51 | } 52 | 53 | public void setTitle (String title) 54 | { 55 | _title = title; 56 | } 57 | 58 | public int getWidth () 59 | { 60 | return _width; 61 | } 62 | 63 | public void setWidth (int width) 64 | { 65 | _width = width; 66 | } 67 | 68 | public int getHeight () 69 | { 70 | return _height; 71 | } 72 | 73 | public void setHeight (int height) 74 | { 75 | _height = height; 76 | } 77 | 78 | public Size getSize () 79 | { 80 | return _size; 81 | } 82 | 83 | public void setSize (Size size) 84 | { 85 | this._size = size; 86 | } 87 | 88 | public int hashCode() { 89 | final int prime = 31; 90 | int result = 1; 91 | result = prime * result + _height; 92 | result = prime * result + ((_size == null) ? 0 : _size.hashCode()); 93 | result = prime * result + ((_title == null) ? 0 : _title.hashCode()); 94 | result = prime * result + ((_uri == null) ? 0 : _uri.hashCode()); 95 | result = prime * result + _width; 96 | return result; 97 | } 98 | 99 | public boolean equals( Object obj ) { 100 | if ( this == obj ) return true; 101 | if ( obj == null ) return false; 102 | if ( getClass() != obj.getClass() ) return false; 103 | Image other = (Image)obj; 104 | if ( _height != other._height ) return false; 105 | if ( _size == null ) { 106 | if ( other._size != null ) return false; 107 | } else if ( !_size.equals(other._size) ) return false; 108 | if ( _title == null ) { 109 | if ( other._title != null ) return false; 110 | } else if ( !_title.equals(other._title) ) return false; 111 | if ( _uri == null ) { 112 | if ( other._uri != null ) return false; 113 | } else if ( !_uri.equals(other._uri) ) return false; 114 | if ( _width != other._width ) return false; 115 | return true; 116 | } 117 | 118 | @Override 119 | public String toString() 120 | { 121 | StringBuilder sb = new StringBuilder(); 122 | sb.append("[Image "); 123 | sb.append("width=").append(_width); 124 | sb.append(", height=").append(_height); 125 | sb.append(", uri=").append(_uri); 126 | sb.append(", title=").append(_title); 127 | sb.append(", size=").append(_size); 128 | sb.append("]"); 129 | return sb.toString(); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /tpc/src/serializers/java/MediaContent.java: -------------------------------------------------------------------------------- 1 | package serializers.java; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import com.twolattes.json.Entity; 8 | import com.twolattes.json.Value; 9 | 10 | import data.media.FieldMapping; 11 | 12 | @Entity 13 | public class MediaContent implements Serializable 14 | { 15 | private static final long serialVersionUID = 1L; 16 | 17 | private @Value(name = FieldMapping.FULL_FIELD_NAME_IMAGES) List _images; 18 | private @Value(name = FieldMapping.FULL_FIELD_NAME_MEDIA) Media _media; 19 | 20 | public MediaContent() { } 21 | 22 | public MediaContent (Media media) 23 | { 24 | _media = media; 25 | } 26 | 27 | public List getImages() { return _images; } 28 | public void setImages(List i) { _images = i; } 29 | 30 | public void addImage (Image image) 31 | { 32 | if(_images == null) 33 | { 34 | _images = new ArrayList(); 35 | } 36 | _images.add(image); 37 | } 38 | 39 | public int imageCount() { return _images.size(); } 40 | 41 | public Image getImage (int i) 42 | { 43 | return _images.get(i); 44 | } 45 | 46 | public Media getMedia () 47 | { 48 | return _media; 49 | } 50 | 51 | public void setMedia(Media m) { _media = m; } 52 | 53 | public int hashCode() { 54 | final int prime = 31; 55 | int result = 1; 56 | result = prime * result + ((_images == null) ? 0 : _images.hashCode()); 57 | result = prime * result + ((_media == null) ? 0 : _media.hashCode()); 58 | return result; 59 | } 60 | 61 | public boolean equals( Object obj ) { 62 | if ( this == obj ) return true; 63 | if ( obj == null ) return false; 64 | if ( getClass() != obj.getClass() ) return false; 65 | MediaContent other = (MediaContent)obj; 66 | if ( _images == null ) { 67 | if ( other._images != null ) return false; 68 | } else if ( !_images.equals(other._images) ) return false; 69 | if ( _media == null ) { 70 | if ( other._media != null ) return false; 71 | } else if ( !_media.equals(other._media) ) return false; 72 | return true; 73 | } 74 | 75 | @Override 76 | public String toString() 77 | { 78 | StringBuilder sb = new StringBuilder(); 79 | sb.append("[MediaContent: "); 80 | sb.append("media=").append(_media); 81 | sb.append(", images=").append(_images); 82 | sb.append("]"); 83 | return sb.toString(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /tpc/src/serializers/javaxjson/JavaxJsonStreamGlassfish.java: -------------------------------------------------------------------------------- 1 | package serializers.javaxjson; 2 | 3 | import org.glassfish.json.*; 4 | 5 | import serializers.*; 6 | 7 | public class JavaxJsonStreamGlassfish extends JavaxJsonStream { 8 | private static final JsonProviderImpl JSON = new JsonProviderImpl(); 9 | 10 | public JavaxJsonStreamGlassfish() { 11 | super(JSON); 12 | } 13 | 14 | @Override 15 | public String getName() { 16 | return "json/javax-stream/glassfish"; 17 | } 18 | 19 | public static void register(TestGroups groups) { 20 | groups.media.add(JavaBuiltIn.mediaTransformer, new JavaxJsonStreamGlassfish(), 21 | new SerFeatures( 22 | SerFormat.JSON, 23 | SerGraph.FLAT_TREE, 24 | SerClass.MANUAL_OPT, 25 | "" 26 | ) 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tpc/src/serializers/javaxjson/JavaxJsonTree.java: -------------------------------------------------------------------------------- 1 | package serializers.javaxjson; 2 | 3 | import java.io.*; 4 | 5 | import javax.json.*; 6 | import javax.json.spi.*; 7 | 8 | import serializers.*; 9 | 10 | /** 11 | * Base class for javax.json benchmark using the tree model intermediate 12 | */ 13 | public abstract class JavaxJsonTree extends Serializer { 14 | private final JsonProvider json; 15 | 16 | public JavaxJsonTree(JsonProvider json) { 17 | this.json = json; 18 | } 19 | 20 | @Override 21 | public JsonStructure deserialize(byte[] array) throws Exception { 22 | return json.createReader(new ByteArrayInputStream(array)).read(); 23 | } 24 | 25 | @Override 26 | public byte[] serialize(JsonStructure content) throws Exception { 27 | ByteArrayOutputStream outputStream = outputStream(content); 28 | JsonWriter writer = json.createWriter(outputStream); 29 | writer.write(content); 30 | writer.close(); 31 | return outputStream.toByteArray(); 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /tpc/src/serializers/javaxjson/JavaxJsonTreeGlassfish.java: -------------------------------------------------------------------------------- 1 | package serializers.javaxjson; 2 | 3 | import org.glassfish.json.*; 4 | 5 | import serializers.*; 6 | 7 | public class JavaxJsonTreeGlassfish extends JavaxJsonTree { 8 | private static final JsonProviderImpl JSON = new JsonProviderImpl(); 9 | 10 | public JavaxJsonTreeGlassfish() { 11 | super(JSON); 12 | } 13 | 14 | @Override 15 | public String getName() { 16 | return "json/javax-tree/glassfish"; 17 | } 18 | 19 | public static void register(TestGroups groups) { 20 | groups.media.add(new JavaxJsonTransformer(JSON), new JavaxJsonTreeGlassfish(), 21 | new SerFeatures( 22 | SerFormat.JSON, 23 | SerGraph.FLAT_TREE, 24 | SerClass.ZERO_KNOWLEDGE, 25 | "" 26 | ) 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tpc/src/serializers/json/FastJSONArrayDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.json; 2 | 3 | import java.io.*; 4 | 5 | import serializers.*; 6 | 7 | import data.media.MediaContent; 8 | 9 | import com.alibaba.fastjson.JSON; 10 | import com.alibaba.fastjson.serializer.SerializerFeature; 11 | import com.alibaba.fastjson.parser.Feature; 12 | import com.alibaba.fastjson.serializer.JSONSerializer; 13 | import com.alibaba.fastjson.serializer.SerializeConfig; 14 | import com.alibaba.fastjson.serializer.SerializeWriter; 15 | import com.alibaba.fastjson.serializer.SerializeFilter; 16 | 17 | /** 18 | * This serializer uses FastJSON [https://github.com/alibaba/fastjson] for JSON data binding. 19 | */ 20 | public class FastJSONArrayDatabind 21 | { 22 | public static void register(TestGroups groups) 23 | { 24 | groups.media.add(JavaBuiltIn.mediaTransformer, 25 | new GenericSerializer("json-array/fastjson/databind", MediaContent.class), 26 | new SerFeatures( 27 | SerFormat.JSON, 28 | SerGraph.FLAT_TREE, 29 | SerClass.ZERO_KNOWLEDGE, 30 | "" 31 | ) 32 | ); 33 | } 34 | 35 | static class GenericSerializer extends Serializer 36 | { 37 | private final String name; 38 | private final Class type; 39 | 40 | private int serializerFeatures; 41 | 42 | public GenericSerializer(String name, Class clazz) 43 | { 44 | this.name = name; 45 | type = clazz; 46 | 47 | serializerFeatures |= SerializerFeature.QuoteFieldNames.getMask(); 48 | serializerFeatures |= SerializerFeature.SkipTransientField.getMask(); 49 | serializerFeatures |= SerializerFeature.SortField.getMask(); 50 | serializerFeatures |= SerializerFeature.DisableCircularReferenceDetect.getMask(); 51 | serializerFeatures |= SerializerFeature.BeanToArray.getMask(); 52 | } 53 | 54 | @Override 55 | public String getName() 56 | { 57 | return name; 58 | } 59 | 60 | public void serializeItems(T[] items, OutputStream out) throws IOException 61 | { 62 | for (int i = 0, len = items.length; i < len; ++i) { 63 | JSON.writeJSONString(out, 64 | items[i], 65 | serializerFeatures); 66 | } 67 | } 68 | 69 | 70 | @SuppressWarnings("unchecked") 71 | @Override 72 | public T deserialize(byte[] array) throws Exception 73 | { 74 | // fastjson can parse from byte array, yay: 75 | return (T) JSON.parseObject(array, type, Feature.SupportArrayToBean, Feature.DisableCircularReferenceDetect); 76 | } 77 | 78 | @Override 79 | public byte[] serialize(T data) throws IOException 80 | { 81 | return JSON.toJSONBytes(data, serializerFeatures); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /tpc/src/serializers/json/FastJSONDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.json; 2 | 3 | import java.io.*; 4 | 5 | import serializers.*; 6 | 7 | import data.media.MediaContent; 8 | 9 | import com.alibaba.fastjson.JSON; 10 | import com.alibaba.fastjson.serializer.SerializerFeature; 11 | import com.alibaba.fastjson.parser.Feature; 12 | import com.alibaba.fastjson.serializer.JSONSerializer; 13 | import com.alibaba.fastjson.serializer.SerializeWriter; 14 | 15 | /** 16 | * This serializer uses FastJSON [https://github.com/alibaba/fastjson] for JSON data binding. 17 | */ 18 | public class FastJSONDatabind 19 | { 20 | public static void register(TestGroups groups) 21 | { 22 | groups.media.add(JavaBuiltIn.mediaTransformer, 23 | new GenericSerializer("json/fastjson/databind", MediaContent.class), 24 | new SerFeatures( 25 | SerFormat.JSON, 26 | SerGraph.FLAT_TREE, 27 | SerClass.ZERO_KNOWLEDGE, 28 | "" 29 | ) 30 | ); 31 | } 32 | 33 | static class GenericSerializer extends Serializer 34 | { 35 | private final String name; 36 | private final Class type; 37 | 38 | public GenericSerializer(String name, Class clazz) 39 | { 40 | this.name = name; 41 | type = clazz; 42 | } 43 | 44 | @Override 45 | public String getName() 46 | { 47 | return name; 48 | } 49 | 50 | public void serializeItems(T[] items, OutputStream out) throws IOException 51 | { 52 | for (int i = 0, len = items.length; i < len; ++i) { 53 | JSON.writeJSONString(out, items[i], SerializerFeature.WriteEnumUsingToString, 54 | SerializerFeature.DisableCircularReferenceDetect); 55 | } 56 | } 57 | 58 | @SuppressWarnings("unchecked") 59 | @Override 60 | public T deserialize(byte[] array) throws Exception 61 | { 62 | // fastjson can parse from byte array, yay: 63 | return (T) JSON.parseObject(array, type, Feature.DisableCircularReferenceDetect); 64 | } 65 | 66 | @Override 67 | public byte[] serialize(T data) throws IOException 68 | { 69 | return JSON.toJSONBytes(data, SerializerFeature.WriteEnumUsingToString,SerializerFeature.DisableCircularReferenceDetect); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /tpc/src/serializers/json/FlexjsonDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.json; 2 | 3 | import java.io.*; 4 | 5 | import serializers.*; 6 | 7 | import data.media.MediaContent; 8 | import flexjson.JSONDeserializer; 9 | import flexjson.JSONSerializer; 10 | 11 | /** 12 | * This serializer uses Flexjson for data binding. 13 | * http://flexjson.sourceforge.net 14 | */ 15 | public class FlexjsonDatabind 16 | { 17 | public static void register(TestGroups groups) 18 | { 19 | groups.media.add(JavaBuiltIn.mediaTransformer, 20 | new GenericSerializer("json/flexjson/databind", MediaContent.class), 21 | new SerFeatures( 22 | SerFormat.JSON, 23 | SerGraph.FULL_GRAPH, 24 | SerClass.ZERO_KNOWLEDGE, 25 | "" 26 | ) 27 | ); 28 | } 29 | 30 | static class GenericSerializer extends Serializer 31 | { 32 | private final String name; 33 | private final Class type; 34 | 35 | public GenericSerializer(String name, Class clazz) 36 | { 37 | this.name = name; 38 | type = clazz; 39 | } 40 | 41 | public String getName() 42 | { 43 | return name; 44 | } 45 | 46 | public T deserialize(byte[] array) throws Exception 47 | { 48 | return new JSONDeserializer().deserialize(new String(array, "UTF-8"), type); 49 | } 50 | 51 | public byte[] serialize(T data) throws IOException 52 | { 53 | String jsonString = new JSONSerializer().exclude("*.class").deepSerialize(data); 54 | return jsonString.getBytes("UTF-8"); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tpc/src/serializers/json/JsonGsonDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.json; 2 | 3 | import java.io.*; 4 | 5 | import serializers.*; 6 | 7 | import data.media.MediaContent; 8 | 9 | /** 10 | * This serializer uses Google-gson for data binding. 11 | * to configure) 12 | */ 13 | public class JsonGsonDatabind 14 | { 15 | public static void register(TestGroups groups) 16 | { 17 | groups.media.add(JavaBuiltIn.mediaTransformer, 18 | new GenericSerializer("json/gson/databind", MediaContent.class), 19 | new SerFeatures( 20 | SerFormat.JSON, 21 | SerGraph.FLAT_TREE, 22 | SerClass.ZERO_KNOWLEDGE, 23 | "" 24 | ) 25 | ); 26 | } 27 | 28 | // ------------------------------------------------------------ 29 | // Serializer (just one) 30 | 31 | static class GenericSerializer extends Serializer 32 | { 33 | private final com.google.gson.Gson _gson = new com.google.gson.Gson(); 34 | private final String name; 35 | private final Class type; 36 | 37 | public GenericSerializer(String name, Class clazz) 38 | { 39 | this.name = name; 40 | type = clazz; 41 | } 42 | 43 | public String getName() { return name; } 44 | 45 | public T deserialize(byte[] array) throws Exception 46 | { 47 | T result = _gson.fromJson(new String(array, "UTF-8"), type); 48 | return result; 49 | } 50 | 51 | public byte[] serialize(T data) throws IOException 52 | { 53 | StringWriter w = new StringWriter(); 54 | _gson.toJson(data, w); 55 | w.flush(); 56 | return w.toString().getBytes("UTF-8"); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /tpc/src/serializers/json/JsonSvensonDatabind.java: -------------------------------------------------------------------------------- 1 | package serializers.json; 2 | 3 | import java.io.*; 4 | 5 | import serializers.*; 6 | 7 | import data.media.Image; 8 | import data.media.MediaContent; 9 | 10 | /** 11 | * This serializer uses svenson for JSON data binding. 12 | */ 13 | public class JsonSvensonDatabind 14 | { 15 | public static void register(TestGroups groups) 16 | { 17 | groups.media.add(JavaBuiltIn.mediaTransformer, 18 | new GenericSerializer("json/svenson/databind", MediaContent.class), 19 | new SerFeatures( 20 | SerFormat.JSON, 21 | SerGraph.FLAT_TREE, 22 | SerClass.MANUAL_OPT, 23 | "" 24 | ) 25 | ); 26 | } 27 | 28 | static class GenericSerializer extends Serializer 29 | { 30 | private final org.svenson.JSONParser _jsonParser; 31 | private final org.svenson.JSON _jsonWriter; 32 | private final String name; 33 | private final Class type; 34 | 35 | public GenericSerializer(String name, Class clazz) 36 | { 37 | this.name = name; 38 | type = clazz; 39 | 40 | _jsonParser = org.svenson.JSONParser.defaultJSONParser(); 41 | _jsonParser.addTypeHint(".images[]", Image.class); 42 | _jsonWriter = org.svenson.JSON.defaultJSON(); 43 | } 44 | 45 | @Override 46 | public String getName() 47 | { 48 | return name; 49 | } 50 | 51 | @Override 52 | public T deserialize(byte[] array) throws Exception 53 | { 54 | return _jsonParser.parse(type, new String(array, "UTF-8")); 55 | } 56 | 57 | @Override 58 | public byte[] serialize(T data) throws IOException 59 | { 60 | String result = _jsonWriter.forValue(data); 61 | return result.getBytes(); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /tpc/src/serializers/json/JsonTwoLattes.java: -------------------------------------------------------------------------------- 1 | package serializers.json; 2 | 3 | import java.io.*; 4 | import java.nio.charset.Charset; 5 | 6 | import serializers.Serializer; 7 | import serializers.TestGroups; 8 | 9 | import com.twolattes.json.Json; 10 | import com.twolattes.json.Marshaller; 11 | import com.twolattes.json.TwoLattes; 12 | 13 | public class JsonTwoLattes 14 | { 15 | public static void register(TestGroups groups) 16 | { 17 | // TODO: Need classes with @Entity and @Value annotations. 18 | //groups.media.add(JavaBuiltIn.MediaTransformer, new GenericSerializer(MediaContent.class)); 19 | } 20 | 21 | // ------------------------------------------------------------ 22 | // Serializer (just one class) 23 | 24 | public static final class GenericSerializer extends Serializer 25 | { 26 | public String getName() { return "json/twolattes/databind"; } 27 | 28 | private final Marshaller _marshaller; 29 | private final Charset _charset = Charset.forName("UTF-8"); 30 | 31 | public GenericSerializer(Class clazz) 32 | { 33 | _marshaller = TwoLattes.createMarshaller(clazz); 34 | } 35 | 36 | 37 | public T deserialize(byte[] array) throws Exception { 38 | String str = new String(array, _charset.toString()); 39 | return _marshaller.unmarshall((Json.Object) Json.read( 40 | new StringReader(str))); 41 | } 42 | 43 | public byte[] serialize(T content) throws Exception { 44 | StringWriter sw = new StringWriter(); 45 | _marshaller.marshall(content).write(sw); 46 | sw.flush(); 47 | return sw.toString().getBytes(_charset.toString()); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /tpc/src/serializers/msgpack/ImageSizeTemplate.java: -------------------------------------------------------------------------------- 1 | package serializers.msgpack; 2 | 3 | import org.msgpack.template.OrdinalEnumTemplate; 4 | import org.msgpack.template.Template; 5 | 6 | import data.media.Image; 7 | import data.media.Image.Size; 8 | 9 | final class ImageSizeTemplate extends OrdinalEnumTemplate { 10 | static final Template INSTANCE = new ImageSizeTemplate(Image.Size.class); 11 | 12 | public ImageSizeTemplate(Class targetClass) { 13 | super(targetClass); 14 | } 15 | } -------------------------------------------------------------------------------- /tpc/src/serializers/msgpack/ImageTemplate.java: -------------------------------------------------------------------------------- 1 | package serializers.msgpack; 2 | 3 | import java.io.IOException; 4 | 5 | import org.msgpack.packer.Packer; 6 | import org.msgpack.template.AbstractTemplate; 7 | import org.msgpack.template.NotNullableTemplate; 8 | import org.msgpack.template.Template; 9 | import org.msgpack.template.Templates; 10 | import org.msgpack.unpacker.Unpacker; 11 | 12 | import data.media.Image; 13 | import data.media.Image.Size; 14 | 15 | final class ImageTemplate extends AbstractTemplate { 16 | static final Template INSTANCE = new ImageTemplate(); 17 | static final Template imageSizeTemplate = 18 | new NotNullableTemplate(ImageSizeTemplate.INSTANCE); 19 | 20 | @Override 21 | public void write(Packer packer, Image v, boolean required) throws IOException { 22 | packer.writeArrayBegin(5); 23 | Templates.TString.write(packer, v.uri, true); 24 | Templates.TString.write(packer, v.title, false); 25 | Templates.TInteger.write(packer, v.width, true); 26 | Templates.TInteger.write(packer, v.height, true); 27 | imageSizeTemplate.write(packer, v.size); 28 | packer.writeArrayEnd(); 29 | } 30 | 31 | @Override 32 | public Image read(Unpacker unpacker, Image to, boolean required) throws IOException { 33 | unpacker.readArrayBegin(); 34 | to = new Image( 35 | Templates.TString.read(unpacker, null, true), 36 | Templates.TString.read(unpacker, null, false), 37 | Templates.TInteger.read(unpacker, null, true), 38 | Templates.TInteger.read(unpacker, null, true), 39 | imageSizeTemplate.read(unpacker, null, true) 40 | ); 41 | unpacker.readArrayEnd(); 42 | return to; 43 | } 44 | } -------------------------------------------------------------------------------- /tpc/src/serializers/msgpack/MediaContentTemplate.java: -------------------------------------------------------------------------------- 1 | package serializers.msgpack; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | 6 | import org.msgpack.packer.Packer; 7 | import org.msgpack.template.AbstractTemplate; 8 | import org.msgpack.template.ListTemplate; 9 | import org.msgpack.template.NotNullableTemplate; 10 | import org.msgpack.template.Template; 11 | import org.msgpack.unpacker.Unpacker; 12 | 13 | import data.media.Image; 14 | import data.media.Media; 15 | import data.media.MediaContent; 16 | 17 | final class MediaContentTemplate extends AbstractTemplate { 18 | static final Template INSTANCE = new MediaContentTemplate(); 19 | static final Template mediaTemplate = new NotNullableTemplate(MediaTemplate.INSTANCE); 20 | @SuppressWarnings({ "rawtypes", "unchecked" }) 21 | static final Template> imageListTemplate = 22 | new NotNullableTemplate>(new ListTemplate( 23 | new NotNullableTemplate(ImageTemplate.INSTANCE))); 24 | 25 | @Override 26 | public void write(Packer packer, MediaContent v, boolean required) throws IOException { 27 | packer.writeArrayBegin(2); 28 | mediaTemplate.write(packer, v.media, true); 29 | imageListTemplate.write(packer, v.images, true); 30 | packer.writeArrayEnd(); 31 | } 32 | 33 | @Override 34 | public MediaContent read(Unpacker unpacker, MediaContent to, boolean required) throws IOException { 35 | unpacker.readArrayBegin(); 36 | to = new MediaContent( 37 | mediaTemplate.read(unpacker, null, true), 38 | imageListTemplate.read(unpacker, null, true) 39 | ); 40 | unpacker.readArrayEnd(); 41 | return to; 42 | } 43 | } -------------------------------------------------------------------------------- /tpc/src/serializers/msgpack/MediaContentTypeHandler.java: -------------------------------------------------------------------------------- 1 | package serializers.msgpack; 2 | 3 | import org.msgpack.MessagePack; 4 | import org.msgpack.template.NotNullableTemplate; 5 | import org.msgpack.template.Template; 6 | 7 | import data.media.Image; 8 | import data.media.Media; 9 | import data.media.MediaContent; 10 | 11 | public final class MediaContentTypeHandler extends TypeHandler { 12 | protected MediaContentTypeHandler() { 13 | super(MediaContent.class); 14 | } 15 | 16 | @Override 17 | public void register(MessagePack msgpack) { 18 | msgpack.register(Image.Size.class); 19 | msgpack.register(Image.class); 20 | msgpack.register(Media.Player.class); 21 | msgpack.register(Media.class); 22 | msgpack.register(MediaContent.class); 23 | } 24 | 25 | static final Template mediaContentTemplate = new NotNullableTemplate(MediaContentTemplate.INSTANCE); 26 | 27 | @Override 28 | public void registerManually(MessagePack msgpack) { 29 | msgpack.register(MediaContent.class, mediaContentTemplate); 30 | } 31 | } -------------------------------------------------------------------------------- /tpc/src/serializers/msgpack/MediaPlayerTemplate.java: -------------------------------------------------------------------------------- 1 | package serializers.msgpack; 2 | 3 | import org.msgpack.template.OrdinalEnumTemplate; 4 | //import org.msgpack.template.Template; 5 | 6 | import data.media.Media; 7 | 8 | final class MediaPlayerTemplate extends OrdinalEnumTemplate { 9 | public MediaPlayerTemplate() { 10 | super(Media.Player.class); 11 | } 12 | } -------------------------------------------------------------------------------- /tpc/src/serializers/msgpack/MediaTemplate.java: -------------------------------------------------------------------------------- 1 | package serializers.msgpack; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | 6 | import org.msgpack.packer.Packer; 7 | import org.msgpack.template.*; 8 | import org.msgpack.unpacker.Unpacker; 9 | 10 | import data.media.Media; 11 | 12 | final class MediaTemplate extends AbstractTemplate { 13 | static final Template INSTANCE = new MediaTemplate(); 14 | static final Template mediaPlayerTemplate = 15 | new NotNullableTemplate(new MediaPlayerTemplate()); 16 | @SuppressWarnings({ "rawtypes", "unchecked" }) 17 | static final Template> personsTemplate = 18 | new NotNullableTemplate>(new ListTemplate( 19 | new NotNullableTemplate(StringTemplate.getInstance()))); 20 | 21 | @Override 22 | public void write(Packer packer, Media v, boolean required) throws IOException { 23 | packer.writeArrayBegin(12); 24 | Templates.TString.write(packer, v.uri, true); 25 | Templates.TString.write(packer, v.title, false); 26 | Templates.TInteger.write(packer, v.width, true); 27 | Templates.TInteger.write(packer, v.height, true); 28 | Templates.TString.write(packer, v.format, true); 29 | Templates.TLong.write(packer, v.duration, true); 30 | Templates.TLong.write(packer, v.size, true); 31 | Templates.TInteger.write(packer, v.bitrate, true); 32 | Templates.TBoolean.write(packer, v.hasBitrate, true); 33 | personsTemplate.write(packer, v.persons, true); 34 | mediaPlayerTemplate.write(packer, v.player, true); 35 | Templates.TString.write(packer, v.copyright, false); 36 | packer.writeArrayEnd(); 37 | } 38 | 39 | @Override 40 | public Media read(Unpacker unpacker, Media to, boolean required) throws IOException { 41 | unpacker.readArrayBegin(); 42 | to = new Media( 43 | Templates.TString.read(unpacker, null, true), 44 | Templates.TString.read(unpacker, null, false), 45 | Templates.TInteger.read(unpacker, null, true), 46 | Templates.TInteger.read(unpacker, null, true), 47 | Templates.TString.read(unpacker, null, true), 48 | Templates.TLong.read(unpacker, null, true), 49 | Templates.TLong.read(unpacker, null, true), 50 | Templates.TInteger.read(unpacker, null, true), 51 | Templates.TBoolean.read(unpacker, null, true), 52 | personsTemplate.read(unpacker, null, true), 53 | mediaPlayerTemplate.read(unpacker, null, true), 54 | Templates.TString.read(unpacker, null, false) 55 | ); 56 | unpacker.readArrayEnd(); 57 | return to; 58 | } 59 | } -------------------------------------------------------------------------------- /tpc/src/serializers/msgpack/MsgPack.java: -------------------------------------------------------------------------------- 1 | package serializers.msgpack; 2 | 3 | import org.msgpack.MessagePack; 4 | 5 | import serializers.*; 6 | 7 | public class MsgPack 8 | { 9 | private final static String DESC = 10 | "uses positional (column) layout (instead of Maps std impl uses) to eliminate use of names"; 11 | 12 | public static void register(TestGroups groups) { 13 | register(groups.media, JavaBuiltIn.mediaTransformer); 14 | } 15 | 16 | @SuppressWarnings("unchecked") 17 | private static void register(TestGroup group, Transformer transformer) { 18 | MessagePack msgpack = new MessagePack(); 19 | TypeHandler h = (TypeHandler) new MediaContentTypeHandler(); 20 | h.register(msgpack); 21 | group.add(transformer, new MsgPackSerializer("msgpack/databind", h, msgpack), 22 | new SerFeatures(SerFormat.BIN_CROSSLANG, SerGraph.FLAT_TREE, SerClass.CLASSES_KNOWN, DESC)); 23 | 24 | msgpack = new MessagePack(); 25 | h = (TypeHandler) new MediaContentTypeHandler(); 26 | h.registerManually(msgpack); 27 | 28 | group.add(transformer, new MsgPackSerializer("msgpack/manual", h, msgpack), 29 | new SerFeatures( SerFormat.BIN_CROSSLANG,SerGraph.FLAT_TREE,SerClass.MANUAL_OPT, DESC)); 30 | } 31 | } -------------------------------------------------------------------------------- /tpc/src/serializers/msgpack/MsgPackSerializer.java: -------------------------------------------------------------------------------- 1 | package serializers.msgpack; 2 | 3 | import org.msgpack.MessagePack; 4 | import org.msgpack.packer.BufferPacker; 5 | import org.msgpack.unpacker.BufferUnpacker; 6 | 7 | import serializers.Serializer; 8 | 9 | public class MsgPackSerializer extends Serializer { 10 | protected final String name; 11 | protected final Class type; 12 | private final BufferPacker packer; 13 | private final BufferUnpacker unpacker; 14 | 15 | public MsgPackSerializer(String name, TypeHandler handler, MessagePack msgpack) { 16 | this.name = name; 17 | type = handler.type; 18 | packer = msgpack.createBufferPacker(BUFFER_SIZE); 19 | unpacker = msgpack.createBufferUnpacker(); 20 | } 21 | 22 | @Override 23 | public byte[] serialize(T content) throws Exception { 24 | packer.write(content); 25 | byte[] array = packer.toByteArray(); 26 | packer.clear(); 27 | return array; 28 | } 29 | 30 | @Override 31 | public T deserialize(byte[] array) throws Exception { 32 | unpacker.wrap(array); 33 | return unpacker.read(type); 34 | } 35 | 36 | @Override 37 | public String getName() { 38 | return name; 39 | } 40 | } -------------------------------------------------------------------------------- /tpc/src/serializers/msgpack/TypeHandler.java: -------------------------------------------------------------------------------- 1 | package serializers.msgpack; 2 | 3 | import org.msgpack.MessagePack; 4 | 5 | abstract class TypeHandler { 6 | public final Class type; 7 | 8 | protected TypeHandler(Class type) { 9 | this.type = type; 10 | } 11 | 12 | public abstract void register(final MessagePack msgpack); 13 | 14 | public abstract void registerManually(final MessagePack msgpack); 15 | } -------------------------------------------------------------------------------- /tpc/src/serializers/protobuf/ProtobufJson.java: -------------------------------------------------------------------------------- 1 | package serializers.protobuf; 2 | 3 | import serializers.*; 4 | import serializers.protobuf.media.MediaContentHolder.MediaContent; 5 | 6 | import java.io.IOException; 7 | import java.nio.charset.Charset; 8 | 9 | import com.google.protobuf.JsonFormat; 10 | 11 | public class ProtobufJson 12 | { 13 | public static void register(TestGroups groups) { 14 | groups.media.add(new Protobuf.Transformer(), new JsonSerializer(), 15 | new SerFeatures( 16 | SerFormat.JSON, 17 | SerGraph.FLAT_TREE, 18 | SerClass.CLASSES_KNOWN, 19 | "" 20 | ) 21 | ); 22 | } 23 | 24 | private static final Charset _charset = Charset.forName("UTF-8"); 25 | 26 | static final class JsonSerializer extends Serializer 27 | { 28 | public MediaContent deserialize (byte[] array) throws Exception 29 | { 30 | MediaContent.Builder builder = MediaContent.newBuilder(); 31 | JsonFormat.merge(new String(array, _charset.name()), builder); 32 | return builder.build(); 33 | } 34 | 35 | public byte[] serialize(MediaContent content) throws IOException { 36 | return JsonFormat.printToString(content).getBytes(_charset.name()); 37 | } 38 | 39 | public String getName () { 40 | return "json/protobuf"; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tpc/src/serializers/scala/media/Image.scala: -------------------------------------------------------------------------------- 1 | package serializers.scala.media 2 | 3 | case class Image( 4 | uri: String, 5 | title: Option[String], 6 | width: Int, 7 | height: Int, 8 | size: Image.Size) extends Serializable 9 | 10 | object Image { 11 | sealed abstract class Size 12 | object Size { 13 | case object Small extends Size 14 | case object Large extends Size 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tpc/src/serializers/scala/media/Media.scala: -------------------------------------------------------------------------------- 1 | package serializers.scala.media 2 | 3 | case class Media ( 4 | val uri: String, 5 | val title: Option[String], 6 | val width: Int, 7 | val height: Int, 8 | val format: String, 9 | val duration: Long, 10 | val size: Long, 11 | val bitrate: Option[Int], 12 | val persons: List[String], 13 | val player: Media.Player, 14 | val copyright: Option[String]) extends Serializable 15 | 16 | object Media { 17 | sealed abstract class Player 18 | object Player { 19 | case object Java extends Media.Player 20 | case object Flash extends Media.Player 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tpc/src/serializers/scala/media/MediaContent.scala: -------------------------------------------------------------------------------- 1 | package serializers.scala.media 2 | 3 | case class MediaContent (val media: Media, val images: List[Image]) extends Serializable 4 | -------------------------------------------------------------------------------- /tpc/src/serializers/stephenerialization/MediaContent.java: -------------------------------------------------------------------------------- 1 | package serializers.stephenerialization; 2 | 3 | import java.io.ObjectInputStream; 4 | import java.io.ObjectOutputStream; 5 | import java.util.List; 6 | 7 | import com.enragedginger.stephenerialization.StephenerializationLookupService; 8 | import com.enragedginger.stephenerialization.StephenerializationService; 9 | import com.enragedginger.stephenerialization.annotations.Stephenerializable; 10 | import com.enragedginger.stephenerialization.annotations.Stephenerialize; 11 | 12 | @Stephenerializable(version = 20121225) 13 | public class MediaContent implements java.io.Serializable 14 | { 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | @Stephenerialize(minVersion = 20121225, priority = 1) 19 | public Media media; 20 | @Stephenerialize(minVersion = 20121225, priority = 2) 21 | public List images; 22 | 23 | public MediaContent() {} 24 | 25 | public MediaContent (Media media, List images) { 26 | this.media = media; 27 | this.images = images; 28 | } 29 | 30 | @Override 31 | public boolean equals(Object o) 32 | { 33 | if (this == o) return true; 34 | if (o == null || getClass() != o.getClass()) return false; 35 | 36 | MediaContent that = (MediaContent) o; 37 | 38 | if (images != null ? !images.equals(that.images) : that.images != null) return false; 39 | if (media != null ? !media.equals(that.media) : that.media != null) return false; 40 | 41 | return true; 42 | } 43 | 44 | @Override 45 | public int hashCode() 46 | { 47 | int result = media != null ? media.hashCode() : 0; 48 | result = 31 * result + (images != null ? images.hashCode() : 0); 49 | return result; 50 | } 51 | 52 | public String toString() { 53 | StringBuilder sb = new StringBuilder(); 54 | sb.append("[MediaContent: "); 55 | sb.append("media=").append(media); 56 | sb.append(", images=").append(images); 57 | sb.append("]"); 58 | return sb.toString(); 59 | } 60 | 61 | public void setMedia(Media media) { 62 | this.media = media; 63 | } 64 | 65 | public void setImages(List images) { 66 | this.images = images; 67 | } 68 | 69 | public Media getMedia() { 70 | return media; 71 | } 72 | 73 | public List getImages() { 74 | return images; 75 | } 76 | 77 | /** 78 | * Writes this object out to the stream using Stephenerialization. 79 | * @param streamer The output stream to use. 80 | */ 81 | private void writeObject(ObjectOutputStream streamer) { 82 | MediaContentStephenerializer.stephenerialize(this, streamer); 83 | /*final StephenerializationService service = StephenerializationLookupService.lookup(); 84 | service.stephenerialize(this, streamer, MediaContent.class);*/ 85 | } 86 | 87 | /** 88 | * Reads this object from the stream using Stephenerialization. 89 | * @param streamer The input stream to use. 90 | */ 91 | private void readObject(ObjectInputStream streamer) { 92 | MediaContentStephenerializer.destephenerialize(this, streamer); 93 | /*final StephenerializationService service = StephenerializationLookupService.lookup(); 94 | service.destephenerialize(this, streamer, MediaContent.class);*/ 95 | } 96 | } -------------------------------------------------------------------------------- /tpc/src/serializers/wobly/Wobly.java: -------------------------------------------------------------------------------- 1 | package serializers.wobly; 2 | 3 | import serializers.SerClass; 4 | import serializers.SerFeatures; 5 | import serializers.SerFormat; 6 | import serializers.SerGraph; 7 | import serializers.TestGroups; 8 | import serializers.wobly.compact.WoblyCompactUtils; 9 | import serializers.wobly.simple.WoblySimpleUtils; 10 | 11 | public class Wobly { 12 | public static void register(TestGroups groups) 13 | { 14 | groups.media.add(new WoblySimpleUtils.WoblyTransformer(), new WoblySimpleUtils.WoblySerializer(), 15 | new SerFeatures( 16 | SerFormat.BINARY, 17 | SerGraph.FLAT_TREE, 18 | SerClass.MANUAL_OPT, 19 | "" 20 | ) 21 | ); 22 | groups.media.add(new WoblyCompactUtils.WoblyTransformer(), new WoblyCompactUtils.WoblySerializer(), 23 | new SerFeatures( 24 | SerFormat.BINARY, 25 | SerGraph.FLAT_TREE, 26 | SerClass.MANUAL_OPT, 27 | "" 28 | ) 29 | ); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /tpc/src/serializers/wobly/compact/WoblyCompactUtils.java: -------------------------------------------------------------------------------- 1 | package serializers.wobly.compact; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import data.media.Image; 8 | import data.media.Media; 9 | import data.media.MediaContent; 10 | import data.media.MediaTransformer; 11 | 12 | import serializers.Serializer; 13 | 14 | public class WoblyCompactUtils { 15 | public static WMedia forwardMedia(Media a) { 16 | return new WMedia(a.uri, a.title, a.width, a.height, a.format, a.duration, a.size, a.bitrate, a.persons, a.player, a.copyright); 17 | } 18 | public static Media reverseMedia(WMedia a) { 19 | return new Media(a.uri, a.title, a.width, a.height, a.format, a.duration, a.size, a.bitrate, true, a.persons, a.player, a.copyright); 20 | } 21 | public static WImage forwardImage(Image a) { 22 | return new WImage(a.uri, a.title, a.width, a.height, a.size); 23 | } 24 | public static Image reverseImage(WImage a) { 25 | return new Image(a.uri, a.title, a.width, a.height, a.size); 26 | } 27 | public static List forwardImages(List a) { 28 | ArrayList images = new ArrayList(a.size()); 29 | for (Image image : a) { 30 | images.add(forwardImage(image)); 31 | } 32 | return images; 33 | } 34 | public static List reverseImages(List a) { 35 | ArrayList images = new ArrayList(a.size()); 36 | for (WImage image : a) { 37 | images.add(reverseImage(image)); 38 | } 39 | return images; 40 | } 41 | 42 | public static final class WoblyTransformer extends MediaTransformer { 43 | @Override 44 | public WMediaContent[] resultArray(int size) { return new WMediaContent[size]; } 45 | 46 | @Override 47 | public WMediaContent forward(MediaContent a) { 48 | return new WMediaContent(forwardImages(a.images), forwardMedia(a.media)); 49 | } 50 | 51 | @Override 52 | public MediaContent reverse(WMediaContent a) { 53 | return new MediaContent(reverseMedia(a.media), reverseImages(a.images)); 54 | } 55 | 56 | @Override 57 | public MediaContent shallowReverse(WMediaContent a) { 58 | return new MediaContent(reverseMedia(a.media), Collections.emptyList()); 59 | } 60 | } 61 | public static final class WoblySerializer extends Serializer 62 | { 63 | @Override 64 | public WMediaContent deserialize(byte[] array) 65 | throws Exception { 66 | return WMediaContent.read(array); 67 | } 68 | 69 | @Override 70 | public byte[] serialize(WMediaContent content) 71 | throws Exception { 72 | return content.toByteArray(); 73 | } 74 | 75 | @Override 76 | public String getName() { 77 | return "wobly-compact"; 78 | } 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /tpc/src/serializers/wobly/simple/WoblySimpleUtils.java: -------------------------------------------------------------------------------- 1 | package serializers.wobly.simple; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import serializers.Serializer; 8 | import data.media.Image; 9 | import data.media.Media; 10 | import data.media.MediaContent; 11 | import data.media.MediaTransformer; 12 | 13 | public class WoblySimpleUtils { 14 | public static WMedia forwardMedia(Media a) { 15 | return new WMedia(a.uri, a.title, a.width, a.height, a.format, a.duration, a.size, a.bitrate, a.persons, a.player, a.copyright); 16 | } 17 | public static Media reverseMedia(WMedia a) { 18 | return new Media(a.uri, a.title, a.width, a.height, a.format, a.duration, a.size, a.bitrate, true, a.persons, a.player, a.copyright); 19 | } 20 | public static WImage forwardImage(Image a) { 21 | return new WImage(a.uri, a.title, a.width, a.height, a.size); 22 | } 23 | public static Image reverseImage(WImage a) { 24 | return new Image(a.uri, a.title, a.width, a.height, a.size); 25 | } 26 | public static List forwardImages(List a) { 27 | ArrayList images = new ArrayList(a.size()); 28 | for (Image image : a) { 29 | images.add(forwardImage(image)); 30 | } 31 | return images; 32 | } 33 | public static List reverseImages(List a) { 34 | ArrayList images = new ArrayList(a.size()); 35 | for (WImage image : a) { 36 | images.add(reverseImage(image)); 37 | } 38 | return images; 39 | } 40 | 41 | public static final class WoblyTransformer extends MediaTransformer 42 | { 43 | @Override 44 | public WMediaContent[] resultArray(int size) { return new WMediaContent[size]; } 45 | 46 | @Override 47 | public WMediaContent forward(MediaContent a) { 48 | return new WMediaContent(forwardImages(a.images), forwardMedia(a.media)); 49 | } 50 | 51 | @Override 52 | public MediaContent reverse(WMediaContent a) { 53 | return new MediaContent(reverseMedia(a.media), reverseImages(a.images)); 54 | } 55 | 56 | @Override 57 | public MediaContent shallowReverse(WMediaContent a) { 58 | return new MediaContent(reverseMedia(a.media), Collections.emptyList()); 59 | } 60 | } 61 | public static final class WoblySerializer extends Serializer 62 | { 63 | @Override 64 | public WMediaContent deserialize(byte[] array) 65 | throws Exception { 66 | return WMediaContent.read(array); 67 | } 68 | 69 | @Override 70 | public byte[] serialize(WMediaContent content) 71 | throws Exception { 72 | return content.toByteArray(); 73 | } 74 | 75 | @Override 76 | public String getName() { 77 | return "wobly"; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /tpc/src/serializers/xml/BaseStaxMediaSerializer.java: -------------------------------------------------------------------------------- 1 | package serializers.xml; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.InputStream; 6 | import java.io.OutputStream; 7 | 8 | import javax.xml.stream.XMLStreamException; 9 | import javax.xml.stream.XMLStreamReader; 10 | import javax.xml.stream.XMLStreamWriter; 11 | 12 | import serializers.Serializer; 13 | import data.media.MediaContent; 14 | 15 | public abstract class BaseStaxMediaSerializer extends Serializer 16 | { 17 | private final StaxSerializer _serializer = new StaxSerializer(); 18 | 19 | private final StaxDeserializer _deserializer; 20 | 21 | protected BaseStaxMediaSerializer(boolean workingGetElementText) 22 | { 23 | _deserializer = new StaxDeserializer(workingGetElementText); 24 | } 25 | 26 | protected XMLStreamReader createReader(byte[] input) throws XMLStreamException { 27 | return createReader(new ByteArrayInputStream(input)); 28 | } 29 | protected abstract XMLStreamReader createReader(InputStream in) throws XMLStreamException; 30 | protected abstract XMLStreamWriter createWriter(OutputStream output) throws XMLStreamException; 31 | 32 | // // Public API 33 | 34 | @Override 35 | public MediaContent deserialize (byte[] array) throws XMLStreamException 36 | { 37 | XMLStreamReader parser = createReader(array); 38 | MediaContent content = _deserializer.readDocument(parser); 39 | parser.close(); 40 | return content; 41 | } 42 | 43 | @Override 44 | public MediaContent[] deserializeItems(InputStream in, int numberOfItems) throws XMLStreamException 45 | { 46 | XMLStreamReader parser = createReader(in); 47 | MediaContent[] result = _deserializer.readDocument(parser, numberOfItems); 48 | parser.close(); 49 | return result; 50 | } 51 | 52 | @Override 53 | public byte[] serialize(MediaContent content) throws Exception 54 | { 55 | ByteArrayOutputStream baos = outputStream(content); 56 | XMLStreamWriter writer = createWriter(baos); 57 | _serializer.writeDocument(writer, content); 58 | writer.flush(); 59 | writer.close(); 60 | return baos.toByteArray(); 61 | } 62 | 63 | @Override 64 | public final void serializeItems(MediaContent[] items, OutputStream out) throws XMLStreamException 65 | { 66 | // XML requires single root, so add bogus "stream" 67 | XMLStreamWriter writer = createWriter(out); 68 | _serializer.writeDocument(writer, items); 69 | writer.flush(); 70 | writer.close(); 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /tpc/support/intellij/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/misc.xml 2 | .idea/workspace.xml 3 | -------------------------------------------------------------------------------- /tpc/support/intellij/.idea/.name: -------------------------------------------------------------------------------- 1 | jvm-serializers -------------------------------------------------------------------------------- /tpc/support/intellij/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 26 | 27 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /tpc/support/intellij/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tpc/support/intellij/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /tpc/support/intellij/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /tpc/support/intellij/.idea/libraries/All.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tpc/support/intellij/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /tpc/support/intellij/.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /tpc/support/intellij/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tpc/support/intellij/Main.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /tpc/support/scala/scala-compiler-2.13.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eishay/jvm-serializers/3f7e4bc94e40f2c8c89acd3d2e51454867cec596/tpc/support/scala/scala-compiler-2.13.3.jar -------------------------------------------------------------------------------- /tpc/support/scala/scalac: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | sv="2.13.3" 4 | 5 | # Locate the script file. Cross symlinks if necessary. 6 | loc="$0" 7 | while [ -h "$loc" ]; do 8 | ls=`ls -ld "$loc"` 9 | link=`expr "$ls" : '.*-> \(.*\)$'` 10 | if expr "$link" : '/.*' > /dev/null; then 11 | loc="$link" # Absolute link 12 | else 13 | loc="`dirname "$loc"`/$link" # Relative link 14 | fi 15 | done 16 | 17 | base_dir=`dirname "$loc"` 18 | 19 | path_sep=":" 20 | case "`uname`" in 21 | CYGWIN*) path_sep=";" ;; 22 | esac 23 | 24 | cp="" 25 | sep="" 26 | for jar in "$base_dir"/scala-compiler-$sv.jar "$base_dir/../../lib"/scala-{library,reflect}-$sv.jar; do 27 | cp="$cp$sep$jar" 28 | sep="$path_sep" 29 | done 30 | 31 | java -cp "$cp" scala.tools.nsc.Main "$@" 32 | -------------------------------------------------------------------------------- /tpc/website/.gitignore: -------------------------------------------------------------------------------- 1 | /benchmarkResults.js 2 | -------------------------------------------------------------------------------- /tpc/website/beval.js: -------------------------------------------------------------------------------- 1 | // Boolean expression evaluator. 2 | 3 | var beval = (function() { 4 | 5 | function eval(s, domain) { 6 | var stream = new Stream(s) 7 | var tokenizer = new Tokenizer(stream) 8 | 9 | function expr() { 10 | var v = term() 11 | 12 | while (true) { 13 | var t = tokenizer.peek() 14 | if (t.type === '|' || t.type === '&' || t.type === '-') { 15 | tokenizer.next() 16 | var f = domain[t.type] 17 | v = f(v, term()) 18 | } else { 19 | return v 20 | } 21 | } 22 | } 23 | 24 | function term() { 25 | var t = tokenizer.peek() 26 | if (t.type === '(') { 27 | tokenizer.next() 28 | var v = expr() 29 | var end = tokenizer.peek() 30 | if (end.type != ')') { 31 | throw new EvalError(end.pos, "expecting \")\" to match \"(\" at position " + t.pos) 32 | } 33 | tokenizer.next() 34 | return v 35 | } 36 | else if (t.type === 'ident') { 37 | tokenizer.next() 38 | var v = domain.ident(t.v) 39 | if (v === null) { 40 | throw new EvalError(t.pos, "unknown identifier: " + JSON.stringify(t.v)) 41 | } 42 | return v 43 | } 44 | else if (t.type === '!') { 45 | tokenizer.next() 46 | var f = domain['!'] 47 | return f(term()) 48 | } 49 | else { 50 | throw new EvalError(t.pos, "not expecting: " + t.type) 51 | } 52 | } 53 | 54 | var v = expr() 55 | var t = tokenizer.peek() 56 | if (t.type != "end of input") { 57 | throw new EvalError(t.pos, "not expecting: " + t.type) 58 | } 59 | return v 60 | } 61 | 62 | function EvalError(pos, message) { 63 | this.pos = pos 64 | this.message = message 65 | 66 | this.toString = function() { 67 | return pos.toString() + ": " + message 68 | } 69 | } 70 | 71 | function isIdentChar(c) { 72 | if (c === null) return false 73 | return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c === '.' || c == '-' || c == '/' 74 | } 75 | 76 | function isDelimiter(c) { 77 | if (c === null) return false 78 | return c === '&' || c === '|' || c === '!' || c === '-' || c === '(' || c === ')' 79 | } 80 | 81 | function Stream(s) { 82 | var i = 0 83 | this.pos = function() { return i+1 } 84 | this.peek = function() { 85 | if (i >= s.length) return null 86 | return s[i] 87 | } 88 | this.next = function() { 89 | if (i >= s.length) return 90 | i++ 91 | } 92 | } 93 | 94 | function Tokenizer(stream) { 95 | function _next() { 96 | // Eat whitespace 97 | while ((c = stream.peek()) === ' ') { 98 | stream.next() 99 | } 100 | 101 | if (c === null) return {pos: pos, type: "end of input"} 102 | var pos = stream.pos() 103 | 104 | if (isDelimiter(c)) { 105 | stream.next() 106 | return {pos: pos, type: c} 107 | } 108 | 109 | if (isIdentChar(c)) { 110 | stream.next() 111 | var ident = c 112 | while (isIdentChar((c = stream.peek()))) { 113 | stream.next() 114 | ident += c 115 | } 116 | return {pos: pos, type: 'ident', v: ident} 117 | } 118 | 119 | throw new EvalError(pos, "invalid character: " + JSON.stringify(c)) 120 | } 121 | 122 | var nextToken = _next() 123 | this.next = function() { nextToken = _next(); } 124 | this.peek = function() { return nextToken } 125 | } 126 | 127 | return { 128 | eval: eval, 129 | EvalError: EvalError, 130 | } 131 | 132 | })() 133 | -------------------------------------------------------------------------------- /tpc/website/example-benchmarkResults.js: -------------------------------------------------------------------------------- 1 | // Example results file. To see it being used: 2 | // 1. Copy to "benchmarkResults.js". 3 | // 2. View "index.html" in a web browser. 4 | 5 | var benchmarkResults = { 6 | columns: ['ser', 'deser', 'size', 'gz-size'], 7 | 8 | categories: [ 9 | // Serialization format. 10 | { 11 | name: "Format", 12 | properties: [ 13 | { 14 | name: "text", 15 | description: "the serializer uses a human-readable text format", 16 | }, 17 | { 18 | name: "neutral", 19 | description: "the serializer's format is language-neutral", 20 | }, 21 | ] 22 | }, 23 | // Specifying the data structure. 24 | { 25 | name: "Spec", 26 | properties: [ 27 | { 28 | name: "pojo", 29 | description: "the serializer automatically uses POJOs", 30 | }, 31 | { 32 | name: "schema", 33 | description: "you must define a schema for your data type and compile that schema", 34 | }, 35 | { 36 | name: "manual", 37 | description: "you must call the serialization routines manually", 38 | }, 39 | { 40 | name: "manual.more", 41 | description: "you must call the serialization routines manually, and there is more effort involved", 42 | }, 43 | ], 44 | }, 45 | // For POJO serializers, some additional properties. 46 | { 47 | name: "POJO Hints", 48 | properties: [ 49 | { 50 | name: "hint.type", 51 | description: "the serializer was given the list of type names", 52 | }, 53 | { 54 | name: "hint.null", 55 | description: "the serializer was given the list of non-null fields", 56 | }, 57 | ], 58 | }, 59 | ], 60 | 61 | entries: [ 62 | { 63 | name: 'protobuf', 64 | properties: ['schema', 'neutral'], 65 | results: [10, 12, 12, 11] 66 | }, 67 | { 68 | name: 'kryo', 69 | properties: ['pojo'], 70 | results: [11, 13, 8, 4] 71 | }, 72 | { 73 | name: 'kryo-opt', 74 | properties: ['pojo', 'hint.type', 'hint.null'], 75 | results: [10, 10, 8, 4] 76 | }, 77 | { 78 | name: 'jackson-databind', 79 | properties: ['pojo', 'text', 'neutral'], 80 | results: [40, 20, 18, 16] 81 | }, 82 | { 83 | name: 'jackson-manual', 84 | properties: ['manual.more', 'text', 'neutral'], 85 | results: [4, 24, 22, 20] 86 | }, 87 | { 88 | name: 'jvm-default', 89 | properties: ['pojo'], 90 | results: [50, 50, 12, 11] 91 | }, 92 | { 93 | name: 'jvm-manual', 94 | properties: ['manual'], 95 | results: [15, 15, 12, 11] 96 | }, 97 | ], 98 | } 99 | -------------------------------------------------------------------------------- /tpc/website/fchart.css: -------------------------------------------------------------------------------- 1 | .fchart-body { 2 | display: table; 3 | } 4 | 5 | .fchart-row { 6 | display: table-row; 7 | } 8 | 9 | .fchart-row-hidden { 10 | display: none; 11 | height: 100%; 12 | } 13 | 14 | .fchart-row-label { 15 | display: table-cell; 16 | text-align: right; 17 | vertical-align: middle; 18 | white-space: nowrap; 19 | padding: 0 2px; 20 | font-size: small; 21 | } 22 | 23 | .fchart-row-data { 24 | display: table-cell; 25 | width: 100%; 26 | height: 100%; 27 | padding: 1px 0 0 0; 28 | } 29 | 30 | .fchart-row-data-bar { 31 | background-color: #246; 32 | height: 100%; 33 | display: inline-block; 34 | } 35 | 36 | .fchart-row-data-bar-0 { 37 | background-color: #123; 38 | } 39 | --------------------------------------------------------------------------------