| 215 | |
| 216 | template <typename ArrayType> |
| 217 | void DirectPutImpl(const ::arrow::Array& values, ::arrow::BufferBuilder* sink) { |
| 218 | if (values.type_id() != ArrayType::TypeClass::type_id) { |
| 219 | std::string type_name = ArrayType::TypeClass::type_name(); |
| 220 | throw ParquetException("direct put to " + type_name + " from " + |
| 221 | values.type()->ToString() + " not supported"); |
| 222 | } |
| 223 | |
| 224 | using value_type = typename ArrayType::value_type; |
| 225 | constexpr auto value_size = sizeof(value_type); |
| 226 | auto raw_values = checked_cast<const ArrayType&>(values).raw_values(); |
| 227 | |
| 228 | if (values.null_count() == 0) { |
| 229 | // no nulls, just dump the data |
| 230 | PARQUET_THROW_NOT_OK(sink->Append(raw_values, values.length() * value_size)); |
| 231 | } else { |
| 232 | PARQUET_THROW_NOT_OK( |
| 233 | sink->Reserve((values.length() - values.null_count()) * value_size)); |
| 234 | |
| 235 | for (int64_t i = 0; i < values.length(); i++) { |
| 236 | if (values.IsValid(i)) { |
| 237 | sink->UnsafeAppend(&raw_values[i], value_size); |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | template <> |
| 244 | void PlainEncoder<Int32Type>::Put(const ::arrow::Array& values) { |
nothing calls this directly
no test coverage detected