| 1290 | } |
| 1291 | |
| 1292 | static void SetSelectionVector(SelectionVector &sel, data_ptr_t indices_p, const LogicalType &logical_type, idx_t size, |
| 1293 | ValidityMask *mask = nullptr, idx_t last_element_pos = 0) { |
| 1294 | sel.Initialize(size); |
| 1295 | |
| 1296 | if (mask) { |
| 1297 | switch (logical_type.id()) { |
| 1298 | case LogicalTypeId::UTINYINT: |
| 1299 | SetMaskedSelectionVectorLoop<uint8_t>(sel, indices_p, size, *mask, last_element_pos); |
| 1300 | break; |
| 1301 | case LogicalTypeId::TINYINT: |
| 1302 | SetMaskedSelectionVectorLoop<int8_t>(sel, indices_p, size, *mask, last_element_pos); |
| 1303 | break; |
| 1304 | case LogicalTypeId::USMALLINT: |
| 1305 | SetMaskedSelectionVectorLoop<uint16_t>(sel, indices_p, size, *mask, last_element_pos); |
| 1306 | break; |
| 1307 | case LogicalTypeId::SMALLINT: |
| 1308 | SetMaskedSelectionVectorLoop<int16_t>(sel, indices_p, size, *mask, last_element_pos); |
| 1309 | break; |
| 1310 | case LogicalTypeId::UINTEGER: |
| 1311 | if (last_element_pos > NumericLimits<uint32_t>::Maximum()) { |
| 1312 | //! Its guaranteed that our indices will point to the last element, so just throw an error |
| 1313 | throw ConversionException("DuckDB only supports indices that fit on an uint32"); |
| 1314 | } |
| 1315 | SetMaskedSelectionVectorLoop<uint32_t>(sel, indices_p, size, *mask, last_element_pos); |
| 1316 | break; |
| 1317 | case LogicalTypeId::INTEGER: |
| 1318 | SetMaskedSelectionVectorLoop<int32_t>(sel, indices_p, size, *mask, last_element_pos); |
| 1319 | break; |
| 1320 | case LogicalTypeId::UBIGINT: |
| 1321 | if (last_element_pos > NumericLimits<uint32_t>::Maximum()) { |
| 1322 | //! Its guaranteed that our indices will point to the last element, so just throw an error |
| 1323 | throw ConversionException("DuckDB only supports indices that fit on an uint32"); |
| 1324 | } |
| 1325 | SetMaskedSelectionVectorLoop<uint64_t>(sel, indices_p, size, *mask, last_element_pos); |
| 1326 | break; |
| 1327 | case LogicalTypeId::BIGINT: |
| 1328 | if (last_element_pos > NumericLimits<uint32_t>::Maximum()) { |
| 1329 | //! Its guaranteed that our indices will point to the last element, so just throw an error |
| 1330 | throw ConversionException("DuckDB only supports indices that fit on an uint32"); |
| 1331 | } |
| 1332 | SetMaskedSelectionVectorLoop<int64_t>(sel, indices_p, size, *mask, last_element_pos); |
| 1333 | break; |
| 1334 | |
| 1335 | default: |
| 1336 | throw NotImplementedException("(Arrow) Unsupported type for selection vectors %s", logical_type.ToString()); |
| 1337 | } |
| 1338 | |
| 1339 | } else { |
| 1340 | switch (logical_type.id()) { |
| 1341 | case LogicalTypeId::UTINYINT: |
| 1342 | SetSelectionVectorLoop<uint8_t>(sel, indices_p, size); |
| 1343 | break; |
| 1344 | case LogicalTypeId::TINYINT: |
| 1345 | SetSelectionVectorLoop<int8_t>(sel, indices_p, size); |
| 1346 | break; |
| 1347 | case LogicalTypeId::USMALLINT: |
| 1348 | SetSelectionVectorLoop<uint16_t>(sel, indices_p, size); |
| 1349 | break; |
no test coverage detected