MCPcopy Create free account
hub / github.com/apache/arrow / Elt64

Method Elt64

r/src/altrep.cpp:564–627  ·  view source on GitHub ↗

The value at position i as an int64_t (to make bounds checking less verbose)

Source from the content-addressed store, hash-verified

562
563 // The value at position i as an int64_t (to make bounds checking less verbose)
564 static int64_t Elt64(SEXP alt, R_xlen_t i) {
565 auto altrep_data =
566 reinterpret_cast<ArrowAltrepData*>(R_ExternalPtrAddr(R_altrep_data1(alt)));
567 auto resolve = altrep_data->locate(i);
568
569 const auto& array =
570 altrep_data->chunked_array()->chunk(static_cast<int>(resolve.chunk_index));
571 auto j = resolve.index_in_chunk;
572
573 if (!array->IsNull(j)) {
574 const auto& indices =
575 internal::checked_cast<const DictionaryArray&>(*array).indices();
576
577 if (WasUnified(alt)) {
578 const auto* transpose_data = reinterpret_cast<const int32_t*>(
579 GetArrayTransposed(alt, static_cast<int>(resolve.chunk_index))->data());
580
581 switch (indices->type_id()) {
582 case Type::UINT8:
583 return transpose_data[indices->data()->GetValues<uint8_t>(1)[j]] + 1;
584 case Type::INT8:
585 return transpose_data[indices->data()->GetValues<int8_t>(1)[j]] + 1;
586 case Type::UINT16:
587 return transpose_data[indices->data()->GetValues<uint16_t>(1)[j]] + 1;
588 case Type::INT16:
589 return transpose_data[indices->data()->GetValues<int16_t>(1)[j]] + 1;
590 case Type::INT32:
591 return transpose_data[indices->data()->GetValues<int32_t>(1)[j]] + 1;
592 case Type::UINT32:
593 return transpose_data[indices->data()->GetValues<uint32_t>(1)[j]] + 1;
594 case Type::INT64:
595 return transpose_data[indices->data()->GetValues<int64_t>(1)[j]] + 1;
596 case Type::UINT64:
597 return transpose_data[indices->data()->GetValues<uint64_t>(1)[j]] + 1;
598 default:
599 break;
600 }
601 } else {
602 switch (indices->type_id()) {
603 case Type::UINT8:
604 return indices->data()->GetValues<uint8_t>(1)[j] + 1;
605 case Type::INT8:
606 return indices->data()->GetValues<int8_t>(1)[j] + 1;
607 case Type::UINT16:
608 return indices->data()->GetValues<uint16_t>(1)[j] + 1;
609 case Type::INT16:
610 return indices->data()->GetValues<int16_t>(1)[j] + 1;
611 case Type::INT32:
612 return indices->data()->GetValues<int32_t>(1)[j] + 1;
613 case Type::UINT32:
614 return indices->data()->GetValues<uint32_t>(1)[j] + 1;
615 case Type::INT64:
616 return indices->data()->GetValues<int64_t>(1)[j] + 1;
617 case Type::UINT64:
618 return static_cast<int64_t>(indices->data()->GetValues<uint64_t>(1)[j] + 1);
619 default:
620 break;
621 }

Callers

nothing calls this directly

Calls 6

locateMethod · 0.80
chunked_arrayMethod · 0.80
indicesMethod · 0.80
IsNullMethod · 0.45
dataMethod · 0.45
type_idMethod · 0.45

Tested by

no test coverage detected