Skip to content

Instantly share code, notes, and snippets.

@tebeka
Created May 12, 2011 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tebeka/967968 to your computer and use it in GitHub Desktop.
Save tebeka/967968 to your computer and use it in GitHub Desktop.
Counting records in Avro file
#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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment