#!/usr/bin/env python
#coding:utf-8
#Copyright (C) dirlt

# this file could be generated by mapreduce or spark.
import avro.schema
from avro.datafile import DataFileReader, DataFileWriter
from avro.io import DatumReader, DatumWriter

schema = avro.schema.parse(open("src/main/avro/event1.avsc").read())

writer = DataFileWriter(open("/tmp/events1.avro", "w"), DatumWriter(), schema)
writer.append({"event" : "request1", "id" : "12345", "timestamp" : "20150902", "details":
               [{"f1" : "abc", "f2" : "abd" }]})
writer.append({"event" : "request2", "id" : "12346", "timestamp" : "20150903", "details":
               [{"f1" : "bcd", "f2" : "bce" }]})
writer.append({"event" : "request3", "id" : "12347", "timestamp" : "20150904", "details":
               [{"f1" : "efg", "f2" : "emd" }]})
writer.close()
