Added: avro/trunk/lang/csharp/src/apache/perf/PerfTest.cs URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/perf/PerfTest.cs?rev=1540206&view=auto ============================================================================== --- avro/trunk/lang/csharp/src/apache/perf/PerfTest.cs (added) +++ avro/trunk/lang/csharp/src/apache/perf/PerfTest.cs Fri Nov 8 22:15:02 2013 @@ -0,0 +1,239 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Avro.Generic; +using Avro.IO; +using Avro.Specific; +using com.foo; + +namespace Avro.perf +{ + class Program + { + static void Main(string[] args) + { + Console.Out.WriteLine("type\timpl\taction\ttotal_items\tbatches\tbatch_size\ttime(ms)"); + PerfTest( "simple", BuildSimple(), Simple._SCHEMA); + PerfTest( "complex", BuildComplex(), Complex._SCHEMA); + PerfTest( "narrow", BuildNarrow(), Narrow._SCHEMA); + PerfTest( "wide", BuildWide(), Wide._SCHEMA); + } + + private static Simple BuildSimple() + { + var bytes = "bytes sample text"; + var encoding = new UTF8Encoding(); + var simp = new Simple + { + myInt = 1, + myLong = 2, + myBool = true, + myDouble = (double) 3, + myFloat = (float) 4.5, + myBytes = encoding.GetBytes( bytes ), + myString = "Hello", + myNull = null, + }; + return simp; + } + + private static Complex BuildComplex() + { + var bytes = "bytes sample text"; + var encoding = new UTF8Encoding(); + + var c = new Complex + { + myUInt = 1, + myULong = 2, + myUBool = true, + myUDouble = (double) 3, + myUFloat = (float) 4.5, + myUBytes = encoding.GetBytes( bytes ), + myUString = "Hello", + myInt = 1, + myLong = 2, + myBool = true, + myDouble = (double) 3, + myFloat = (float) 4.5, + myBytes = encoding.GetBytes( bytes ), + myString = "Hello", + myNull = null, + myFixed = new MyFixed() { Value = encoding.GetBytes( "My fixed record0" ) }, + myA = new A() { f1 = 10 }, + myE = com.foo.MyEnum.C + }; + + c.myArray = new List<byte[]>(); + c.myArray.Add( encoding.GetBytes( "a" ) ); + + c.myArray2 = new List<com.foo.newRec>(); + var rec = new com.foo.newRec(); + rec.f1 = 50; + c.myArray2.Add( rec ); + + c.myMap = new Dictionary<string, string>(); + c.myMap.Add( "key", "value" ); + c.myMap2 = new Dictionary<string, com.foo.newRec>(); + var newrec = new com.foo.newRec(); + newrec.f1 = 1200; + c.myMap2.Add( "A", newrec ); + c.myObject = c.myA; + + var o1 = new List<System.Object>(); + + o1.Add( (double) 1123123121 ); + o1.Add( (double) 2 ); + o1.Add( null ); + o1.Add( "fred" ); + + var o2 = new List<System.Object>(); + + o2.Add( (double) 1 ); + o2.Add( (double) 32531 ); + o2.Add( (double) 4 ); + o2.Add( (double) 555 ); + o2.Add( (double) 0 ); + + c.myArray3 = new List<IList<System.Object>>(); + c.myArray3.Add( o1 ); + c.myArray3.Add( o2 ); + return c; + } + + private static Narrow BuildNarrow() + { + return new Narrow + { + myInt = 5000000, + myLong = 99999999999, + myString = "narrow" + }; + } + + private static Wide BuildWide() + { + return new Wide() + { + myA = new A { f1 = 9995885 }, + myA2 = new A { f1 = 29995885 }, + myA3 = new A { f1 = 39995885 }, + myA4 = new A { f1 = 49995885 }, + myFloat = 11111.11f, + myFloat2 = 22222.22f, + myFloat3 = 33333.33f, + myFloat4 = 44444.44f, + myE = MyEnum.A, + myE2 = MyEnum.B, + myE3 = MyEnum.C, + myE4 = MyEnum.C, + myBool = true, + myBool2 = false, + myBool3 = true, + myBool4 = false, + myDouble = 11111111111.11, + myDouble2 = 22222222222.22, + myDouble3 = 33333333333.33, + myDouble4 = 44444444444.44, + myInt = 1111111, + myInt2 = 2222222, + myInt3 = 3333333, + myInt4 = 4444444, + myLong = 1111111111111, + myLong2 = 2222222222222, + myLong3 = 3333333333333, + myLong4 = 4444444444444, + myString = "wide record 1", + myString2 = "wide record 2", + myString3 = "wide record 3", + myString4 = "wide record 4", + myBytes = new byte[] { 1, 1, 1, 1 }, + myBytes2 = new byte[] { 2, 2, 2, 2 }, + myBytes3 = new byte[] { 3, 3, 3, 3 }, + myBytes4 = new byte[] { 4, 4, 4, 4 } + }; + } + + private static void PerfTest<T>(string testName, T testObj, Schema schema) + { + var generic = ConvertSpecificToGeneric(testObj, schema); + PerfTest(testName, "default_specific", testObj, schema, s => new SpecificWriter<T>(s), s => new SpecificReader<T>(s, s)); + PerfTest(testName, "preresolved_specific", testObj, schema, s => new SpecificDatumWriter<T>(s), s => new SpecificDatumReader<T>(s, s)); + PerfTest(testName, "default_generic", generic, schema, s => new GenericWriter<GenericRecord>(s), s => new GenericReader<GenericRecord>(s, s)); + PerfTest(testName, "preresolved_generic", generic, schema, s => new GenericDatumWriter<GenericRecord>(s), s => new GenericDatumReader<GenericRecord>(s, s)); + } + + private static GenericRecord ConvertSpecificToGeneric<T>(T obj, Schema schema) + { + var stream = new MemoryStream(); + var encoder = new BinaryEncoder( stream ); + var decoder = new BinaryDecoder( stream ); + + var writer = new SpecificWriter<T>(schema); + writer.Write(obj, encoder); + encoder.Flush(); + stream.Position = 0; + + return new GenericReader<GenericRecord>(schema, schema).Read(null, decoder); + } + + private static void PerfTest<T>(string name, string impl, T z, Schema schema, Func<Schema,DatumWriter<T>> writerFactory, Func<Schema,DatumReader<T>> readerFactory) + { + var stream = new MemoryStream(); + var binEncoder = new BinaryEncoder( stream ); + var decoder = new BinaryDecoder( stream ); + + var totalItems = 1000000; + + foreach (int itemsPerBatch in new List<int> { 1000 } ) + { + int serialized = 0; + int batches = totalItems / itemsPerBatch; + var startTime = Environment.TickCount; + for (int batch = 0; batch < batches; batch++ ) + { + var writer = writerFactory( schema ); + for( int i = 0; i < itemsPerBatch; i++ ) + { + stream.Position = 0; + writer.Write( z, binEncoder ); + serialized++; + } + } + Console.Out.WriteLine("{0}\t{1}\tserialize\t{2}\t{3}\t{4}\t{5}", name, impl, serialized, batches, itemsPerBatch, Environment.TickCount - startTime); + + int deserialized = 0; + startTime = Environment.TickCount; + for (int batch = 0; batch < batches; batch++ ) + { + var reader = readerFactory(schema); + for (int i = 0; i < itemsPerBatch; i++) + { + stream.Position = 0; + reader.Read( z, decoder ); + deserialized++; + } + } + Console.Out.WriteLine("{0}\t{1}\tdeserialize\t{2}\t{3}\t{4}\t{5}", name, impl, deserialized, batches, itemsPerBatch, Environment.TickCount - startTime); + } + } + } +} \ No newline at end of file
Added: avro/trunk/lang/csharp/src/apache/perf/com/foo/A.cs URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/perf/com/foo/A.cs?rev=1540206&view=auto ============================================================================== --- avro/trunk/lang/csharp/src/apache/perf/com/foo/A.cs (added) +++ avro/trunk/lang/csharp/src/apache/perf/com/foo/A.cs Fri Nov 8 22:15:02 2013 @@ -0,0 +1,56 @@ +// ------------------------------------------------------------------------------ +// <auto-generated> +// Generated by avrogen.exe, version 0.9.0.0 +// Changes to this file may cause incorrect behavior and will be lost if code +// is regenerated +// </auto-generated> +// ------------------------------------------------------------------------------ +namespace com.foo +{ + using System; + using System.Collections.Generic; + using System.Text; + using Avro; + using Avro.Specific; + + public partial class A : ISpecificRecord + { + public static Schema _SCHEMA = Avro.Schema.Parse("{\"type\":\"record\",\"name\":\"A\",\"namespace\":\"com.foo\",\"fields\":[{\"name\":\"f1\",\"type\":\"" + + "long\"}]}"); + private long _f1; + public virtual Schema Schema + { + get + { + return A._SCHEMA; + } + } + public long f1 + { + get + { + return this._f1; + } + set + { + this._f1 = value; + } + } + public virtual object Get(int fieldPos) + { + switch (fieldPos) + { + case 0: return this.f1; + default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()"); + }; + } + public virtual void Put(int fieldPos, object fieldValue) + { + switch (fieldPos) + { + case 0: this.f1 = (System.Int64)fieldValue; break; + default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()"); + }; + } + } +} Added: avro/trunk/lang/csharp/src/apache/perf/com/foo/Complex.cs URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/perf/com/foo/Complex.cs?rev=1540206&view=auto ============================================================================== --- avro/trunk/lang/csharp/src/apache/perf/com/foo/Complex.cs (added) +++ avro/trunk/lang/csharp/src/apache/perf/com/foo/Complex.cs Fri Nov 8 22:15:02 2013 @@ -0,0 +1,377 @@ +// ------------------------------------------------------------------------------ +// <auto-generated> +// Generated by avrogen.exe, version 0.9.0.0 +// Changes to this file may cause incorrect behavior and will be lost if code +// is regenerated +// </auto-generated> +// ------------------------------------------------------------------------------ +namespace com.foo +{ + using System; + using System.Collections.Generic; + using System.Text; + using Avro; + using Avro.Specific; + + public partial class Complex : ISpecificRecord + { + public static Schema _SCHEMA = Avro.Schema.Parse(@"{""type"":""record"",""name"":""Complex"",""namespace"":""com.foo"",""fields"":[{""name"":""myUInt"",""type"":[""int"",""null""]},{""name"":""myULong"",""type"":[""long"",""null""]},{""name"":""myUBool"",""type"":[""boolean"",""null""]},{""name"":""myUDouble"",""type"":[""double"",""null""]},{""name"":""myUFloat"",""type"":[""float"",""null""]},{""name"":""myUBytes"",""type"":[""bytes"",""null""]},{""name"":""myUString"",""type"":[""string"",""null""]},{""name"":""myInt"",""type"":""int""},{""name"":""myLong"",""type"":""long""},{""name"":""myBool"",""type"":""boolean""},{""name"":""myDouble"",""type"":""double""},{""name"":""myFloat"",""type"":""float""},{""name"":""myBytes"",""type"":""bytes""},{""name"":""myString"",""type"":""string""},{""name"":""myNull"",""type"":""null""},{""name"":""myFixed"",""type"":{""type"":""fixed"",""name"":""MyFixed"",""namespace"":""com.foo"",""size"":16}},{""name"":""myA"",""type"":{""type"":""rec ord"",""name"":""A"",""namespace"":""com.foo"",""fields"":[{""name"":""f1"",""type"":""long""}]}},{""name"":""myE"",""type"":{""type"":""enum"",""name"":""MyEnum"",""namespace"":""com.foo"",""symbols"":[""A"",""B"",""C""]}},{""name"":""myArray"",""type"":{""type"":""array"",""items"":""bytes""}},{""name"":""myArray2"",""type"":{""type"":""array"",""items"":{""type"":""record"",""name"":""newRec"",""namespace"":""com.foo"",""fields"":[{""name"":""f1"",""type"":""long""}]}}},{""name"":""myMap"",""type"":{""type"":""map"",""values"":""string""}},{""name"":""myMap2"",""type"":{""type"":""map"",""values"":""newRec""}},{""name"":""myObject"",""type"":[""MyEnum"",""A"",""null""]},{""name"":""myArray3"",""type"":{""type"":""array"",""items"":{""type"":""array"",""items"":[""double"",""string"",""null""]}}}]}"); + private System.Nullable<int> _myUInt; + private System.Nullable<long> _myULong; + private System.Nullable<bool> _myUBool; + private System.Nullable<double> _myUDouble; + private System.Nullable<float> _myUFloat; + private byte[] _myUBytes; + private string _myUString; + private int _myInt; + private long _myLong; + private bool _myBool; + private double _myDouble; + private float _myFloat; + private byte[] _myBytes; + private string _myString; + private object _myNull; + private com.foo.MyFixed _myFixed; + private com.foo.A _myA; + private com.foo.MyEnum _myE; + private IList<System.Byte[]> _myArray; + private IList<com.foo.newRec> _myArray2; + private IDictionary<string,System.String> _myMap; + private IDictionary<string,com.foo.newRec> _myMap2; + private object _myObject; + private IList<IList<System.Object>> _myArray3; + public virtual Schema Schema + { + get + { + return Complex._SCHEMA; + } + } + public System.Nullable<int> myUInt + { + get + { + return this._myUInt; + } + set + { + this._myUInt = value; + } + } + public System.Nullable<long> myULong + { + get + { + return this._myULong; + } + set + { + this._myULong = value; + } + } + public System.Nullable<bool> myUBool + { + get + { + return this._myUBool; + } + set + { + this._myUBool = value; + } + } + public System.Nullable<double> myUDouble + { + get + { + return this._myUDouble; + } + set + { + this._myUDouble = value; + } + } + public System.Nullable<float> myUFloat + { + get + { + return this._myUFloat; + } + set + { + this._myUFloat = value; + } + } + public byte[] myUBytes + { + get + { + return this._myUBytes; + } + set + { + this._myUBytes = value; + } + } + public string myUString + { + get + { + return this._myUString; + } + set + { + this._myUString = value; + } + } + public int myInt + { + get + { + return this._myInt; + } + set + { + this._myInt = value; + } + } + public long myLong + { + get + { + return this._myLong; + } + set + { + this._myLong = value; + } + } + public bool myBool + { + get + { + return this._myBool; + } + set + { + this._myBool = value; + } + } + public double myDouble + { + get + { + return this._myDouble; + } + set + { + this._myDouble = value; + } + } + public float myFloat + { + get + { + return this._myFloat; + } + set + { + this._myFloat = value; + } + } + public byte[] myBytes + { + get + { + return this._myBytes; + } + set + { + this._myBytes = value; + } + } + public string myString + { + get + { + return this._myString; + } + set + { + this._myString = value; + } + } + public object myNull + { + get + { + return this._myNull; + } + set + { + this._myNull = value; + } + } + public com.foo.MyFixed myFixed + { + get + { + return this._myFixed; + } + set + { + this._myFixed = value; + } + } + public com.foo.A myA + { + get + { + return this._myA; + } + set + { + this._myA = value; + } + } + public com.foo.MyEnum myE + { + get + { + return this._myE; + } + set + { + this._myE = value; + } + } + public IList<System.Byte[]> myArray + { + get + { + return this._myArray; + } + set + { + this._myArray = value; + } + } + public IList<com.foo.newRec> myArray2 + { + get + { + return this._myArray2; + } + set + { + this._myArray2 = value; + } + } + public IDictionary<string,System.String> myMap + { + get + { + return this._myMap; + } + set + { + this._myMap = value; + } + } + public IDictionary<string,com.foo.newRec> myMap2 + { + get + { + return this._myMap2; + } + set + { + this._myMap2 = value; + } + } + public object myObject + { + get + { + return this._myObject; + } + set + { + this._myObject = value; + } + } + public IList<IList<System.Object>> myArray3 + { + get + { + return this._myArray3; + } + set + { + this._myArray3 = value; + } + } + public virtual object Get(int fieldPos) + { + switch (fieldPos) + { + case 0: return this.myUInt; + case 1: return this.myULong; + case 2: return this.myUBool; + case 3: return this.myUDouble; + case 4: return this.myUFloat; + case 5: return this.myUBytes; + case 6: return this.myUString; + case 7: return this.myInt; + case 8: return this.myLong; + case 9: return this.myBool; + case 10: return this.myDouble; + case 11: return this.myFloat; + case 12: return this.myBytes; + case 13: return this.myString; + case 14: return this.myNull; + case 15: return this.myFixed; + case 16: return this.myA; + case 17: return this.myE; + case 18: return this.myArray; + case 19: return this.myArray2; + case 20: return this.myMap; + case 21: return this.myMap2; + case 22: return this.myObject; + case 23: return this.myArray3; + default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()"); + }; + } + public virtual void Put(int fieldPos, object fieldValue) + { + switch (fieldPos) + { + case 0: this.myUInt = (System.Nullable<int>)fieldValue; break; + case 1: this.myULong = (System.Nullable<long>)fieldValue; break; + case 2: this.myUBool = (System.Nullable<bool>)fieldValue; break; + case 3: this.myUDouble = (System.Nullable<double>)fieldValue; break; + case 4: this.myUFloat = (System.Nullable<float>)fieldValue; break; + case 5: this.myUBytes = (System.Byte[])fieldValue; break; + case 6: this.myUString = (System.String)fieldValue; break; + case 7: this.myInt = (System.Int32)fieldValue; break; + case 8: this.myLong = (System.Int64)fieldValue; break; + case 9: this.myBool = (System.Boolean)fieldValue; break; + case 10: this.myDouble = (System.Double)fieldValue; break; + case 11: this.myFloat = (System.Single)fieldValue; break; + case 12: this.myBytes = (System.Byte[])fieldValue; break; + case 13: this.myString = (System.String)fieldValue; break; + case 14: this.myNull = (System.Object)fieldValue; break; + case 15: this.myFixed = (com.foo.MyFixed)fieldValue; break; + case 16: this.myA = (com.foo.A)fieldValue; break; + case 17: this.myE = (com.foo.MyEnum)fieldValue; break; + case 18: this.myArray = (IList<System.Byte[]>)fieldValue; break; + case 19: this.myArray2 = (IList<com.foo.newRec>)fieldValue; break; + case 20: this.myMap = (IDictionary<string,System.String>)fieldValue; break; + case 21: this.myMap2 = (IDictionary<string,com.foo.newRec>)fieldValue; break; + case 22: this.myObject = (System.Object)fieldValue; break; + case 23: this.myArray3 = (IList<IList<System.Object>>)fieldValue; break; + default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()"); + }; + } + } +} Added: avro/trunk/lang/csharp/src/apache/perf/com/foo/MyEnum.cs URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/perf/com/foo/MyEnum.cs?rev=1540206&view=auto ============================================================================== --- avro/trunk/lang/csharp/src/apache/perf/com/foo/MyEnum.cs (added) +++ avro/trunk/lang/csharp/src/apache/perf/com/foo/MyEnum.cs Fri Nov 8 22:15:02 2013 @@ -0,0 +1,22 @@ +// ------------------------------------------------------------------------------ +// <auto-generated> +// Generated by avrogen.exe, version 0.9.0.0 +// Changes to this file may cause incorrect behavior and will be lost if code +// is regenerated +// </auto-generated> +// ------------------------------------------------------------------------------ +namespace com.foo +{ + using System; + using System.Collections.Generic; + using System.Text; + using Avro; + using Avro.Specific; + + public enum MyEnum + { + A, + B, + C, + } +} Added: avro/trunk/lang/csharp/src/apache/perf/com/foo/MyFixed.cs URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/perf/com/foo/MyFixed.cs?rev=1540206&view=auto ============================================================================== --- avro/trunk/lang/csharp/src/apache/perf/com/foo/MyFixed.cs (added) +++ avro/trunk/lang/csharp/src/apache/perf/com/foo/MyFixed.cs Fri Nov 8 22:15:02 2013 @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------ +// <auto-generated> +// Generated by avrogen.exe, version 0.9.0.0 +// Changes to this file may cause incorrect behavior and will be lost if code +// is regenerated +// </auto-generated> +// ------------------------------------------------------------------------------ +namespace com.foo +{ + using System; + using System.Collections.Generic; + using System.Text; + using Avro; + using Avro.Specific; + + public partial class MyFixed : SpecificFixed + { + public static Schema _SCHEMA = Avro.Schema.Parse("{\"type\":\"fixed\",\"name\":\"MyFixed\",\"namespace\":\"com.foo\",\"size\":16}"); + private static uint fixedSize = 16; + public MyFixed() : + base(fixedSize) + { + } + public override Schema Schema + { + get + { + return MyFixed._SCHEMA; + } + } + public static uint FixedSize + { + get + { + return MyFixed.fixedSize; + } + } + } +} Added: avro/trunk/lang/csharp/src/apache/perf/com/foo/Narrow.cs URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/perf/com/foo/Narrow.cs?rev=1540206&view=auto ============================================================================== --- avro/trunk/lang/csharp/src/apache/perf/com/foo/Narrow.cs (added) +++ avro/trunk/lang/csharp/src/apache/perf/com/foo/Narrow.cs Fri Nov 8 22:15:02 2013 @@ -0,0 +1,85 @@ +// ------------------------------------------------------------------------------ +// <auto-generated> +// Generated by avrogen.exe, version 0.9.0.0 +// Changes to this file may cause incorrect behavior and will be lost if code +// is regenerated +// </auto-generated> +// ------------------------------------------------------------------------------ +namespace com.foo +{ + using System; + using System.Collections.Generic; + using System.Text; + using Avro; + using Avro.Specific; + + public partial class Narrow : ISpecificRecord + { + public static Schema _SCHEMA = Avro.Schema.Parse("{\"type\":\"record\",\"name\":\"Narrow\",\"namespace\":\"com.foo\",\"fields\":[{\"name\":\"myInt\"," + + "\"type\":\"int\"},{\"name\":\"myLong\",\"type\":\"long\"},{\"name\":\"myString\",\"type\":\"string\"" + + "}]}"); + private int _myInt; + private long _myLong; + private string _myString; + public virtual Schema Schema + { + get + { + return Narrow._SCHEMA; + } + } + public int myInt + { + get + { + return this._myInt; + } + set + { + this._myInt = value; + } + } + public long myLong + { + get + { + return this._myLong; + } + set + { + this._myLong = value; + } + } + public string myString + { + get + { + return this._myString; + } + set + { + this._myString = value; + } + } + public virtual object Get(int fieldPos) + { + switch (fieldPos) + { + case 0: return this.myInt; + case 1: return this.myLong; + case 2: return this.myString; + default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()"); + }; + } + public virtual void Put(int fieldPos, object fieldValue) + { + switch (fieldPos) + { + case 0: this.myInt = (System.Int32)fieldValue; break; + case 1: this.myLong = (System.Int64)fieldValue; break; + case 2: this.myString = (System.String)fieldValue; break; + default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()"); + }; + } + } +} Added: avro/trunk/lang/csharp/src/apache/perf/com/foo/Simple.cs URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/perf/com/foo/Simple.cs?rev=1540206&view=auto ============================================================================== --- avro/trunk/lang/csharp/src/apache/perf/com/foo/Simple.cs (added) +++ avro/trunk/lang/csharp/src/apache/perf/com/foo/Simple.cs Fri Nov 8 22:15:02 2013 @@ -0,0 +1,153 @@ +// ------------------------------------------------------------------------------ +// <auto-generated> +// Generated by avrogen.exe, version 0.9.0.0 +// Changes to this file may cause incorrect behavior and will be lost if code +// is regenerated +// </auto-generated> +// ------------------------------------------------------------------------------ +namespace com.foo +{ + using System; + using System.Collections.Generic; + using System.Text; + using Avro; + using Avro.Specific; + + public partial class Simple : ISpecificRecord + { + public static Schema _SCHEMA = Avro.Schema.Parse(@"{""type"":""record"",""name"":""Simple"",""namespace"":""com.foo"",""fields"":[{""name"":""myInt"",""type"":""int""},{""name"":""myLong"",""type"":""long""},{""name"":""myBool"",""type"":""boolean""},{""name"":""myDouble"",""type"":""double""},{""name"":""myFloat"",""type"":""float""},{""name"":""myBytes"",""type"":""bytes""},{""name"":""myString"",""type"":""string""},{""name"":""myNull"",""type"":""null""}]}"); + private int _myInt; + private long _myLong; + private bool _myBool; + private double _myDouble; + private float _myFloat; + private byte[] _myBytes; + private string _myString; + private object _myNull; + public virtual Schema Schema + { + get + { + return Simple._SCHEMA; + } + } + public int myInt + { + get + { + return this._myInt; + } + set + { + this._myInt = value; + } + } + public long myLong + { + get + { + return this._myLong; + } + set + { + this._myLong = value; + } + } + public bool myBool + { + get + { + return this._myBool; + } + set + { + this._myBool = value; + } + } + public double myDouble + { + get + { + return this._myDouble; + } + set + { + this._myDouble = value; + } + } + public float myFloat + { + get + { + return this._myFloat; + } + set + { + this._myFloat = value; + } + } + public byte[] myBytes + { + get + { + return this._myBytes; + } + set + { + this._myBytes = value; + } + } + public string myString + { + get + { + return this._myString; + } + set + { + this._myString = value; + } + } + public object myNull + { + get + { + return this._myNull; + } + set + { + this._myNull = value; + } + } + public virtual object Get(int fieldPos) + { + switch (fieldPos) + { + case 0: return this.myInt; + case 1: return this.myLong; + case 2: return this.myBool; + case 3: return this.myDouble; + case 4: return this.myFloat; + case 5: return this.myBytes; + case 6: return this.myString; + case 7: return this.myNull; + default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()"); + }; + } + public virtual void Put(int fieldPos, object fieldValue) + { + switch (fieldPos) + { + case 0: this.myInt = (System.Int32)fieldValue; break; + case 1: this.myLong = (System.Int64)fieldValue; break; + case 2: this.myBool = (System.Boolean)fieldValue; break; + case 3: this.myDouble = (System.Double)fieldValue; break; + case 4: this.myFloat = (System.Single)fieldValue; break; + case 5: this.myBytes = (System.Byte[])fieldValue; break; + case 6: this.myString = (System.String)fieldValue; break; + case 7: this.myNull = (System.Object)fieldValue; break; + default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()"); + }; + } + } +} Added: avro/trunk/lang/csharp/src/apache/perf/com/foo/Wide.cs URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/perf/com/foo/Wide.cs?rev=1540206&view=auto ============================================================================== --- avro/trunk/lang/csharp/src/apache/perf/com/foo/Wide.cs (added) +++ avro/trunk/lang/csharp/src/apache/perf/com/foo/Wide.cs Fri Nov 8 22:15:02 2013 @@ -0,0 +1,545 @@ +// ------------------------------------------------------------------------------ +// <auto-generated> +// Generated by avrogen.exe, version 0.9.0.0 +// Changes to this file may cause incorrect behavior and will be lost if code +// is regenerated +// </auto-generated> +// ------------------------------------------------------------------------------ +namespace com.foo +{ + using System; + using System.Collections.Generic; + using System.Text; + using Avro; + using Avro.Specific; + + public partial class Wide : ISpecificRecord + { + public static Schema _SCHEMA = Avro.Schema.Parse(@"{""type"":""record"",""name"":""Wide"",""namespace"":""com.foo"",""fields"":[{""name"":""myInt"",""type"":""int""},{""name"":""myLong"",""type"":""long""},{""name"":""myBool"",""type"":""boolean""},{""name"":""myDouble"",""type"":""double""},{""name"":""myFloat"",""type"":""float""},{""name"":""myBytes"",""type"":""bytes""},{""name"":""myString"",""type"":""string""},{""name"":""myA"",""type"":{""type"":""record"",""name"":""A"",""namespace"":""com.foo"",""fields"":[{""name"":""f1"",""type"":""long""}]}},{""name"":""myE"",""type"":{""type"":""enum"",""name"":""MyEnum"",""namespace"":""com.foo"",""symbols"":[""A"",""B"",""C""]}},{""name"":""myInt2"",""type"":""int""},{""name"":""myLong2"",""type"":""long""},{""name"":""myBool2"",""type"":""boolean""},{""name"":""myDouble2"",""type"":""double""},{""name"":""myFloat2"",""type"":""float""},{""name"":""myBytes2"",""type"":""bytes""},{""name"":""myString2"",""type"":""string""},{""name" ":""myA2"",""type"":""A""},{""name"":""myE2"",""type"":""MyEnum""},{""name"":""myInt3"",""type"":""int""},{""name"":""myLong3"",""type"":""long""},{""name"":""myBool3"",""type"":""boolean""},{""name"":""myDouble3"",""type"":""double""},{""name"":""myFloat3"",""type"":""float""},{""name"":""myBytes3"",""type"":""bytes""},{""name"":""myString3"",""type"":""string""},{""name"":""myA3"",""type"":""A""},{""name"":""myE3"",""type"":""MyEnum""},{""name"":""myInt4"",""type"":""int""},{""name"":""myLong4"",""type"":""long""},{""name"":""myBool4"",""type"":""boolean""},{""name"":""myDouble4"",""type"":""double""},{""name"":""myFloat4"",""type"":""float""},{""name"":""myBytes4"",""type"":""bytes""},{""name"":""myString4"",""type"":""string""},{""name"":""myA4"",""type"":""A""},{""name"":""myE4"",""type"":""MyEnum""}]}"); + private int _myInt; + private long _myLong; + private bool _myBool; + private double _myDouble; + private float _myFloat; + private byte[] _myBytes; + private string _myString; + private com.foo.A _myA; + private com.foo.MyEnum _myE; + private int _myInt2; + private long _myLong2; + private bool _myBool2; + private double _myDouble2; + private float _myFloat2; + private byte[] _myBytes2; + private string _myString2; + private com.foo.A _myA2; + private com.foo.MyEnum _myE2; + private int _myInt3; + private long _myLong3; + private bool _myBool3; + private double _myDouble3; + private float _myFloat3; + private byte[] _myBytes3; + private string _myString3; + private com.foo.A _myA3; + private com.foo.MyEnum _myE3; + private int _myInt4; + private long _myLong4; + private bool _myBool4; + private double _myDouble4; + private float _myFloat4; + private byte[] _myBytes4; + private string _myString4; + private com.foo.A _myA4; + private com.foo.MyEnum _myE4; + public virtual Schema Schema + { + get + { + return Wide._SCHEMA; + } + } + public int myInt + { + get + { + return this._myInt; + } + set + { + this._myInt = value; + } + } + public long myLong + { + get + { + return this._myLong; + } + set + { + this._myLong = value; + } + } + public bool myBool + { + get + { + return this._myBool; + } + set + { + this._myBool = value; + } + } + public double myDouble + { + get + { + return this._myDouble; + } + set + { + this._myDouble = value; + } + } + public float myFloat + { + get + { + return this._myFloat; + } + set + { + this._myFloat = value; + } + } + public byte[] myBytes + { + get + { + return this._myBytes; + } + set + { + this._myBytes = value; + } + } + public string myString + { + get + { + return this._myString; + } + set + { + this._myString = value; + } + } + public com.foo.A myA + { + get + { + return this._myA; + } + set + { + this._myA = value; + } + } + public com.foo.MyEnum myE + { + get + { + return this._myE; + } + set + { + this._myE = value; + } + } + public int myInt2 + { + get + { + return this._myInt2; + } + set + { + this._myInt2 = value; + } + } + public long myLong2 + { + get + { + return this._myLong2; + } + set + { + this._myLong2 = value; + } + } + public bool myBool2 + { + get + { + return this._myBool2; + } + set + { + this._myBool2 = value; + } + } + public double myDouble2 + { + get + { + return this._myDouble2; + } + set + { + this._myDouble2 = value; + } + } + public float myFloat2 + { + get + { + return this._myFloat2; + } + set + { + this._myFloat2 = value; + } + } + public byte[] myBytes2 + { + get + { + return this._myBytes2; + } + set + { + this._myBytes2 = value; + } + } + public string myString2 + { + get + { + return this._myString2; + } + set + { + this._myString2 = value; + } + } + public com.foo.A myA2 + { + get + { + return this._myA2; + } + set + { + this._myA2 = value; + } + } + public com.foo.MyEnum myE2 + { + get + { + return this._myE2; + } + set + { + this._myE2 = value; + } + } + public int myInt3 + { + get + { + return this._myInt3; + } + set + { + this._myInt3 = value; + } + } + public long myLong3 + { + get + { + return this._myLong3; + } + set + { + this._myLong3 = value; + } + } + public bool myBool3 + { + get + { + return this._myBool3; + } + set + { + this._myBool3 = value; + } + } + public double myDouble3 + { + get + { + return this._myDouble3; + } + set + { + this._myDouble3 = value; + } + } + public float myFloat3 + { + get + { + return this._myFloat3; + } + set + { + this._myFloat3 = value; + } + } + public byte[] myBytes3 + { + get + { + return this._myBytes3; + } + set + { + this._myBytes3 = value; + } + } + public string myString3 + { + get + { + return this._myString3; + } + set + { + this._myString3 = value; + } + } + public com.foo.A myA3 + { + get + { + return this._myA3; + } + set + { + this._myA3 = value; + } + } + public com.foo.MyEnum myE3 + { + get + { + return this._myE3; + } + set + { + this._myE3 = value; + } + } + public int myInt4 + { + get + { + return this._myInt4; + } + set + { + this._myInt4 = value; + } + } + public long myLong4 + { + get + { + return this._myLong4; + } + set + { + this._myLong4 = value; + } + } + public bool myBool4 + { + get + { + return this._myBool4; + } + set + { + this._myBool4 = value; + } + } + public double myDouble4 + { + get + { + return this._myDouble4; + } + set + { + this._myDouble4 = value; + } + } + public float myFloat4 + { + get + { + return this._myFloat4; + } + set + { + this._myFloat4 = value; + } + } + public byte[] myBytes4 + { + get + { + return this._myBytes4; + } + set + { + this._myBytes4 = value; + } + } + public string myString4 + { + get + { + return this._myString4; + } + set + { + this._myString4 = value; + } + } + public com.foo.A myA4 + { + get + { + return this._myA4; + } + set + { + this._myA4 = value; + } + } + public com.foo.MyEnum myE4 + { + get + { + return this._myE4; + } + set + { + this._myE4 = value; + } + } + public virtual object Get(int fieldPos) + { + switch (fieldPos) + { + case 0: return this.myInt; + case 1: return this.myLong; + case 2: return this.myBool; + case 3: return this.myDouble; + case 4: return this.myFloat; + case 5: return this.myBytes; + case 6: return this.myString; + case 7: return this.myA; + case 8: return this.myE; + case 9: return this.myInt2; + case 10: return this.myLong2; + case 11: return this.myBool2; + case 12: return this.myDouble2; + case 13: return this.myFloat2; + case 14: return this.myBytes2; + case 15: return this.myString2; + case 16: return this.myA2; + case 17: return this.myE2; + case 18: return this.myInt3; + case 19: return this.myLong3; + case 20: return this.myBool3; + case 21: return this.myDouble3; + case 22: return this.myFloat3; + case 23: return this.myBytes3; + case 24: return this.myString3; + case 25: return this.myA3; + case 26: return this.myE3; + case 27: return this.myInt4; + case 28: return this.myLong4; + case 29: return this.myBool4; + case 30: return this.myDouble4; + case 31: return this.myFloat4; + case 32: return this.myBytes4; + case 33: return this.myString4; + case 34: return this.myA4; + case 35: return this.myE4; + default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()"); + }; + } + public virtual void Put(int fieldPos, object fieldValue) + { + switch (fieldPos) + { + case 0: this.myInt = (System.Int32)fieldValue; break; + case 1: this.myLong = (System.Int64)fieldValue; break; + case 2: this.myBool = (System.Boolean)fieldValue; break; + case 3: this.myDouble = (System.Double)fieldValue; break; + case 4: this.myFloat = (System.Single)fieldValue; break; + case 5: this.myBytes = (System.Byte[])fieldValue; break; + case 6: this.myString = (System.String)fieldValue; break; + case 7: this.myA = (com.foo.A)fieldValue; break; + case 8: this.myE = (com.foo.MyEnum)fieldValue; break; + case 9: this.myInt2 = (System.Int32)fieldValue; break; + case 10: this.myLong2 = (System.Int64)fieldValue; break; + case 11: this.myBool2 = (System.Boolean)fieldValue; break; + case 12: this.myDouble2 = (System.Double)fieldValue; break; + case 13: this.myFloat2 = (System.Single)fieldValue; break; + case 14: this.myBytes2 = (System.Byte[])fieldValue; break; + case 15: this.myString2 = (System.String)fieldValue; break; + case 16: this.myA2 = (com.foo.A)fieldValue; break; + case 17: this.myE2 = (com.foo.MyEnum)fieldValue; break; + case 18: this.myInt3 = (System.Int32)fieldValue; break; + case 19: this.myLong3 = (System.Int64)fieldValue; break; + case 20: this.myBool3 = (System.Boolean)fieldValue; break; + case 21: this.myDouble3 = (System.Double)fieldValue; break; + case 22: this.myFloat3 = (System.Single)fieldValue; break; + case 23: this.myBytes3 = (System.Byte[])fieldValue; break; + case 24: this.myString3 = (System.String)fieldValue; break; + case 25: this.myA3 = (com.foo.A)fieldValue; break; + case 26: this.myE3 = (com.foo.MyEnum)fieldValue; break; + case 27: this.myInt4 = (System.Int32)fieldValue; break; + case 28: this.myLong4 = (System.Int64)fieldValue; break; + case 29: this.myBool4 = (System.Boolean)fieldValue; break; + case 30: this.myDouble4 = (System.Double)fieldValue; break; + case 31: this.myFloat4 = (System.Single)fieldValue; break; + case 32: this.myBytes4 = (System.Byte[])fieldValue; break; + case 33: this.myString4 = (System.String)fieldValue; break; + case 34: this.myA4 = (com.foo.A)fieldValue; break; + case 35: this.myE4 = (com.foo.MyEnum)fieldValue; break; + default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()"); + }; + } + } +} Added: avro/trunk/lang/csharp/src/apache/perf/com/foo/newRec.cs URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/perf/com/foo/newRec.cs?rev=1540206&view=auto ============================================================================== --- avro/trunk/lang/csharp/src/apache/perf/com/foo/newRec.cs (added) +++ avro/trunk/lang/csharp/src/apache/perf/com/foo/newRec.cs Fri Nov 8 22:15:02 2013 @@ -0,0 +1,56 @@ +// ------------------------------------------------------------------------------ +// <auto-generated> +// Generated by avrogen.exe, version 0.9.0.0 +// Changes to this file may cause incorrect behavior and will be lost if code +// is regenerated +// </auto-generated> +// ------------------------------------------------------------------------------ +namespace com.foo +{ + using System; + using System.Collections.Generic; + using System.Text; + using Avro; + using Avro.Specific; + + public partial class newRec : ISpecificRecord + { + public static Schema _SCHEMA = Avro.Schema.Parse("{\"type\":\"record\",\"name\":\"newRec\",\"namespace\":\"com.foo\",\"fields\":[{\"name\":\"f1\",\"ty" + + "pe\":\"long\"}]}"); + private long _f1; + public virtual Schema Schema + { + get + { + return newRec._SCHEMA; + } + } + public long f1 + { + get + { + return this._f1; + } + set + { + this._f1 = value; + } + } + public virtual object Get(int fieldPos) + { + switch (fieldPos) + { + case 0: return this.f1; + default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()"); + }; + } + public virtual void Put(int fieldPos, object fieldValue) + { + switch (fieldPos) + { + case 0: this.f1 = (System.Int64)fieldValue; break; + default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()"); + }; + } + } +} Added: avro/trunk/lang/csharp/src/apache/perf/schema.avsc URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/perf/schema.avsc?rev=1540206&view=auto ============================================================================== --- avro/trunk/lang/csharp/src/apache/perf/schema.avsc (added) +++ avro/trunk/lang/csharp/src/apache/perf/schema.avsc Fri Nov 8 22:15:02 2013 @@ -0,0 +1,122 @@ +{ + "protocol" : "MyProtocol", + "namespace" : "com.foo", + "types" : [ + { + "type" : "record", + "name" : "A", + "fields" : [ { "name" : "f1", "type" : "long" } ] + }, + { + "type" : "enum", + "name" : "MyEnum", + "symbols" : [ "A", "B", "C" ] + }, + { + "type": "fixed", + "size": 16, + "name": "MyFixed" + }, + { + "type" : "record", + "name" : "Simple", + "fields" : + [ + { "name" : "myInt", "type" : "int" }, + { "name" : "myLong", "type" : "long" }, + { "name" : "myBool", "type" : "boolean" }, + { "name" : "myDouble", "type" : "double" }, + { "name" : "myFloat", "type" : "float" }, + { "name" : "myBytes", "type" : "bytes" }, + { "name" : "myString", "type" : "string" }, + { "name" : "myNull", "type" : "null" }, + ] + }, + { + "type" : "record", + "name" : "Complex", + "fields" : + [ + { "name" : "myUInt", "type" : [ "int", "null" ] }, + { "name" : "myULong", "type" : [ "long", "null" ] }, + { "name" : "myUBool", "type" : [ "boolean", "null" ] }, + { "name" : "myUDouble", "type" : [ "double", "null" ] }, + { "name" : "myUFloat", "type" : [ "float", "null" ] }, + { "name" : "myUBytes", "type" : [ "bytes", "null" ] }, + { "name" : "myUString", "type" : [ "string", "null" ] }, + + { "name" : "myInt", "type" : "int" }, + { "name" : "myLong", "type" : "long" }, + { "name" : "myBool", "type" : "boolean" }, + { "name" : "myDouble", "type" : "double" }, + { "name" : "myFloat", "type" : "float" }, + { "name" : "myBytes", "type" : "bytes" }, + { "name" : "myString", "type" : "string" }, + { "name" : "myNull", "type" : "null" }, + + { "name" : "myFixed", "type" : "MyFixed" }, + { "name" : "myA", "type" : "A" }, + { "name" : "myE", "type" : "MyEnum" }, + { "name" : "myArray", "type" : { "type" : "array", "items" : "bytes" } }, + { "name" : "myArray2", "type" : { "type" : "array", "items" : { "type" : "record", "name" : "newRec", "fields" : [ { "name" : "f1", "type" : "long"} ] } } }, + { "name" : "myMap", "type" : { "type" : "map", "values" : "string" } }, + { "name" : "myMap2", "type" : { "type" : "map", "values" : "newRec" } }, + { "name" : "myObject", "type" : [ "MyEnum", "A", "null" ] }, + { "name" : "myArray3", "type" : { "type" : "array", "items" : { "type" : "array", "items" : [ "double", "string", "null" ] } } } + ] + }, + { + "type" : "record", + "name" : "Wide", + "fields" : + [ + { "name" : "myInt", "type" : "int" }, + { "name" : "myLong", "type" : "long" }, + { "name" : "myBool", "type" : "boolean" }, + { "name" : "myDouble", "type" : "double" }, + { "name" : "myFloat", "type" : "float" }, + { "name" : "myBytes", "type" : "bytes" }, + { "name" : "myString", "type" : "string" }, + { "name" : "myA", "type" : "A" }, + { "name" : "myE", "type" : "MyEnum" }, + { "name" : "myInt2", "type" : "int" }, + { "name" : "myLong2", "type" : "long" }, + { "name" : "myBool2", "type" : "boolean" }, + { "name" : "myDouble2", "type" : "double" }, + { "name" : "myFloat2", "type" : "float" }, + { "name" : "myBytes2", "type" : "bytes" }, + { "name" : "myString2", "type" : "string" }, + { "name" : "myA2", "type" : "A" }, + { "name" : "myE2", "type" : "MyEnum" }, + { "name" : "myInt3", "type" : "int" }, + { "name" : "myLong3", "type" : "long" }, + { "name" : "myBool3", "type" : "boolean" }, + { "name" : "myDouble3", "type" : "double" }, + { "name" : "myFloat3", "type" : "float" }, + { "name" : "myBytes3", "type" : "bytes" }, + { "name" : "myString3", "type" : "string" }, + { "name" : "myA3", "type" : "A" }, + { "name" : "myE3", "type" : "MyEnum" }, + { "name" : "myInt4", "type" : "int" }, + { "name" : "myLong4", "type" : "long" }, + { "name" : "myBool4", "type" : "boolean" }, + { "name" : "myDouble4", "type" : "double" }, + { "name" : "myFloat4", "type" : "float" }, + { "name" : "myBytes4", "type" : "bytes" }, + { "name" : "myString4", "type" : "string" }, + { "name" : "myA4", "type" : "A" }, + { "name" : "myE4", "type" : "MyEnum" }, + ] + }, + { + "type" : "record", + "name" : "Narrow", + "fields" : + [ + { "name" : "myInt", "type" : "int" }, + { "name" : "myLong", "type" : "long" }, + { "name" : "myString", "type" : "string" } + ] + } + ] +} \ No newline at end of file Modified: avro/trunk/lang/csharp/src/apache/test/Generic/GenericTests.cs URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/test/Generic/GenericTests.cs?rev=1540206&r1=1540205&r2=1540206&view=diff ============================================================================== --- avro/trunk/lang/csharp/src/apache/test/Generic/GenericTests.cs (original) +++ avro/trunk/lang/csharp/src/apache/test/Generic/GenericTests.cs Fri Nov 8 22:15:02 2013 @@ -434,22 +434,32 @@ namespace Avro.Test.Generic long initialPos = ms.Position; GenericReader<S> r = new GenericReader<S>(ws, rs); Decoder d = new BinaryDecoder(ms); - S n = default(S); - S output = r.Read(n, d); + var items = new List<S>(); + // validate reading twice to make sure there isn't some state that isn't reset between reads. + items.Add( Read( r, d ) ); + items.Add( Read( r, d ) ); Assert.AreEqual(ms.Length, ms.Position); // Ensure we have read everything. - checkAlternateDeserializers(output, ms, initialPos, ws, rs); - return output; + checkAlternateDeserializers(items, ms, initialPos, ws, rs); + return items[0]; } - private static void checkAlternateDeserializers<S>(S expected, Stream input, long startPos, Schema ws, Schema rs) + private static S Read<S>( DatumReader<S> reader, Decoder d ) + { + S reuse = default( S ); + return reader.Read( reuse, d ); + } + + private static void checkAlternateDeserializers<S>(IEnumerable<S> expectations, Stream input, long startPos, Schema ws, Schema rs) { input.Position = startPos; var reader = new GenericDatumReader<S>(ws, rs); Decoder d = new BinaryDecoder(input); - S n = default(S); - S output = reader.Read(n, d); + foreach( var expected in expectations ) + { + var read = Read( reader, d ); + Assert.AreEqual(expected, read); + } Assert.AreEqual(input.Length, input.Position); // Ensure we have read everything. - Assert.AreEqual(expected, output); } private static void serialize<T>(string writerSchema, T actual, out Stream stream, out Schema ws) @@ -458,6 +468,8 @@ namespace Avro.Test.Generic Encoder e = new BinaryEncoder(ms); ws = Schema.Parse(writerSchema); GenericWriter<T> w = new GenericWriter<T>(ws); + // write twice so we can validate reading twice + w.Write(actual, e); w.Write(actual, e); ms.Flush(); ms.Position = 0; @@ -471,6 +483,7 @@ namespace Avro.Test.Generic var writer = new GenericDatumWriter<T>(ws); var e = new BinaryEncoder(ms); writer.Write(value, e); + writer.Write(value, e); var output = ms.ToArray(); Assert.AreEqual(expected.Length, output.Length);
