Avro relies on schemas


Schemas
Avro relies on schemas.

In computer programming, a schema (pronounced SKEE-mah) is the organization or structure for a database.

A schema is a logical database object holder. A database schema of a database system is its structure described in a formal language supported by the database management system.

Let us take example Schema in Arvo.

a simple schema example, user.avsc:

Avro schemas are defined with JSON . This facilitates implementation in languages that already have JSON libraries.

{"namespace": "example.avro",
"type": "record",
"name": "User",
"fields": [
{"name": "name", "type": "string"},
{"name": "favorite_number", "type": ["int", "null"]},
{"name": "favorite_color", "type": ["string", "null"]}
]
}

When Avro data is read, the schema used when writing it is always present. This permits each datum

datum – Computer Definition. The singular form of data; for example, one datum. It is rarely used, and data, its plural form, is commonly used for both singular and plural.

to be written with no per-value overheads, making serialization both fast and small. This also facilitates use with dynamic, scripting languages, since data, together with its schema, is fully self-describing.

When Avro data is stored in a file, its schema is stored with it, so that files may be processed later by any program. If the program reading the data expects a different schema this can be easily resolved, since both schemas are present.

When Avro is used in RPC, the client and server exchange schemas in the connection handshake. (This can be optimized so that, for most calls, no schemas are actually transmitted.) Since both client and server both have the other’s full schema, correspondence between same named fields, missing fields, extra fields, etc. can all be easily resolved.

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *