-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Avro - toJson should work exactly as toBinary #256
Avro - toJson should work exactly as toBinary #256
Conversation
val klass = classTag[T].runtimeClass.asInstanceOf[Class[T]] | ||
val writer = new SpecificDatumWriter[T](klass) | ||
val reader = new SpecificDatumReader[T](klass) | ||
def toJson[T <: SpecificRecordBase: ClassTag]: Injection[T, String] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a new method name and not break binary compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it's what I suggested when we changed toBinary
, but you guys decided it was unnecessary. I'll update the PR.
We since added a binary compatibility check to CI and changed the process
|
Makes sense. Is the updated PR not binary compatible? Edit: Ah I think there's a formatting error, but I'm not sure what it is. |
Failed the scala format test. Can you run sbt scalafmt and commit the changes? |
Current coverage is 66.14% (diff: 100%)@@ develop #256 diff @@
==========================================
Files 50 50
Lines 1394 1397 +3
Methods 1363 1347 -16
Messages 0 0
Branches 31 50 +19
==========================================
+ Hits 921 924 +3
Misses 473 473
Partials 0 0
|
Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can, let's remove the ClassTag
on the toBinary
. If I'm missing something, let's add a comment and leave it.
Thanks for updating the PR!
} | ||
|
||
/** | ||
* Returns Injection capable of serializing and deserializing a generic avro record using org.apache.avro.io.JsonEncoder to a | ||
* UTF-8 String | ||
* @tparam T compiled Avro record | ||
* @param schema The record's schema | ||
* @return Injection | ||
*/ | ||
def toJson[T <: SpecificRecordBase: ClassTag](schema: Schema): Injection[T, String] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd live to remove the ClassTag
here if possible, but that would be a binary incompatible break, so we can leave it as a TODO for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I added a todo.
* @param schema The record's schema | ||
* @return Injection | ||
*/ | ||
def toBinary[T <: SpecificRecordBase: ClassTag](schema: Schema): Injection[T, Array[Byte]] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this actually use the ClassTag
? I don't see where. If not, since we already dropped it in a previous version, why not correct that issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, done!
…ted Scala case classes as specific records
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
All checks successful, merge away ;) |
Thank you! |
Adapt
toJson
to work similarly astoBinary
in order to support generated Scala case classes as specific records.