public void TestInitialize() { this.stringDictionary = new TableVector <string> { Vector = new Dictionary <string, VectorMember <string> >() }; this.intDictionary = new TableVector <int> { Vector = new Dictionary <int, VectorMember <int> >() }; for (int i = 0; i < 10; ++i) { this.stringDictionary.Vector[i.ToString()] = new VectorMember <string> { Key = i.ToString(), Value = Guid.NewGuid().ToString() }; this.intDictionary.Vector[i] = new VectorMember <int> { Key = i, Value = Guid.NewGuid().ToString() }; } Span <byte> buffer = new byte[1024]; var serializer = new FlatBufferSerializer(new FlatBufferSerializerOptions(FlatBufferDeserializationOption.Lazy)); int bytesWritten = serializer.Serialize(this.stringDictionary, buffer); this.stringDictionary = serializer.Parse <TableVector <string> >(buffer.Slice(0, bytesWritten).ToArray()); bytesWritten = serializer.Serialize(this.intDictionary, buffer); this.intDictionary = serializer.Parse <TableVector <int> >(buffer.Slice(0, bytesWritten).ToArray()); }
public FlatBufferVectorTests() { var originalVector = new TableVector <string> { Vector = ExpectedStringContents.ToList() }; var originalIntVector = new TableVector <int> { Vector = ExpectedIntContents.ToList() }; Span <byte> buffer = new byte[1024 * 1024]; var serializer = new FlatBufferSerializer(new FlatBufferSerializerOptions(FlatBufferDeserializationOption.Lazy)); var progressiveSerializer = new FlatBufferSerializer(new FlatBufferSerializerOptions(FlatBufferDeserializationOption.Progressive)); int bytesWritten = serializer.Serialize(originalVector, buffer); this.stringVector = serializer.Parse <TableVector <string> >(buffer.Slice(0, bytesWritten).ToArray()); this.progressiveStringVector = progressiveSerializer.Parse <TableVector <string> >(buffer.Slice(0, bytesWritten).ToArray()); bytesWritten = serializer.Serialize(originalIntVector, buffer); this.intVector = serializer.Parse <TableVector <int> >(buffer.Slice(0, bytesWritten).ToArray()); this.progressiveIntVector = progressiveSerializer.Parse <TableVector <int> >(buffer.Slice(0, bytesWritten).ToArray()); }
public void TestInitialize() { var originalVector = new TableVector { StringVector = ExpectedContents.ToList() }; Span <byte> buffer = new byte[1024]; var serializer = new FlatBufferSerializer(new FlatBufferSerializerOptions(FlatBufferDeserializationOption.Greedy)); int bytesWritten = serializer.Serialize(originalVector, buffer); this.parsedVector = serializer.Parse <TableVector>(buffer.Slice(0, bytesWritten).ToArray()); }
public IndexedVectorTests() { this.stringVectorSource = new TableVector <string> { Vector = new IndexedVector <string, VectorMember <string> >() }; this.intVectorSource = new TableVector <int> { Vector = new IndexedVector <int, VectorMember <int> >() }; this.stringKeys = new List <string>(); for (int i = 0; i < 10; ++i) { string key = i.ToString(); stringKeys.Add(key); this.stringVectorSource.Vector.AddOrReplace(new VectorMember <string> { Key = key, Value = Guid.NewGuid().ToString() }); this.intVectorSource.Vector.AddOrReplace(new VectorMember <int> { Key = i, Value = Guid.NewGuid().ToString() }); } this.stringVectorSource.Vector.Freeze(); this.intVectorSource.Vector.Freeze(); Span <byte> buffer = new byte[1024]; var serializer = new FlatBufferSerializer(new FlatBufferSerializerOptions(FlatBufferDeserializationOption.Lazy)); var progressiveSerializer = new FlatBufferSerializer(new FlatBufferSerializerOptions(FlatBufferDeserializationOption.Progressive)); int bytesWritten = serializer.Serialize(this.stringVectorSource, buffer); this.stringVectorParsed = serializer.Parse <TableVector <string> >(buffer.Slice(0, bytesWritten).ToArray()); this.stringVectorProgressive = progressiveSerializer.Parse <TableVector <string> >(buffer.Slice(0, bytesWritten).ToArray()); bytesWritten = serializer.Serialize(this.intVectorSource, buffer); this.intVectorParsed = serializer.Parse <TableVector <int> >(buffer.Slice(0, bytesWritten).ToArray()); this.intVectorProgressive = progressiveSerializer.Parse <TableVector <int> >(buffer.Slice(0, bytesWritten).ToArray()); }