New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avro - toJson should work exactly as toBinary #256

Merged
merged 1 commit into from Sep 27, 2016

Conversation

Projects
None yet
3 participants
@mariussoutier
Contributor

mariussoutier commented Sep 20, 2016

Adapt toJson to work similarly as toBinary in order to support generated Scala case classes as specific records.

Show outdated Hide outdated bijection-avro/src/main/scala/com/twitter/bijection/avro/AvroCodecs.scala
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] = {

This comment has been minimized.

@johnynek

johnynek Sep 23, 2016

Collaborator

can we add a new method name and not break binary compatibility?

@johnynek

johnynek Sep 23, 2016

Collaborator

can we add a new method name and not break binary compatibility?

This comment has been minimized.

@mariussoutier

mariussoutier Sep 24, 2016

Contributor

Sure, it's what I suggested when we changed toBinary, but you guys decided it was unnecessary. I'll update the PR.

@mariussoutier

mariussoutier Sep 24, 2016

Contributor

Sure, it's what I suggested when we changed toBinary, but you guys decided it was unnecessary. I'll update the PR.

@johnynek

This comment has been minimized.

Show comment
Hide comment
@johnynek

johnynek Sep 24, 2016

Collaborator

We since added a binary compatibility check to CI and changed the process
for publishing when that check fails. Sorry for the hassle.
On Sat, Sep 24, 2016 at 03:19 Marius Soutier notifications@github.com
wrote:

@mariussoutier commented on this pull request.

In
bijection-avro/src/main/scala/com/twitter/bijection/avro/AvroCodecs.scala
#256:

@@ -121,10 +121,11 @@ object SpecificAvroCodecs {
* @tparam T compiled Avro record
* @return Injection
*/

  • def toJson[T <: SpecificRecordBase: ClassTag](schema: Schema): Injection[T, String] = {
  • val klass = classTag[T].runtimeClass.asInstanceOf[Class[T]]
  • val writer = new SpecificDatumWriterT
  • val reader = new SpecificDatumReaderT
  • def toJson[T <: SpecificRecordBase: ClassTag]: Injection[T, String] = {

Sure, it's what I suggested when we changed toBinary, but you guys
decided it was unnecessary. I'll update the PR.


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#256, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEJdtgope7S0Gfqsvpdz3NigV8MSek4ks5qtPkigaJpZM4KCG5w
.

Collaborator

johnynek commented Sep 24, 2016

We since added a binary compatibility check to CI and changed the process
for publishing when that check fails. Sorry for the hassle.
On Sat, Sep 24, 2016 at 03:19 Marius Soutier notifications@github.com
wrote:

@mariussoutier commented on this pull request.

In
bijection-avro/src/main/scala/com/twitter/bijection/avro/AvroCodecs.scala
#256:

@@ -121,10 +121,11 @@ object SpecificAvroCodecs {
* @tparam T compiled Avro record
* @return Injection
*/

  • def toJson[T <: SpecificRecordBase: ClassTag](schema: Schema): Injection[T, String] = {
  • val klass = classTag[T].runtimeClass.asInstanceOf[Class[T]]
  • val writer = new SpecificDatumWriterT
  • val reader = new SpecificDatumReaderT
  • def toJson[T <: SpecificRecordBase: ClassTag]: Injection[T, String] = {

Sure, it's what I suggested when we changed toBinary, but you guys
decided it was unnecessary. I'll update the PR.


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#256, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEJdtgope7S0Gfqsvpdz3NigV8MSek4ks5qtPkigaJpZM4KCG5w
.

@mariussoutier

This comment has been minimized.

Show comment
Hide comment
@mariussoutier

mariussoutier Sep 24, 2016

Contributor

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.

Contributor

mariussoutier commented Sep 24, 2016

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.

@johnynek

This comment has been minimized.

Show comment
Hide comment
@johnynek

johnynek Sep 24, 2016

Collaborator

Failed the scala format test. Can you run sbt scalafmt and commit the changes?

Collaborator

johnynek commented Sep 24, 2016

Failed the scala format test. Can you run sbt scalafmt and commit the changes?

@codecov-io

This comment has been minimized.

Show comment
Hide comment
@codecov-io

codecov-io Sep 24, 2016

Current coverage is 66.14% (diff: 100%)

Merging #256 into develop will increase coverage by 0.07%

@@            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          

Powered by Codecov. Last update b68dd06...d0ba2c3

codecov-io commented Sep 24, 2016

Current coverage is 66.14% (diff: 100%)

Merging #256 into develop will increase coverage by 0.07%

@@            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          

Powered by Codecov. Last update b68dd06...d0ba2c3

@mariussoutier

This comment has been minimized.

Show comment
Hide comment
@mariussoutier

mariussoutier Sep 24, 2016

Contributor

Done!

Contributor

mariussoutier commented Sep 24, 2016

Done!

@johnynek

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!

Show outdated Hide outdated bijection-avro/src/main/scala/com/twitter/bijection/avro/AvroCodecs.scala
}
/**
* 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] = {

This comment has been minimized.

@johnynek

johnynek Sep 26, 2016

Collaborator

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.

@johnynek

johnynek Sep 26, 2016

Collaborator

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.

This comment has been minimized.

@mariussoutier

mariussoutier Sep 26, 2016

Contributor

Ok I added a todo.

@mariussoutier

mariussoutier Sep 26, 2016

Contributor

Ok I added a todo.

Show outdated Hide outdated bijection-avro/src/main/scala/com/twitter/bijection/avro/AvroCodecs.scala
* @param schema The record's schema
* @return Injection
*/
def toBinary[T <: SpecificRecordBase: ClassTag](schema: Schema): Injection[T, Array[Byte]] = {

This comment has been minimized.

@johnynek

johnynek Sep 26, 2016

Collaborator

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?

@johnynek

johnynek Sep 26, 2016

Collaborator

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?

This comment has been minimized.

@mariussoutier

mariussoutier Sep 26, 2016

Contributor

Good point, done!

@mariussoutier

mariussoutier Sep 26, 2016

Contributor

Good point, done!

@johnynek

Thanks!

@mariussoutier

This comment has been minimized.

Show comment
Hide comment
@mariussoutier

mariussoutier Sep 27, 2016

Contributor

All checks successful, merge away ;)

Contributor

mariussoutier commented Sep 27, 2016

All checks successful, merge away ;)

@johnynek johnynek merged commit 66bbeb7 into twitter:develop Sep 27, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@johnynek

This comment has been minimized.

Show comment
Hide comment
@johnynek

johnynek Sep 27, 2016

Collaborator

Thank you!

Collaborator

johnynek commented Sep 27, 2016

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment