| 158 | } |
| 159 | |
| 160 | DeviceAllocationTypeSet Datum::device_types() const { |
| 161 | switch (kind()) { |
| 162 | case NONE: |
| 163 | break; |
| 164 | case SCALAR: |
| 165 | // Scalars are asssumed as always residing in CPU memory for now. |
| 166 | return DeviceAllocationTypeSet::CpuOnly(); |
| 167 | case ARRAY: |
| 168 | return DeviceAllocationTypeSet{array()->device_type()}; |
| 169 | case CHUNKED_ARRAY: |
| 170 | return chunked_array()->device_types(); |
| 171 | case RECORD_BATCH: { |
| 172 | auto& columns = record_batch()->columns(); |
| 173 | if (columns.empty()) { |
| 174 | // An empty RecordBatch is considered to be CPU-only. |
| 175 | return DeviceAllocationTypeSet::CpuOnly(); |
| 176 | } |
| 177 | DeviceAllocationTypeSet set; |
| 178 | for (const auto& column : columns) { |
| 179 | set.add(column->device_type()); |
| 180 | } |
| 181 | return set; |
| 182 | } |
| 183 | case TABLE: { |
| 184 | auto& columns = table()->columns(); |
| 185 | if (columns.empty()) { |
| 186 | // An empty Table is considered to be CPU-only. |
| 187 | return DeviceAllocationTypeSet::CpuOnly(); |
| 188 | } |
| 189 | DeviceAllocationTypeSet set; |
| 190 | for (const auto& column : columns) { |
| 191 | set.Add(column->device_types()); |
| 192 | } |
| 193 | return set; |
| 194 | } |
| 195 | } |
| 196 | return {}; |
| 197 | } |
| 198 | |
| 199 | bool Datum::Equals(const Datum& other) const { |
| 200 | if (this->kind() != other.kind()) return false; |
nothing calls this directly
no test coverage detected