@@ -110,12 +110,12 @@ arrow::Status sliceByColumn(
110110{
111111 arrow::Datum value_counts;
112112 auto column = input->GetColumnByName (key);
113+ auto array0 = static_cast <arrow::NumericArray<arrow::Int32Type>>(column->chunk (0 )->data ());
114+ int32_t prev = 0 ;
115+ int32_t cur = array0.Value (0 );
116+ int32_t lastNeg = cur < 0 ? cur : 0 ;
117+ int32_t lastPos = cur < 0 ? -1 : cur;
113118 for (auto i = 0 ; i < column->num_chunks (); ++i) {
114- int32_t prev = 0 ;
115- int32_t cur = 0 ;
116- int32_t lastNeg = 0 ;
117- int32_t lastPos = 0 ;
118- bool switchedGroup = false ;
119119 auto array = static_cast <arrow::NumericArray<arrow::Int32Type>>(column->chunk (i)->data ());
120120 for (auto e = 0 ; e < array.length (); ++e) {
121121 prev = cur;
@@ -129,22 +129,17 @@ arrow::Status sliceByColumn(
129129 if (lastPos > cur) {
130130 throw runtime_error_f (" Table %s index %s is not sorted: next value %d < previous value %d!" , target, key, cur, lastPos);
131131 }
132- if (switchedGroup && lastPos == cur && prev < 0 ) {
132+ if (lastPos == cur && prev < 0 ) {
133133 throw runtime_error_f (" Table %s index %s has a group with index %d that is split by %d" , target, key, cur, prev);
134134 }
135135 } else {
136136 if (lastNeg < cur) {
137137 throw runtime_error_f (" Table %s index %s is not sorted: next negative value %d > previous negative value %d!" , target, key, cur, lastNeg);
138138 }
139- if (switchedGroup && lastNeg == cur && prev >= 0 ) {
139+ if (lastNeg == cur && prev >= 0 ) {
140140 throw runtime_error_f (" Table %s index %s has a group with index %d that is split by %d" , target, key, cur, prev);
141141 }
142142 }
143- if (cur != prev) {
144- switchedGroup = true ;
145- } else {
146- switchedGroup = false ;
147- }
148143 }
149144 }
150145 std::shared_ptr<arrow::NumericArray<arrow::Int32Type>> values;
0 commit comments