in scrooge-core/src/main/scala/com/twitter/scrooge/TLazyBinaryProtocol.scala [262:301]
override def decodeBool(buf: Array[Byte], offset: Int): Boolean =
buf(offset) == 1
override def decodeByte(buf: Array[Byte], offset: Int): Byte =
buf(offset)
override def decodeI16(buf: Array[Byte], off: Int): Short =
(((buf(off) & 0xff) << 8) | ((buf(off + 1) & 0xff))).toShort
override def decodeI32(buf: Array[Byte], off: Int): Int =
((buf(off) & 0xff) << 24) |
((buf(off + 1) & 0xff) << 16) |
((buf(off + 2) & 0xff) << 8) |
((buf(off + 3) & 0xff))
override def decodeI64(buf: Array[Byte], off: Int): Long =
((buf(off) & 0xffL) << 56) |
((buf(off + 1) & 0xffL) << 48) |
((buf(off + 2) & 0xffL) << 40) |
((buf(off + 3) & 0xffL) << 32) |
((buf(off + 4) & 0xffL) << 24) |
((buf(off + 5) & 0xffL) << 16) |
((buf(off + 6) & 0xffL) << 8) |
((buf(off + 7) & 0xffL))
override def decodeDouble(buf: Array[Byte], off: Int): Double =
java.lang.Double.longBitsToDouble(decodeI64(buf, off))
override def decodeString(buf: Array[Byte], off: Int): String =
try {
val size = decodeI32(buf, off)
new String(buf, off + 4, size, utf8Charset)
} catch {
case e: StringIndexOutOfBoundsException =>
throw new TException(
s"Data is corrupt, string size reported as ${decodeI32(buf, off)}, array size is : ${buf.size} , with offset as $off"
)
case e: UnsupportedEncodingException =>
throw new TException("JVM DOES NOT SUPPORT UTF-8")
}