jamesbrucepower/node-avro-io


Node JS Avro implementation

Language: JavaScript


Node Avro IO

Build Status

Implements the avro spec

This status of this repository is initial release

npm install node-avro-io

or

npm install git://github.com/jamesbrucepower/node-avro-io.git

Serializing data to an avro binary file

var avro = require('./index').DataFile.AvroFile();
var schema = {
            "name": "data",
            "type": "record",
            "fields": [
                {"name":"key","type": "string"},
                {"name":"value","type": "string"},
                {"name":"flag","type": "boolean"},
                {"name":"subrecord","type":"record","fields":[
                    {"name":"key","type":"string"},
                    {"name":"value","type":["string","int","null"]}
                ]}
            ]
};
var writer = avro.open("test.avro", schema, { flags: 'w', codec: 'deflate' });
writer
    .append({ key:"john", value:"hive", flag: true, subrecord: { key: "preference", value: 2}})
    .append({ key:"eric", value:"lola", flag: true, subrecord: { key: "postcode", value: null}})
    .end({ key:"fred", value:"wonka", flag: false, subrecord: { key: "city", value: "michigan"}});

Deserializing data to from avro binary file

require("./index").DataFile.AvroFile()
	.open('test.avro', null, { flags: 'r' })
		.on('data', function(data) {
	  		console.log(data);
		});

See tests for more usage examples

TODO:

  • Avro RPC
  • Support for Trevni (column major data serialization)

Project Statistics

Sourcerank 6
Repository Size 12 MB
Stars 27
Forks 28
Watchers 8
Open issues 11
Dependencies 10
Contributors 9
Tags 1
Created
Last updated
Last pushed

Top Contributors See all

James Power Jeremiah Lu Matt Lavin Austin Kelleher Martin Cizek Greg Byram andrewaustin Hannes Stockner Xander Dumaine

Packages Referencing this Repo

node-avro-io
This will allow you to encode / decode avro binary format to / from json format, it supports both...
Latest release 2.0.0 - Updated - 27 stars

Recent Tags See all

v1.0.1 April 10, 2017

Interesting Forks See all

thecsyco/node-avro-io
Node JS Avro implementation
JavaScript - Last pushed - 2 stars - 1 forks

Something wrong with this page? Make a suggestion

Last synced: 2019-01-07 20:03:34 UTC

Login to resync this repository