From b7703993b4a26626d4488e37dbd3a9ad6894a4b0 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Mon, 13 May 2024 16:15:50 +0530 Subject: [PATCH 1/6] Update spec to add `byte` support --- docs/spec/spec.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/spec/spec.md b/docs/spec/spec.md index 73c8bce..ccd4afd 100644 --- a/docs/spec/spec.md +++ b/docs/spec/spec.md @@ -25,7 +25,7 @@ The conforming implementation of the specification is released and included in t * 3.1 [The `toAvro` API](#31-the-toavro-api) * 3.1.1 [API Parameters](#311-api-parameters) * 3.1.1.1 [The `data` Parameter](#3111-the-data-parameter) - * 3.1.1.1.1 [Accepted Ballerina types](#31111-accepted-ballerina-types) + * 3.1.1.1.1 [Map Avro types to Ballerina Types](#31111-map-avro-types-to-ballerina-types) * 3.1.2 [Return type](#312-return-type) 4. [Deserialize bytes to a specific Ballerina type](#4-deserialize-bytes-to-a-specific-ballerina-type) * 4.1 [The `fromAvro` API](#41-the-fromavro-api) @@ -74,11 +74,23 @@ byte[] serializedData = check schema.toAvro("avro-data"); The `data` parameter accepts the following Ballerina data types that is needed to be serialized into `byte` array. -###### 3.1.1.1.1 Accepted Ballerina types - -* `json` -* `enum` -* `record` +###### 3.1.1.1.1 Map Avro types to Ballerina Types + +The following table summarizes how Avro types are mapped to corresponding Ballerina types. These rules are applicable when a Ballerina data is serialized/deserialized according to an Avro schema. + +| Avro Type | Ballerina Type | Example | +|--------------|----------------|-----------------------------------------------| +| null | nil | () | +| boolean | boolean | true | +| int,long | int | 1 | +| float,double | float | 1.1 | +| bytes | byte[] | "000FFF".toBytes() | +| string | string | "foo" | +| record | record | type Student record { string name; int age; } | +| enum | enum | enum Color { RED, GREEN, BLUE } | +| array | array | [1,2,3,4,5] | +| map | map | {"a": 1} | +| fixed | byte[] | "000FFFF".toBytes() | #### 3.1.2 Return type From 76714aaf940c571bc467f91c733b6251f44d43ce Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Mon, 13 May 2024 16:20:54 +0530 Subject: [PATCH 2/6] [Automated] Update the native jar versions --- ballerina/Ballerina.toml | 6 +++--- ballerina/Dependencies.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 1d79af3..fb05e2b 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerina" name = "avro" -version = "0.1.3" +version = "1.0.0" authors = ["Ballerina"] export=["avro"] keywords = ["avro", "serialization", "deserialization", "serdes"] @@ -18,8 +18,8 @@ graalvmCompatible = true [[platform.java17.dependency]] groupId = "io.ballerina.lib" artifactId = "avro-native" -version = "0.1.3" -path = "../native/build/libs/avro-native-0.1.3-SNAPSHOT.jar" +version = "1.0.0" +path = "../native/build/libs/avro-native-1.0.0-SNAPSHOT.jar" [[platform.java17.dependency]] groupId = "org.apache.avro" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 02a1600..e770f53 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -10,7 +10,7 @@ distribution-version = "2201.9.0" [[package]] org = "ballerina" name = "avro" -version = "0.1.3" +version = "1.0.0" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, From 5f0400921dff85c7d42124e07af99d6839998c87 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Mon, 13 May 2024 16:27:32 +0530 Subject: [PATCH 3/6] Update the changelog with the byte support feature --- changelog.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 changelog.md diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..cdf13c9 --- /dev/null +++ b/changelog.md @@ -0,0 +1,12 @@ +# Change Log + +This file contains all the notable changes done to the Ballerina Avro package through the releases. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to +[Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.0.0] - 2024-05-13 + +### Added + +- [[#6463] Introduce `byte` support to Avro module](https://github.com/ballerina-platform/ballerina-library/issues/6463) From fc09f8135640f4b4f6b72693a54414771718a4ae Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Mon, 13 May 2024 16:28:01 +0530 Subject: [PATCH 4/6] Update the package version to 1.0.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 81030da..16d3c85 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.caching=true group=io.ballerina.lib -version=0.1.3-SNAPSHOT +version=1.0.0-SNAPSHOT ballerinaLangVersion=2201.9.0 checkstylePluginVersion=10.12.0 From 86dd64bc3b2da15310795e290cb6131bad76f1ef Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Mon, 13 May 2024 16:33:09 +0530 Subject: [PATCH 5/6] Update the description of the type mapping in the spec --- docs/spec/spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/spec/spec.md b/docs/spec/spec.md index ccd4afd..fd6602c 100644 --- a/docs/spec/spec.md +++ b/docs/spec/spec.md @@ -76,7 +76,7 @@ The `data` parameter accepts the following Ballerina data types that is needed t ###### 3.1.1.1.1 Map Avro types to Ballerina Types -The following table summarizes how Avro types are mapped to corresponding Ballerina types. These rules are applicable when a Ballerina data is serialized/deserialized according to an Avro schema. +The following table summarizes how Avro types are mapped to corresponding Ballerina types. These rules are applicable when serializing/deserializing Ballerina data according to an Avro schema. | Avro Type | Ballerina Type | Example | |--------------|----------------|-----------------------------------------------| From 7285e1d507e4a10fdfa9bf54e08b4cc8e536d3f0 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Mon, 13 May 2024 17:12:25 +0530 Subject: [PATCH 6/6] Apply the review suggestions in the spec --- docs/spec/spec.md | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/spec/spec.md b/docs/spec/spec.md index fd6602c..b8a9a03 100644 --- a/docs/spec/spec.md +++ b/docs/spec/spec.md @@ -78,19 +78,23 @@ The `data` parameter accepts the following Ballerina data types that is needed t The following table summarizes how Avro types are mapped to corresponding Ballerina types. These rules are applicable when serializing/deserializing Ballerina data according to an Avro schema. -| Avro Type | Ballerina Type | Example | -|--------------|----------------|-----------------------------------------------| -| null | nil | () | -| boolean | boolean | true | -| int,long | int | 1 | -| float,double | float | 1.1 | -| bytes | byte[] | "000FFF".toBytes() | -| string | string | "foo" | -| record | record | type Student record { string name; int age; } | -| enum | enum | enum Color { RED, GREEN, BLUE } | -| array | array | [1,2,3,4,5] | -| map | map | {"a": 1} | -| fixed | byte[] | "000FFFF".toBytes() | +| Avro Type | Ballerina Type | +|--------------|----------------| +| null | nil | +| boolean | boolean | +| int,long | int | +| float,double | float | +| bytes | byte[] | +| string | string | +| record | record | +| enum | enum | +| array | array | +| map | map | +| fixed | byte[] | + +>**Note:** The Ballerina [`int`](https://ballerina.io/spec/lang/2023R1/#section_5.2.3) type can represent integers up to 64 bits in size using the two's complement representation. Therefore, it can handle both `int` (32-bit signed integer) and `long` (64-bit signed integer) Avro types. + +>**Note:** The Ballerina [`float`](https://ballerina.io/spec/lang/2023R1/#section_5.2.4.1) type supports the IEEE 754-2008 64-bit binary (radix 2) floating-point number standard. Therefore, it can handle both `float` (32-bit single precision IEEE 754 floating-point number) and `double` (64-bit double precision IEEE 754 floating-point number) Avro types. #### 3.1.2 Return type