void RoundTripSingleBool(int numValues)
        {
            var pocos  = new List <SingleBoolPoco>();
            var random = new Random(123);

            for (int i = 0; i < numValues; i++)
            {
                pocos.Add(new SingleBoolPoco {
                    Bool = random.Next() % 2 == 0
                });
            }

            var    stream = new MemoryStream();
            Footer footer;

            StripeStreamHelper.Write(stream, pocos, out footer);
            var stripeStreams = StripeStreamHelper.GetStripeStreams(stream, footer);
            var boolReader    = new BooleanReader(stripeStreams, 1);
            var results       = boolReader.Read().ToArray();

            for (int i = 0; i < numValues; i++)
            {
                Assert.Equal(pocos[i].Bool, results[i]);
            }
        }
        void RoundTripSingleValue(int numValues)
        {
            var pocos  = new List <SingleValuePoco>();
            var random = new Random(123);

            for (int i = 0; i < numValues; i++)
            {
                pocos.Add(new SingleValuePoco {
                    Value = (double)random.Next() / (double)random.Next()
                });
            }

            var    stream = new MemoryStream();
            Footer footer;

            StripeStreamHelper.Write(stream, pocos, out footer);
            var stripeStreams = StripeStreamHelper.GetStripeStreams(stream, footer);
            var reader        = new DoubleReader(stripeStreams, 1);
            var results       = reader.Read().ToArray();

            for (int i = 0; i < numValues; i++)
            {
                Assert.Equal(pocos[i].Value, results[i]);
            }
        }
Exemple #3
0
        void RoundTripSingleValue(int numValues)
        {
            var random = new Random(123);
            var pocos  = GenerateRandomDates(random, numValues).Select(t => new SingleValuePoco {
                Value = t
            }).ToList();

            var configuration = new SerializationConfiguration()
                                .ConfigureType <SingleValuePoco>()
                                .ConfigureProperty(x => x.Value, x => x.SerializeAsDate = true)
                                .Build();

            var    stream = new MemoryStream();
            Footer footer;

            StripeStreamHelper.Write(stream, pocos, out footer, configuration);
            var stripeStreams = StripeStreamHelper.GetStripeStreams(stream, footer);
            var reader        = new DateReader(stripeStreams, 1);
            var results       = reader.Read().ToArray();

            for (int i = 0; i < numValues; i++)
            {
                Assert.Equal(pocos[i].Value, results[i]);
            }
        }
        void RoundTripSingleValue(int numValues)
        {
            var pocos  = new List <SingleValuePoco>();
            var random = new Random(123);

            for (int i = 0; i < numValues; i++)
            {
                decimal wholePortion   = random.Next() % 99999;     //14-9
                decimal decimalPortion = random.Next() % 999999999; //9
                decimal value          = wholePortion + decimalPortion / 1000000000m;
                pocos.Add(new SingleValuePoco {
                    Value = value
                });
            }

            var configuration = new SerializationConfiguration()
                                .ConfigureType <SingleValuePoco>()
                                .ConfigureProperty(x => x.Value, x => { x.DecimalPrecision = 14; x.DecimalScale = 9; })
                                .Build();

            var    stream = new MemoryStream();
            Footer footer;

            StripeStreamHelper.Write(stream, pocos, out footer, configuration);
            var stripeStreams = StripeStreamHelper.GetStripeStreams(stream, footer);
            var reader        = new DecimalReader(stripeStreams, 1);
            var results       = reader.Read().ToArray();

            for (int i = 0; i < numValues; i++)
            {
                Assert.Equal(pocos[i].Value, results[i]);
            }
        }
        void RoundTripSingleBinary(int numValues)
        {
            var pocos  = new List <SingleBinaryPoco>();
            var random = new Random(123);

            for (int i = 0; i < numValues; i++)
            {
                var    numBytes = i % 100;
                byte[] bytes    = new byte[numBytes];
                random.NextBytes(bytes);
                pocos.Add(new SingleBinaryPoco {
                    Bytes = bytes
                });
            }

            var    stream = new MemoryStream();
            Footer footer;

            StripeStreamHelper.Write(stream, pocos, out footer);
            var stripeStreams = StripeStreamHelper.GetStripeStreams(stream, footer);
            var binaryReader  = new ApacheOrcDotNet.ColumnTypes.BinaryReader(stripeStreams, 1);
            var results       = binaryReader.Read().ToArray();

            for (int i = 0; i < numValues; i++)
            {
                Assert.True(pocos[i].Bytes.SequenceEqual(results[i]));
            }
        }
Exemple #6
0
        string[] RoundTripSingleValue(IEnumerable <SingleValuePoco> pocos)
        {
            var    stream = new MemoryStream();
            Footer footer;

            StripeStreamHelper.Write(stream, pocos, out footer);
            var stripeStreams = StripeStreamHelper.GetStripeStreams(stream, footer);
            var reader        = new ApacheOrcDotNet.ColumnTypes.StringReader(stripeStreams, 1);

            return(reader.Read().ToArray());
        }
        void RoundTripSingleValue(int numValues)
        {
            var random = new Random(123);
            var pocos  = GenerateRandomTimestamps(random, numValues).Select(t => new SingleValuePoco {
                Value = t
            }).ToList();

            var    stream = new MemoryStream();
            Footer footer;

            StripeStreamHelper.Write(stream, pocos, out footer);
            var stripeStreams = StripeStreamHelper.GetStripeStreams(stream, footer);
            var reader        = new TimestampReader(stripeStreams, 1);
            var results       = reader.Read().ToArray();

            for (int i = 0; i < numValues; i++)
            {
                Assert.Equal(pocos[i].Value, results[i]);
            }
        }
        void RoundTripNulls(int numValues)
        {
            var pocos = new List <NullableSingleValuePoco>();

            for (int i = 0; i < numValues; i++)
            {
                pocos.Add(new NullableSingleValuePoco());
            }

            var    stream = new MemoryStream();
            Footer footer;

            StripeStreamHelper.Write(stream, pocos, out footer);
            var stripeStreams = StripeStreamHelper.GetStripeStreams(stream, footer);
            var reader        = new DecimalReader(stripeStreams, 1);
            var results       = reader.Read().ToArray();

            for (int i = 0; i < numValues; i++)
            {
                Assert.Equal(pocos[i].Value, results[i]);
            }
        }