-
Notifications
You must be signed in to change notification settings - Fork 135
QuickAvroWrite
Cinchoo edited this page Feb 28, 2021
·
1 revision
To generate Avro file, use the ChoAvroWriter component to generate it. Sample below shows how to create Avro file (Emp.avro)
(Avro is binary format, sample shows the payload in JSON format for illustration purpose)
[
{
"Id":"1",
"Name":"Mark"
},
{
"Id":"2",
"Name":"Jason"
}
]
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
}
List<Employee> objs = new List<Employee>();
objs.Add(new Employee() { Id = 1, Name = "Tom" });
objs.Add(new Employee() { Id = 2, Name = "Mark" });
using (var parser = new ChoAvroWriter<Employee>("Emp.avro"))
{
parser.Write(objs);
}
using (var parser = new ChoAvroWriter("Emp.avro"))
{
Employee rec1 = new Employee();
rec1.Id = 1;
rec1.Name = "Mark";
parser.Write(item);
Employee rec1 = new Employee();
rec1.Id = 2;
rec1.Name = "Jason";
parser.Write(item);
}
©2017 Cinchoo Inc