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

Method GetValueIndex

cpp/src/arrow/array/array_dict.cc:56–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54const std::shared_ptr<Array>& DictionaryArray::indices() const { return indices_; }
55
56int64_t DictionaryArray::GetValueIndex(int64_t i) const {
57 const uint8_t* indices_data = data_->buffers[1]->data();
58 // If the value is non-negative then we can use the unsigned path
59 switch (indices_->type_id()) {
60 case Type::UINT8:
61 case Type::INT8:
62 return static_cast<int64_t>(indices_data[data_->offset + i]);
63 case Type::UINT16:
64 case Type::INT16:
65 return static_cast<int64_t>(
66 reinterpret_cast<const uint16_t*>(indices_data)[data_->offset + i]);
67 case Type::UINT32:
68 case Type::INT32:
69 return static_cast<int64_t>(
70 reinterpret_cast<const uint32_t*>(indices_data)[data_->offset + i]);
71 case Type::UINT64:
72 case Type::INT64:
73 return static_cast<int64_t>(
74 reinterpret_cast<const uint64_t*>(indices_data)[data_->offset + i]);
75 default:
76 ARROW_CHECK(false) << "unreachable";
77 return -1;
78 }
79}
80
81DictionaryArray::DictionaryArray(const std::shared_ptr<ArrayData>& data)
82 : dict_type_(checked_cast<const DictionaryType*>(data->type.get())) {

Callers 2

TESTFunction · 0.80
convertMethod · 0.80

Calls 2

dataMethod · 0.45
type_idMethod · 0.45

Tested by 1

TESTFunction · 0.64