@@ -44,8 +44,8 @@ class UnspecifiedBuilder : public VctrBuilder {
4444
4545 ArrowErrorCode Reserve (R_xlen_t n, ArrowError* error) override {
4646 NANOARROW_RETURN_NOT_OK (VctrBuilder::Reserve (n, error));
47- value_ = PROTECT (Rf_allocVector (LGLSXP, n));
48- SetValue (value_ );
47+ SEXP value = PROTECT (Rf_allocVector (LGLSXP, n));
48+ SetValue (value );
4949 UNPROTECT (1 );
5050 return NANOARROW_OK;
5151 }
@@ -88,19 +88,21 @@ class IntBuilder : public VctrBuilder {
8888
8989 ArrowErrorCode Reserve (R_xlen_t n, ArrowError* error) override {
9090 NANOARROW_RETURN_NOT_OK (VctrBuilder::Reserve (n, error));
91- value_ = PROTECT (Rf_allocVector (INTSXP, n));
92- SetValue (value_ );
91+ SEXP value = PROTECT (Rf_allocVector (INTSXP, n));
92+ SetValue (value );
9393 UNPROTECT (1 );
9494 return NANOARROW_OK;
9595 }
9696
9797 ArrowErrorCode PushNext (const ArrowArray* array, ArrowError* error) override {
98+ NANOARROW_RETURN_NOT_OK (VctrBuilder::PushNext (array, error));
99+
98100 int * result = INTEGER (value_);
99101 int64_t n_bad_values = 0 ;
100102
101103 // True for all the types supported here
102104 const uint8_t * is_valid = array_view_.buffer_views [0 ].data .as_uint8 ;
103- int64_t raw_src_offset = array_view_.array -> offset ;
105+ int64_t raw_src_offset = array_view_.offset ;
104106 R_xlen_t length = array->length ;
105107
106108 // Fill the buffer
@@ -116,7 +118,7 @@ class IntBuilder : public VctrBuilder {
116118 length * sizeof (int32_t ));
117119
118120 // Set any nulls to NA_INTEGER
119- if (is_valid != NULL && array_view_.array -> null_count != 0 ) {
121+ if (is_valid != NULL && array_view_.null_count != 0 ) {
120122 for (R_xlen_t i = 0 ; i < length; i++) {
121123 if (!ArrowBitGet (is_valid, raw_src_offset + i)) {
122124 result[value_size_ + i] = NA_INTEGER;
@@ -129,7 +131,7 @@ class IntBuilder : public VctrBuilder {
129131 raw_src_offset, length, result + value_size_);
130132
131133 // Set any nulls to NA_LOGICAL
132- if (is_valid != NULL && array_view_.array -> null_count != 0 ) {
134+ if (is_valid != NULL && array_view_.null_count != 0 ) {
133135 for (R_xlen_t i = 0 ; i < length; i++) {
134136 if (!ArrowBitGet (is_valid, raw_src_offset + i)) {
135137 result[value_size_ + i] = NA_LOGICAL;
@@ -147,7 +149,7 @@ class IntBuilder : public VctrBuilder {
147149 }
148150
149151 // Set any nulls to NA_INTEGER
150- if (is_valid != NULL && array_view_.array -> null_count != 0 ) {
152+ if (is_valid != NULL && array_view_.null_count != 0 ) {
151153 for (R_xlen_t i = 0 ; i < length; i++) {
152154 if (!ArrowBitGet (is_valid, raw_src_offset + i)) {
153155 result[value_size_ + i] = NA_INTEGER;
@@ -162,7 +164,7 @@ class IntBuilder : public VctrBuilder {
162164 case NANOARROW_TYPE_DOUBLE:
163165 // Loop + bounds check. Because we don't know what memory might be
164166 // in a null slot, we have to check nulls if there are any.
165- if (is_valid != NULL && array_view_.array -> null_count != 0 ) {
167+ if (is_valid != NULL && array_view_.null_count != 0 ) {
166168 for (R_xlen_t i = 0 ; i < length; i++) {
167169 if (ArrowBitGet (is_valid, raw_src_offset + i)) {
168170 int64_t value = ArrowArrayViewGetIntUnsafe (&array_view_, i);
0 commit comments