Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import org.openjdk.jmh.annotations._
import zio.Chunk
import zio.blocks.BaseBenchmark
import zio.blocks.schema.Schema
import zio.blocks.schema.avro.{AvroBinaryCodec, AvroFormat}
import zio.schema.codec.AvroCodec
import zio.blocks.schema.avro.{AvroCodec, AvroFormat}
import zio.schema.{DeriveSchema, Schema => ZIOSchema}
import java.io.ByteArrayOutputStream
import com.sksamuel.avro4s.{AvroSchema, AvroInputStream, AvroOutputStream}
Expand Down Expand Up @@ -78,7 +77,8 @@ object AvroListOfRecordsDomain {

implicit val zioSchema: ZIOSchema[Person] = DeriveSchema.gen[Person]

val zioSchemaCodec: AvroCodec.ExtendedBinaryCodec[List[Person]] = AvroCodec.schemaBasedBinaryCodec[List[Person]]
val zioSchemaCodec: zio.schema.codec.AvroCodec.ExtendedBinaryCodec[List[Person]] =
zio.schema.codec.AvroCodec.schemaBasedBinaryCodec[List[Person]]

val zioBlocksCodec: AvroBinaryCodec[List[Person]] = Schema.derived.deriving(AvroFormat.deriver).derive
val zioBlocksCodec: AvroCodec[List[Person]] = Schema.derived.deriving(AvroFormat.deriver).derive
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package zio.blocks.schema.avro
import org.openjdk.jmh.annotations._
import zio.blocks.BaseBenchmark
import zio.blocks.schema.{Schema, SchemaError}
import zio.blocks.schema.avro.{AvroBinaryCodec, AvroFormat}
import zio.blocks.schema.avro.{AvroCodec, AvroFormat}
import scala.compiletime.uninitialized

class AvroNestedRecordsBenchmark extends BaseBenchmark {
Expand Down Expand Up @@ -55,5 +55,5 @@ class AvroNestedRecordsBenchmark extends BaseBenchmark {
object AvroNestedRecordsBenchmark {
case class Nested(value: Int, next: Option[Nested])

val zioBlocksCodec: AvroBinaryCodec[Nested] = Schema.derived.deriving(AvroFormat.deriver).derive
val zioBlocksCodec: AvroCodec[Nested] = Schema.derived.deriving(AvroFormat.deriver).derive
}
2 changes: 1 addition & 1 deletion docs/reference/codec.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The codec system in ZIO Blocks is organized as a layered hierarchy:
Codec[DecodeInput, EncodeOutput, Value]
├── BinaryCodec[A] = Codec[ByteBuffer, ByteBuffer, A] (ByteBuffer ↔ A)
│ ├── JsonCodec[A]
│ ├── AvroBinaryCodec[A]
│ ├── AvroCodec[A]
│ ├── ToonBinaryCodec[A]
│ ├── ThriftBinaryCodec[A]
│ └── MessagePackBinaryCodec[A]
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Here's a summary of the formats currently supported by ZIO Blocks. Each format p
| `JsonFormat` | `JsonCodec[A]` | `application/json` | `zio-blocks-schema` |
| `ToonFormat` | `ToonBinaryCodec[A]` | `text/toon` | `zio-blocks-schema-toon` |
| `MessagePackFormat` | `MessagePackBinaryCodec[A]` | `application/msgpack` | `zio-blocks-schema-messagepack` |
| `AvroFormat` | `AvroBinaryCodec[A]` | `application/avro` | `zio-blocks-schema-avro` |
| `AvroFormat` | `AvroCodec[A]` | `application/avro` | `zio-blocks-schema-avro` |
| `ThriftFormat` | `ThriftBinaryCodec[A]` | `application/thrift` | `zio-blocks-schema-thrift` |

## Defining a Custom Format
Expand Down Expand Up @@ -162,7 +162,7 @@ val decoded: Either[SchemaError, Person] = codec.decode(bytes)

### Avro Schema Generation

Each `AvroBinaryCodec` exposes an `avroSchema` property containing the Apache Avro schema:
Each `AvroCodec` exposes an `avroSchema` property containing the Apache Avro schema:

```scala mdoc:compile-only
import zio.blocks.schema._
Expand Down
Loading