public
Last active

Counting records in Avro file

  • Download Gist
gistfile1.c
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#include <stdio.h>
#include <avro.h>
#include <stdlib.h>
 
int
main(int argc, char *argv[]) {
if (argc != 2) {
fprintf(stderr, "usage: reader FILENAME\n");
exit(1);
}
 
avro_file_reader_t reader;
avro_datum_t datum;
if (avro_file_reader(argv[1], &reader) != 0) {
fprintf(stderr, "error: can't open");
exit(1);
}
 
int count = 0;
for (; avro_file_reader_read(reader, NULL, &datum) == 0; count++) {
}
avro_file_reader_close(reader);
 
printf("%d\n", count);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.