Index: serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java =================================================================== --- serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java +++ serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java @@ -123,7 +123,12 @@ } } - static VInt vInt = new LazyBinaryUtils.VInt(); + private static ThreadLocal vIntThreadLocal = new ThreadLocal() { + @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 static void checkObjectByteInfo(ObjectInspector objectInspector, byte[] bytes, int offset, RecordInfo recordInfo) { + VInt vInt = vIntThreadLocal.get(); Category category = objectInspector.getCategory(); switch (category) { case PRIMITIVE: @@ -353,9 +359,15 @@ return 1 + len; } - private static byte[] vLongBytes = new byte[9]; + private static ThreadLocal vLongBytesThreadLocal = new ThreadLocal() { + @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); }