| 173 | } |
| 174 | |
| 175 | DeviceAllocationTypeSet Datum::device_types() const { |
| 176 | switch (kind()) { |
| 177 | case NONE: |
| 178 | break; |
| 179 | case SCALAR: |
| 180 | // Scalars are asssumed as always residing in CPU memory for now. |
| 181 | return DeviceAllocationTypeSet::CpuOnly(); |
| 182 | case ARRAY: |
| 183 | return DeviceAllocationTypeSet{array()->device_type()}; |
| 184 | case CHUNKED_ARRAY: |
| 185 | return chunked_array()->device_types(); |
| 186 | case RECORD_BATCH: { |
| 187 | auto& columns = record_batch()->columns(); |
| 188 | if (columns.empty()) { |
| 189 | // An empty RecordBatch is considered to be CPU-only. |
| 190 | return DeviceAllocationTypeSet::CpuOnly(); |
| 191 | } |
| 192 | DeviceAllocationTypeSet set; |
| 193 | for (const auto& column : columns) { |
| 194 | set.add(column->device_type()); |
| 195 | } |
| 196 | return set; |
| 197 | } |
| 198 | case TABLE: { |
| 199 | auto& columns = table()->columns(); |
| 200 | if (columns.empty()) { |
| 201 | // An empty Table is considered to be CPU-only. |
| 202 | return DeviceAllocationTypeSet::CpuOnly(); |
| 203 | } |
| 204 | DeviceAllocationTypeSet set; |
| 205 | for (const auto& column : columns) { |
| 206 | set.Add(column->device_types()); |
| 207 | } |
| 208 | return set; |
| 209 | } |
| 210 | } |
| 211 | return {}; |
| 212 | } |
| 213 | |
| 214 | bool Datum::Equals(const Datum& other) const { |
| 215 | if (this->kind() != other.kind()) return false; |
nothing calls this directly
no test coverage detected