You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ec...@apache.org on 2013/08/10 17:09:10 UTC
svn commit: r1512758 -
/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java
Author: ecapriolo
Date: Sat Aug 10 15:09:09 2013
New Revision: 1512758
URL: http://svn.apache.org/r1512758
Log:
HIVE-3772 Fix concurrency bug in LazyBinaryUtils due to a static field (Mikhail Bautin via egc)
Submitted by:Mikhail Bautin and Reynold Xin
Reviewed by: Edward Capriolo
Approved by: Edward Capriolo
Modified:
hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java
Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java?rev=1512758&r1=1512757&r2=1512758&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java Sat Aug 10 15:09:09 2013
@@ -123,7 +123,12 @@ public final class LazyBinaryUtils {
}
}
- static VInt vInt = new LazyBinaryUtils.VInt();
+ private static ThreadLocal<VInt> vIntThreadLocal = new ThreadLocal<VInt>() {
+ @Override
+ public VInt initialValue() {
+ return new VInt();
+ }
+ };
/**
* Check a particular field and set its size and offset in bytes based on the
@@ -148,6 +153,7 @@ public final class LazyBinaryUtils {
*/
public static void checkObjectByteInfo(ObjectInspector objectInspector,
byte[] bytes, int offset, RecordInfo recordInfo) {
+ VInt vInt = vIntThreadLocal.get();
Category category = objectInspector.getCategory();
switch (category) {
case PRIMITIVE:
@@ -391,9 +397,15 @@ public final class LazyBinaryUtils {
return 1 + len;
}
- private static byte[] vLongBytes = new byte[9];
+ private static ThreadLocal<byte[]> vLongBytesThreadLocal = new ThreadLocal<byte[]>() {
+ @Override
+ public byte[] initialValue() {
+ return new byte[9];
+ }
+ };
public static void writeVLong(Output byteStream, long l) {
+ byte[] vLongBytes = vLongBytesThreadLocal.get();
int len = LazyBinaryUtils.writeVLongToByteArray(vLongBytes, l);
byteStream.write(vLongBytes, 0, len);
}