Created
January 28, 2016 18:37
-
-
Save jmcguirk/d7705f6b92ea4c57c045 to your computer and use it in GitHub Desktop.
FlatBuffers caching proof of concept
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Reference" :{ | |
"TestValue": "A" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// automatically generated, do not modify | |
namespace TestData | |
{ | |
using System; | |
using FlatBuffers; | |
public partial class AnotherTable : Table { | |
public static AnotherTable GetRootAsAnotherTable(ByteBuffer _bb) { return GetRootAsAnotherTable(_bb, new AnotherTable()); } | |
public static AnotherTable GetRootAsAnotherTable(ByteBuffer _bb, AnotherTable obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); } | |
public AnotherTable __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | |
public string TestValue { get { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } } | |
public ArraySegment<byte>? GetTestValueBytes() { return __vector_as_arraysegment(4); } | |
public static Offset<AnotherTable> CreateAnotherTable(FlatBufferBuilder builder, | |
StringOffset TestValueOffset = default(StringOffset)) { | |
builder.StartObject(1); | |
AnotherTable.AddTestValue(builder, TestValueOffset); | |
return AnotherTable.EndAnotherTable(builder); | |
} | |
public static void StartAnotherTable(FlatBufferBuilder builder) { builder.StartObject(1); } | |
public static void AddTestValue(FlatBufferBuilder builder, StringOffset TestValueOffset) { builder.AddOffset(0, TestValueOffset.Value, 0); } | |
public static Offset<AnotherTable> EndAnotherTable(FlatBufferBuilder builder) { | |
int o = builder.EndObject(); | |
return new Offset<AnotherTable>(o); | |
} | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Reference" :{ | |
"TestValue": "B" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// automatically generated, do not modify | |
namespace TestData | |
{ | |
using System; | |
using FlatBuffers; | |
public partial class Container : Table { | |
public static Container GetRootAsContainer(ByteBuffer _bb) { return GetRootAsContainer(_bb, new Container()); } | |
public static Container GetRootAsContainer(ByteBuffer _bb, Container obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); } | |
public static bool ContainerBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "TEST"); } | |
public Container __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | |
protected AnotherTable m_Reference; | |
public AnotherTable Reference { get { if( m_Reference==null){ m_Reference = GetReference(new AnotherTable()); }return m_Reference;}} | |
public AnotherTable GetReference(AnotherTable obj) { int o = __offset(4); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; } | |
public static Offset<Container> CreateContainer(FlatBufferBuilder builder, | |
Offset<AnotherTable> ReferenceOffset = default(Offset<AnotherTable>)) { | |
builder.StartObject(1); | |
Container.AddReference(builder, ReferenceOffset); | |
return Container.EndContainer(builder); | |
} | |
public static void StartContainer(FlatBufferBuilder builder) { builder.StartObject(1); } | |
public static void AddReference(FlatBufferBuilder builder, Offset<AnotherTable> ReferenceOffset) { builder.AddOffset(0, ReferenceOffset.Value, 0); } | |
public static Offset<Container> EndContainer(FlatBufferBuilder builder) { | |
int o = builder.EndObject(); | |
return new Offset<Container>(o); | |
} | |
public static void FinishContainerBuffer(FlatBufferBuilder builder, Offset<Container> offset) { builder.Finish(offset.Value, "TEST"); } | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reference test value for object A is A | |
Reference Equality check on object A True | |
Reference test value for object B is B | |
Reference Equality check on object B True | |
Double check reference test value for object A is A | |
Equality cross check False | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TestData; | |
table Container{ | |
Reference:AnotherTable; | |
} | |
table AnotherTable{ | |
TestValue:string; | |
} | |
root_type Container; | |
file_identifier "TEST"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment