Created
October 26, 2018 08:44
Revisions
-
AndyCross created this gist
Oct 26, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ using System; using System.IO; using System.Linq; using Parquet; namespace parquetdemo { public class SimpleStructure { public int Id { get; set; } public string Name { get; set; } public DateTimeOffset FutureDate { get; set;} public double SomeNumeric { get; set; } public int? MaybeAnInt { get; set; } } class Program { static readonly string _parquetPath = Path.Combine(Environment.CurrentDirectory, "data", "myParquetFile.parquet"); static void Main(string[] args) { SimpleStructure[] structures = Enumerable .Range(0, 1000) .Select(i => new SimpleStructure { Id = i, Name = $"row {i}", FutureDate = DateTime.UtcNow.AddDays(i), SomeNumeric = 1D/i, MaybeAnInt = (i % 44 == 0) ? (Nullable<int>)i : null }) .ToArray(); using (FileStream stream = File.Create(_parquetPath)) { ParquetConvert.Serialize(structures, stream); } using (FileStream stream = File.OpenRead(_parquetPath)) { structures = ParquetConvert.Deserialize<SimpleStructure>(stream); Console.WriteLine($"Roundtrip completed on {structures.Length} rows"); } } } }