Skip to content

Adikteev/node-avro-io

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

  • pending: should allow for self references that are defined later

About

Node JS Avro implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 97.7%
  • Makefile 1.4%
  • Shell 0.9%