Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
P. Oscar Boykin
@johnynek
(stripe pass in 1password)
Ghost
@ghost~54c6a0bddb8155e6700f1b4a
Will have to give it a go on a slow day, i tried 10 seconds of it there, took that long to get 1 word out….!
Ghost
@ghost~54c6a0bddb8155e6700f1b4a
@johnynek with those PR’s, anything else we want to do before rls? Seems like not a binary compatible change for bijection. But not one that should also cause people issues really — inheritance changing of a class seems like a rare problem
but possible
P. Oscar Boykin
@johnynek
that's all I thikn is worth it to do, @ianoc . The size limit on class names might also break compat.
Shane Delmore
@ShaneDelmore
I am tech spiking on Finatra 2.0 today with Quill as the data access library for fun. Going alright so far but one bit feels boilerplatey and I was hoping someone here could help...
P. Oscar Boykin
@johnynek
what’s up?
Shane Delmore
@ShaneDelmore
Finatra wants Twitter Futures, Quill supplies Scala Futures. I am using Bijection to convert between them.
P. Oscar Boykin
@johnynek
ok
Shane Delmore
@ShaneDelmore
But I have to manually supply the types on the conversion. Is there a way to define a ScalaFuture => TwitterFuture that does not require me to manually supply the type of TwitterFuture?
I am currently doing this: twitter2ScalaFuture[List[Foo]].invert(temp)
P. Oscar Boykin
@johnynek
are you using the .as[ ] enrichment?
Shane Delmore
@ShaneDelmore
No I am not. Sounds like I should be.
P. Oscar Boykin
@johnynek
let me get a link
import Conversion.asMethod
then you can do:
scalaFut.as[TwitterFuture[List[Foo]]]
in the worst case
but, since there is type inference
you might be able to do:
scalaFut.as
and in some cases the type can be inferred
Shane Delmore
@ShaneDelmore
That looks cleaner. Experimenting now but it seems the type inference may not work for my case.
P. Oscar Boykin
@johnynek
only thing else I can say it type = ...
Sorry
Shane Delmore
@ShaneDelmore
Where do you import TwitterFuture from?
for the scalaFut.as[TwitterFuture[List[Foo]]]
P. Oscar Boykin
@johnynek
com.twitter.util.{Future => TwitterFuture}
Shane Delmore
@ShaneDelmore
Ahhh…neat.
Raviv Pavel
@raviv

Hi, Looking for an example of converting a scala future to twitter future.
The following fails, looking for ExecutionContext

     val sf:ScalaFuture[Option[String]] = ...
     val tf:TwitterFuture[Option[String]]= twitter2ScalaFuture[Option[String]].invert(sf)

Thanks :)

P. Oscar Boykin
@johnynek
@raviv sorry, just saw this. You need to import an Execution context with scala futures: http://blog.jessitron.com/2014/02/scala-global-executioncontext-makes.html
Benjamin
@bdparrish
Can anyone provide the code for a java implementation of SpecificAvroCodecs such that I can use a toBinary with a SpecificRecordBase object?
Injection<GenericRecord, byte[]> genericRecordInjection = GenericAvroCodecs.toBinary(schema);
byte[] bytes = genericRecordInjection.apply(type);
P. Oscar Boykin
@johnynek
@bdparrish it is a big ugly but I can talk you through it.
Benjamin
@bdparrish
please
P. Oscar Boykin
@johnynek
the implicit parameters are just normal parameters for java
so you can pass them.
which one do you want?
Benjamin
@bdparrish
Class<T> clazz = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];

final ClassTag<T> classTag = ClassTag$.MODULE$.apply(clazz);

Injection<T, byte[]> binaryInjection = SpecificAvroCodecs.toBinary(classTag);
P. Oscar Boykin
@johnynek
that one?
Benjamin
@bdparrish
I have that but the toBinary doesn't like my ClassTag
P. Oscar Boykin
@johnynek
what happens?
that should work (I would wrap it in a static method where you pass a Class in)
Benjamin
@bdparrish
Error:(113, 70) java: method toBinary in class com.twitter.bijection.avro.SpecificAvroCodecs cannot be applied to given types;
required: scala.reflect.ClassTag<T>
found: scala.reflect.ClassTag<T>
reason: inference variable T has incompatible bounds
equality constraints: T
upper bounds: org.apache.avro.specific.SpecificRecordBase
P. Oscar Boykin
@johnynek
all, well just cast it do:
Class<org.apache.avro.specific.SpecificRecordBase>
rather than Class<T> I think
I mean, it is on you that cast is safe.