diff --git serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/fast/LazyBinarySerializeWrite.java serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/fast/LazyBinarySerializeWrite.java index ec56b82..ae9111f 100644 --- serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/fast/LazyBinarySerializeWrite.java +++ serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/fast/LazyBinarySerializeWrite.java @@ -73,12 +73,13 @@ private long[] scratchLongs; private byte[] scratchBuffer; - private Field root; + private final Field root; private Deque stack = new ArrayDeque<>(); private LazyBinarySerDe.BooleanRef warnedOnceNullMapKey; private static class Field { - Category type; + // Make sure the root.type never changes from STRUCT + final Category type; int fieldCount; int fieldIndex; @@ -90,6 +91,15 @@ Field(Category type) { this.type = type; } + + public void clean() { + fieldCount = 0; + fieldIndex = 0; + byteSizeStart = 0; + start = 0; + nullOffset = 0; + nullByte = 0; + } } public LazyBinarySerializeWrite(int fieldCount) { @@ -101,6 +111,7 @@ public LazyBinarySerializeWrite(int fieldCount) { // Not public since we must have the field count and other information. private LazyBinarySerializeWrite() { + this.root = new Field(STRUCT); } /* @@ -133,7 +144,7 @@ public void reset() { } private void resetWithoutOutput() { - root = new Field(STRUCT); + root.clean(); root.fieldCount = rootFieldCount; stack.clear(); stack.push(root);