@@ -540,6 +540,60 @@ public void testSizeOfViewBufferElements() {
540540 }
541541 }
542542
543+ @ ParameterizedTest
544+ @ MethodSource ({"vectorCreatorProvider" })
545+ public void testSetSafeEmptyValueAtViewBufferBoundary (
546+ Function <BufferAllocator , BaseVariableWidthViewVector > vectorCreator ) {
547+ try (final BaseVariableWidthViewVector vector = vectorCreator .apply (allocator )) {
548+ final byte [] emptyValue = new byte [0 ];
549+ vector .allocateNew ();
550+ final int valueCapacity = vector .getValueCapacity ();
551+
552+ for (int i = 0 ; i <= valueCapacity ; i ++) {
553+ vector .setSafe (i , emptyValue );
554+ }
555+
556+ vector .setValueCount (valueCapacity + 1 );
557+ assertTrue (vector .getValueCapacity () > valueCapacity );
558+ assertEquals (0 , vector .getValueLength (valueCapacity ));
559+ assertArrayEquals (emptyValue , vector .get (valueCapacity ));
560+ }
561+ }
562+
563+ @ ParameterizedTest
564+ @ MethodSource ({"vectorCreatorProvider" })
565+ public void testSetValueCountFillsEmptiesAtViewBufferBoundary (
566+ Function <BufferAllocator , BaseVariableWidthViewVector > vectorCreator ) {
567+ try (final BaseVariableWidthViewVector vector = vectorCreator .apply (allocator )) {
568+ vector .allocateNew ();
569+ final int valueCapacity = vector .getValueCapacity ();
570+
571+ vector .setSafe (valueCapacity - 1 , "x" .getBytes (StandardCharsets .UTF_8 ));
572+ vector .setValueCount (valueCapacity + 1 );
573+
574+ assertTrue (vector .getValueCapacity () > valueCapacity );
575+ assertTrue (vector .isNull (valueCapacity ));
576+ }
577+ }
578+
579+ @ ParameterizedTest
580+ @ MethodSource ({"vectorCreatorProvider" })
581+ public void testSetNullAtViewBufferBoundary (
582+ Function <BufferAllocator , BaseVariableWidthViewVector > vectorCreator ) {
583+ try (final BaseVariableWidthViewVector vector = vectorCreator .apply (allocator )) {
584+ vector .allocateNew ();
585+ final int valueCapacity = vector .getValueCapacity ();
586+
587+ for (int i = 0 ; i <= valueCapacity ; i ++) {
588+ vector .setNull (i );
589+ }
590+ vector .setValueCount (valueCapacity + 1 );
591+
592+ assertTrue (vector .getValueCapacity () > valueCapacity );
593+ assertTrue (vector .isNull (valueCapacity ));
594+ }
595+ }
596+
543597 @ Test
544598 public void testNullableVarType1 () {
545599
0 commit comments