Exemplo n.º 1
0
        void WriteTail()
        {
            var metadata = _stripeWriter.GetMetadata();
            var footer   = _stripeWriter.GetFooter();

            footer.HeaderLength = (ulong)_magic.Length;

            long metadataLength, footerLength;

            _bufferFactory.SerializeAndCompressTo(_outputStream, metadata, out metadataLength);
            _bufferFactory.SerializeAndCompressTo(_outputStream, footer, out footerLength);

            var postScript       = GetPostscript((ulong)footerLength, (ulong)metadataLength);
            var postScriptStream = new MemoryStream();

            StaticProtoBuf.Serializer.Serialize(postScriptStream, postScript);
            postScriptStream.Seek(0, SeekOrigin.Begin);
            postScriptStream.CopyTo(_outputStream);

            if (postScriptStream.Length > 255)
            {
                throw new InvalidDataException("Invalid Postscript length");
            }

            _outputStream.WriteByte((byte)postScriptStream.Length);
        }
Exemplo n.º 2
0
        public static void Write <T>(System.IO.Stream outputStream, IEnumerable <T> values, out Footer footer, SerializationConfiguration serializationConfiguration = null) where T : class
        {
            var bufferFactory = new OrcCompressedBufferFactory(256 * 1024, CompressionKind.Zlib, CompressionStrategy.Size);
            var stripeWriter  = new StripeWriter(typeof(T), outputStream, false, 0.8, 18, 6, bufferFactory, 10000, 512 * 1024 * 1024, serializationConfiguration);

            stripeWriter.AddRows(values);
            stripeWriter.RowAddingCompleted();
            footer = stripeWriter.GetFooter();

            outputStream.Seek(0, SeekOrigin.Begin);
        }