private void WriteFooter(Schema schema) { Builder.Clear(); long offset = BaseStream.Position; // Serialize the schema FlatBuffers.Offset <Flatbuf.Schema> schemaOffset = SerializeSchema(schema); // Serialize all record batches Flatbuf.Footer.StartRecordBatchesVector(Builder, RecordBatchBlocks.Count); // flatbuffer struct vectors have to be created in reverse order for (int i = RecordBatchBlocks.Count - 1; i >= 0; i--) { Block recordBatch = RecordBatchBlocks[i]; Flatbuf.Block.CreateBlock( Builder, recordBatch.Offset, recordBatch.MetadataLength, recordBatch.BodyLength); } FlatBuffers.VectorOffset recordBatchesVectorOffset = Builder.EndVector(); // Serialize all dictionaries // NOTE: Currently unsupported. Flatbuf.Footer.StartDictionariesVector(Builder, 0); FlatBuffers.VectorOffset dictionaryBatchesOffset = Builder.EndVector(); // Serialize and write the footer flatbuffer FlatBuffers.Offset <Flatbuf.Footer> footerOffset = Flatbuf.Footer.CreateFooter(Builder, CurrentMetadataVersion, schemaOffset, dictionaryBatchesOffset, recordBatchesVectorOffset); Builder.Finish(footerOffset.Value); WriteFlatBuffer(); // Write footer length Buffers.RentReturn(4, (buffer) => { int footerLength; checked { footerLength = (int)(BaseStream.Position - offset); } BinaryPrimitives.WriteInt32LittleEndian(buffer.Span, footerLength); BaseStream.Write(buffer); }); // Write magic WriteMagic(); }
static StackObject *AssignFromStack_Value_0(ref object o, ILIntepreter __intp, StackObject *ptr_of_this_method, IList <object> __mStack) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; System.Int32 @Value = ptr_of_this_method->Value; FlatBuffers.VectorOffset ins = (FlatBuffers.VectorOffset)o; ins.Value = @Value; o = ins; return(ptr_of_this_method); }
static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref FlatBuffers.VectorOffset instance_of_this_method) { ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.Object: { __mStack[ptr_of_this_method->Value] = instance_of_this_method; } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { var t = __domain.GetType(___obj.GetType()) as CLRType; t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method); } } break; case ObjectTypes.StaticFieldReference: { var t = __domain.GetType(ptr_of_this_method->Value); if (t is ILType) { ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as FlatBuffers.VectorOffset[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; } break; } }
private async Task WriteFooterAsync(Schema schema, CancellationToken cancellationToken) { Builder.Clear(); long offset = BaseStream.Position; // Serialize the schema FlatBuffers.Offset <Flatbuf.Schema> schemaOffset = SerializeSchema(schema); // Serialize all record batches Flatbuf.Footer.StartRecordBatchesVector(Builder, RecordBatchBlocks.Count); foreach (Block recordBatch in RecordBatchBlocks) { Flatbuf.Block.CreateBlock( Builder, recordBatch.Offset, recordBatch.MetadataLength, recordBatch.BodyLength); } FlatBuffers.VectorOffset recordBatchesVectorOffset = Builder.EndVector(); // Serialize all dictionaries // NOTE: Currently unsupported. Flatbuf.Footer.StartDictionariesVector(Builder, 0); FlatBuffers.VectorOffset dictionaryBatchesOffset = Builder.EndVector(); // Serialize and write the footer flatbuffer FlatBuffers.Offset <Flatbuf.Footer> footerOffset = Flatbuf.Footer.CreateFooter(Builder, CurrentMetadataVersion, schemaOffset, dictionaryBatchesOffset, recordBatchesVectorOffset); Builder.Finish(footerOffset.Value); cancellationToken.ThrowIfCancellationRequested(); await WriteFlatBufferAsync(cancellationToken).ConfigureAwait(false); // Write footer length cancellationToken.ThrowIfCancellationRequested(); await Buffers.RentReturnAsync(4, async (buffer) => { int footerLength; checked { footerLength = (int)(BaseStream.Position - offset); } BinaryPrimitives.WriteInt32LittleEndian(buffer.Span, footerLength); await BaseStream.WriteAsync(buffer, cancellationToken).ConfigureAwait(false); }).ConfigureAwait(false); // Write magic await WriteMagicAsync(cancellationToken).ConfigureAwait(false); }
static void set_Value_0(ref object o, object v) { FlatBuffers.VectorOffset ins = (FlatBuffers.VectorOffset)o; ins.Value = (System.Int32)v; o = ins; }