Apache Avro Documentation

repository·main·Indexed 25 days ago

https://github.com/apache/avro

A data serialization system providing efficient, schema-based data encoding for various programming languages. This documentation covers implementations and tools for C# (including Avro.Reflect and NuGet packages), Java (including JMH performance testing and Thrift integration), and JavaScript (avro-js).

Tokens
78.8K
Snippets
187
Records
405
Agent score
83%

What's inside Apache Avro

  1. Overview of Avro Python functionality

    main

    Avro Python is a library that implements the Avro Specification for data serialization. It provides the following core capabilities:

    • Schema Assembly: Programmatically build Avro schemas.
    • Schema Parsing: Parse Avro schemas (written in JSON) into Schema objects.
    • Binary Encoding/Decoding: Use primitive functions to encode data into Avro format and decode it back.
    • Data Streams: Provides streams for storing and reading data used by Encoders and Decoders.
    • Avro DataFile Support: Support for the Avro DataFile format.
  2. Overview of Apache Avro

    main
    Apache Avro™ is a data serialization system designed for record data and streaming data pipelines. It is characterized by its support for excellent schema evolution and provides implementations across multiple languages including the JVM (Java, Kotlin, Scala), Python, C/C++/C#, PHP, Ruby, Rust, JavaScript, and Perl.
  3. Introduction to Apache Avro

    main

    Apache Avro is a data serialization system designed for efficiency and flexibility. It provides rich data structures and a compact, fast, binary data format.

    Key features include:

    • Container Files: For storing persistent data.
    • Remote Procedure Call (RPC): For communication between systems.
    • Dynamic Language Integration: Code generation is not required to read or write data files or to use/implement RPC protocols. This makes it ideal for dynamic or scripting languages.
    • Optional Code Generation: While not required, code generation can be used as an optimization for statically typed languages.
  4. Understand Avro JavaScript Types

    main

    In avro-js, every Avro type maps to a corresponding JavaScript Type class (e.g., int maps to IntType, record to RecordType). An instance of a Type provides methods to encode and decode data, perform validity checks, and generate random data.

    Key capabilities of a Type instance:

    • Buffer Encoding/Decoding: Use toBuffer(val) to encode a value into an Avro-encoded buffer and fromBuffer(buf) to decode it back.
    • JSON Encoding/Decoding: Use toString(val) for JSON-encoded strings and fromString(jsonString) to parse them.
    • Validity Checks: Use isValid(val) to check if a JavaScript object conforms to the schema.
    • Random Generation: Use random() to generate a random value matching the type.
  5. Understand Avro Data Serialization and Deserialization

    main

    Avro binary data does not include type information or field names to minimize size. Consequently, a schema must be used to read Avro data correctly.

    To ensure successful deserialization:

    • Always include the writer's schema with the stored data.
    • In RPC systems, guarantee that recipients have the schema used to write the data.
    • For schema evolution (reading data with a newer schema), use the Schema Resolution process.
    • While it is possible to read data with a different schema if primitive values are compatible (e.g., int can be deserialized as long), it is highly recommended to use schemas with identical Parsing Canonical Forms to ensure reliability.
  6. Integrate C/C++/C# API documentation

    main

    API documentations for C, C++, and C# modules are generated by their respective build.sh dist implementations. To include these in the website, copy the generated HTML to the external documentation folder:

    cp ../avro/build/avro-doc-1.12.0-SNAPSHOT/api/c/* content/en/docs/external/c/
    ```shellncp ../avro/build/avro-doc-1.12.0-SNAPSHOT/api/c/* content/en/docs/external/c/