@@ -51,13 +51,15 @@ public BinaryConsumer(VarBinaryVector vector, int index) {
5151
5252 /** consume a InputStream. */
5353 public void consume (InputStream is ) throws IOException {
54+ while (currentIndex >= vector .getValueCapacity ()) {
55+ vector .reallocValidityAndOffsetBuffers ();
56+ }
57+
58+ final int startOffset = vector .getStartOffset (currentIndex );
59+ final ArrowBuf offsetBuffer = vector .getOffsetBuffer ();
60+ int dataLength = 0 ;
61+
5462 if (is != null ) {
55- while (currentIndex >= vector .getValueCapacity ()) {
56- vector .reallocValidityAndOffsetBuffers ();
57- }
58- final int startOffset = vector .getStartOffset (currentIndex );
59- final ArrowBuf offsetBuffer = vector .getOffsetBuffer ();
60- int dataLength = 0 ;
6163 int read ;
6264 while ((read = is .read (reuseBytes )) != -1 ) {
6365 while (vector .getDataBuffer ().capacity () < (startOffset + dataLength + read )) {
@@ -66,11 +68,12 @@ public void consume(InputStream is) throws IOException {
6668 vector .getDataBuffer ().setBytes (startOffset + dataLength , reuseBytes , 0 , read );
6769 dataLength += read ;
6870 }
69- offsetBuffer .setInt (
70- (currentIndex + 1 ) * ((long ) VarBinaryVector .OFFSET_WIDTH ), startOffset + dataLength );
71+
7172 BitVectorHelper .setBit (vector .getValidityBuffer (), currentIndex );
72- vector .setLastSet (currentIndex );
7373 }
74+ offsetBuffer .setInt (
75+ (currentIndex + 1 ) * ((long ) VarBinaryVector .OFFSET_WIDTH ), startOffset + dataLength );
76+ vector .setLastSet (currentIndex );
7477 }
7578
7679 public void moveWriterPosition () {
@@ -95,9 +98,7 @@ public NullableBinaryConsumer(VarBinaryVector vector, int index) {
9598 @ Override
9699 public void consume (ResultSet resultSet ) throws SQLException , IOException {
97100 InputStream is = resultSet .getBinaryStream (columnIndexInResultSet );
98- if (!resultSet .wasNull ()) {
99- consume (is );
100- }
101+ consume (is );
101102 moveWriterPosition ();
102103 }
103104 }
0 commit comments