diff --git a/project/GenWireFormat.scala b/project/GenWireFormat.scala index 1c0afa0f2..da09765af 100644 --- a/project/GenWireFormat.scala +++ b/project/GenWireFormat.scala @@ -29,12 +29,12 @@ object GenWireFormat { val place = dir / "scoobi" / "codegen" / "GeneratedWireFormats.scala" IO.write(place, """package com.nicta.scoobi.codegen -import com.nicta.scoobi.core.WireFormat +import com.nicta.scoobi.core.{WireFormat, LowPriorityWireFormatImplicits} import java.io._ object GeneratedWireFormats extends GeneratedWireFormats -trait GeneratedWireFormats { +trait GeneratedWireFormats extends LowPriorityWireFormatImplicits { """ + gen_section_1(22) + "\n\n" + gen_section_2(22) + "\n}") Seq(place) diff --git a/src/main/scala/com/nicta/scoobi/core/WireFormat.scala b/src/main/scala/com/nicta/scoobi/core/WireFormat.scala index f3f7920e1..48a7c4a10 100644 --- a/src/main/scala/com/nicta/scoobi/core/WireFormat.scala +++ b/src/main/scala/com/nicta/scoobi/core/WireFormat.scala @@ -110,8 +110,10 @@ object WireFormat extends WireFormatImplicits { // Deprioritize expensive implicits to improve compile times. // See comments in `LowPriorityAvroSchemaImplicits`. +// +// Extended by `GeneratedWireFormats` trait LowPriorityWireFormatImplicits { - self: WireFormatImplicits => + import WireFormat._ /** * Traversable structures @@ -260,7 +262,7 @@ trait LowPriorityWireFormatImplicits { } /** Implicit definitions of WireFormat instances for common types. */ -trait WireFormatImplicits extends LowPriorityWireFormatImplicits with codegen.GeneratedWireFormats { +trait WireFormatImplicits extends codegen.GeneratedWireFormats { class ObjectWireFormat[T : Manifest](val x: T) extends WireFormat[T] { override def toWire(obj: T, out: DataOutput) {} diff --git a/src/main/scala/com/nicta/scoobi/io/avro/AvroSchema.scala b/src/main/scala/com/nicta/scoobi/io/avro/AvroSchema.scala index e9203eeb6..824d45bf5 100644 --- a/src/main/scala/com/nicta/scoobi/io/avro/AvroSchema.scala +++ b/src/main/scala/com/nicta/scoobi/io/avro/AvroSchema.scala @@ -67,8 +67,8 @@ trait AvroFixed[T] { // even if one of these was found to be eligible, it would be deemed lower priority // by the subclass rule of static overload resolution. // -// These changes, together with corresponding changes in `WireFormat`, leads to a 2x -// speedup (2600ms ~> 1300ms) in compiling a benchmark: +// These changes, together with corresponding changes in `WireFormat`, leads to a 3.5x +// speedup (2600ms ~> 740ms) in compiling a benchmark: // https://gist.github.com/retronym/fdef5a41c8e1e31124a4 // // The goal is the reduce the number of lines like the following under `-Xlog-implicits` @@ -193,6 +193,10 @@ object AvroSchema extends LowPriorityAvroSchemaImplicits { def toAvro(x: String): String = x } + // redundant, but better for performance to have this here rather than forcing + // this common implicit serach to go through TraversableSchema. + implicit def SeqSchema[T](implicit sch: AvroSchema[T]): AvroSchema[Seq[T]] = TraversableSchema[Seq, T] + /* AvroSchema type class instance for Arrays. */ implicit def ArraySchema[T](implicit mf: Manifest[T], sch: AvroSchema[T]) = new AvroSchema[Array[T]] { type AvroType = GenericData.Array[sch.AvroType]