AvroPrism

dev.constructive.eo.avro.AvroPrism
See theAvroPrism companion class
object AvroPrism

Attributes

Companion
class
Source
AvroPrism.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
AvroPrism.type

Members list

Value members

Concrete methods

def codecPrism[S](using codec: AvroCodec[S]): AvroPrism[S]

Root AvroPrism[S], summoning the schema from the codec (AvroCodec[S].schema). The reader schema always matches the codec's — there is no explicit-schema overload, since a reader schema diverging from its codec is a footgun (silent misreads on structural drift).

Root AvroPrism[S], summoning the schema from the codec (AvroCodec[S].schema). The reader schema always matches the codec's — there is no explicit-schema overload, since a reader schema diverging from its codec is a footgun (silent misreads on structural drift).

Attributes

Source
AvroPrism.scala

Extensions

Extensions

extension [A](o: AvroPrism[A])
transparent inline def field[B](inline selector: A => B)(using codecB: AvroCodec[B]): AvroPrism[B]

.field(_.x) — drill via selector lambda.

.field(_.x) — drill via selector lambda.

Attributes

Source
AvroPrism.scala
extension [A](o: AvroPrism[A])
def fieldNamed[B](schemaName: String)(using codecB: AvroCodec[B]): AvroPrism[B]

.fieldNamed[B]("schema_name") — drill by the EXPLICIT schema field name, bypassing resolution entirely. The escape hatch for a hand-written codec the resolver cannot read (a field list that both renames beyond recognition and reorders, a column bearing another field's name, two columns normalising alike); the common (derived / order-preserving / name-transformed) codecs need .field(_.x) instead, which resolves the name for you.

.fieldNamed[B]("schema_name") — drill by the EXPLICIT schema field name, bypassing resolution entirely. The escape hatch for a hand-written codec the resolver cannot read (a field list that both renames beyond recognition and reorders, a column bearing another field's name, two columns normalising alike); the common (derived / order-preserving / name-transformed) codecs need .field(_.x) instead, which resolves the name for you.

The name is CHECKED against the schema it will be looked up in, at construction (issue #95): a name the record does not carry throws rather than Missing silently at runtime. A MAP parent is carved out — .fieldNamed is also how a map KEY is addressed, and an absent key is data, not a mistake. To feature-detect a RECORD field, ask the schema: codec.schema.getField(name).

Attributes

Source
AvroPrism.scala
extension [A](o: AvroPrism[A])
transparent inline def at(i: Int): Any

.at(i) — drill into the i-th array element / map entry.

.at(i) — drill into the i-th array element / map entry.

Attributes

Source
AvroPrism.scala
extension [A](o: AvroPrism[A])
transparent inline def union[Branch]: Any

.union[Branch] — drill into a union alternative by branch type.

.union[Branch] — drill into a union alternative by branch type.

Attributes

Source
AvroPrism.scala
extension [A](o: AvroPrism[A])
transparent inline def each: Any

.each — split into an AvroTraversal over the iterated array.

.each — split into an AvroTraversal over the iterated array.

Attributes

Source
AvroPrism.scala
extension [A](o: AvroPrism[A])
transparent inline def fields(inline selectors: A => Any*): Any

.fields(_.a, _.b, ...) — focus a NamedTuple over selected fields.

.fields(_.a, _.b, ...) — focus a NamedTuple over selected fields.

The AvroCodec for the synthesised NamedTuple is summoned at the call site; with no hand-written given in scope it auto-derives through kindlings. The 22-selector ceiling is gone: up to 22 selectors the focus is spelled TupleN and hearth builds it with that tuple's constructor; at 23 and above the focus type IS a *: cons chain, which hearth ≥ 0.4.2 builds through Tuple.fromArray instead. (Both spellings are needed — hearth's constructor branch below 23 cannot build a cons chain, and there is no TupleN above 22.)

That is not the same as "unbounded". .fields selects from a case class, so '''254 selectors is a hard, permanent ceiling''' — the JVM caps a parameter list at 254 slots and a 255-field case class does not compile at all. Well below that, the binding limit is the compiler thread's stack, because the derivation recurses per field: measured, -Xss1m (the JVM default) tops out around 32 selectors, -Xss4m around 150, and -Xss8m — what this repo's .jvmopts sets — reaches 254. A downstream build gets none of that automatically, so raise -Xss there before concluding a cover is too wide. Compile time is the third cost: the derivation grows superlinearly in arity, so a wide cover may also want a higher -Xmacro-settings:avroDerivation.timeout=30s — the unit suffix is required, a bare integer is silently ignored. (Issue #96.)

Attributes

Source
AvroPrism.scala