Skip to main content

IBM Streams Avro integration

Project description

Overview

Provides functions for serialization and deserialization of messages in an Apache Avro format.

This package exposes the com.ibm.streamsx.avro toolkit as Python methods for use with Streaming Analytics service on IBM Cloud and IBM Streams including IBM Cloud Pak for Data.

Sample

A simple example of a Streams application that serializes and deserializes messages:

from streamsx.topology.topology import *
from streamsx.topology.schema import CommonSchema, StreamSchema
from streamsx.topology.context import submit
import streamsx.avro as avro

topo = Topology()

avro_schema = '{"type" : "record", "name" : "hw_schema", "fields" : [{"name" : "a", "type" : "string"}]}'
s = topo.source([{'a': 'Hello'}, {'a': 'World'}, {'a': '!'}]).as_json()

# convert json to avro blob
o = avro.json_to_avro(s, avro_schema)
# convert avro blob to json
res = avro.avro_to_json(o, avro_schema)
res.print()

submit('STREAMING_ANALYTICS_SERVICE', topo)
# Use for IBM Streams including IBM Cloud Pak for Data
# submit ('DISTRIBUTED', topo, cfg)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for streamsx.avro, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size streamsx.avro-1.1.0-py2.py3-none-any.whl (11.6 kB) File type Wheel Python version 3.6 Upload date Hashes View hashes
Filename, size streamsx.avro-1.1.0.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page