Skip to content

Commit

Permalink
Revert "Merge pull request #341 from NICTA/topic/thrift-serialiser-th…
Browse files Browse the repository at this point in the history
…read-safe"

This reverts commit 7005ef5, reversing
changes made to c9d3fef.
  • Loading branch information
etorreborre committed Sep 1, 2014
1 parent 7005ef5 commit 2c5c53f
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ object ThriftSchema {

/* WARNING THIS MUST BE A DEF OR OR IT CAN TRIGGER CONCURRENCY ISSUES WITH SHARED THRIFT SERIALIZERS */
def mkThriftFmt[A](implicit m: Manifest[A], ev: A <:< ThriftLike): WireFormat[A] = new WireFormat[A] {
val serialiser = ThriftSerialiser()
// Call once when the implicit is created to avoid further reflection
val empty = m.runtimeClass.newInstance().asInstanceOf[A]

def toWire(x: A, out: DataOutput) = {
val bytes = ThriftSerialiser().toBytes(x)
val bytes = serialiser.toBytes(x)
out.writeInt(bytes.length)
out.write(bytes)
}
Expand All @@ -25,7 +26,7 @@ object ThriftSchema {
val size = in.readInt()
val bytes = new Array[Byte](size)
in.readFully(bytes)
ThriftSerialiser().fromBytes(empty, bytes)
serialiser.fromBytes(empty, bytes)
}

override def toString = "ThriftObject"
Expand All @@ -34,12 +35,13 @@ object ThriftSchema {
/* WARNING THIS MUST BE A DEF OR OR IT CAN TRIGGER CONCURRENCY ISSUES WITH SHARED THRIFT SERIALIZERS*/
def mkThriftSchema[A](implicit m: Manifest[A], ev: A <:< ThriftLike) = new SeqSchema[A] {
type SeqType = BytesWritable
val serialiser = ThriftSerialiser()
// Call once when the implicit is created to avoid further reflection
val empty = m.runtimeClass.newInstance().asInstanceOf[A]

def toWritable(x: A) = new BytesWritable(ThriftSerialiser().toBytes(x))
def toWritable(x: A) = new BytesWritable(serialiser.toBytes(x))

def fromWritable(x: BytesWritable): A = ThriftSerialiser().fromBytes(empty, x.getBytes)
def fromWritable(x: BytesWritable): A = serialiser.fromBytes(empty, x.getBytes)

val mf: Manifest[SeqType] = implicitly
}
Expand Down

0 comments on commit 2c5c53f

Please sign in to comment.