| 90 | } |
| 91 | |
| 92 | Result<std::unique_ptr<FunctionOptions>> DeserializeFunctionOptions( |
| 93 | const Buffer& buffer) { |
| 94 | #ifdef ARROW_IPC |
| 95 | // Copying the buffer here is not ideal, but we need to do it to avoid |
| 96 | // use-after-free issues with the zero-copy buffer read. |
| 97 | auto stream = io::BufferReader::FromString(buffer.ToString()); |
| 98 | ARROW_ASSIGN_OR_RAISE(auto reader, ipc::RecordBatchFileReader::Open(stream.get())); |
| 99 | ARROW_ASSIGN_OR_RAISE(auto batch, reader->ReadRecordBatch(0)); |
| 100 | if (batch->num_rows() != 1) { |
| 101 | return Status::Invalid( |
| 102 | "serialized FunctionOptions's batch repr was not a single row - had ", |
| 103 | batch->num_rows()); |
| 104 | } |
| 105 | if (batch->num_columns() != 1) { |
| 106 | return Status::Invalid( |
| 107 | "serialized FunctionOptions's batch repr was not a single column - had ", |
| 108 | batch->num_columns()); |
| 109 | } |
| 110 | auto column = batch->column(0); |
| 111 | if (column->type()->id() != Type::STRUCT) { |
| 112 | return Status::Invalid( |
| 113 | "serialized FunctionOptions's batch repr was not a struct column - was ", |
| 114 | column->type()->ToString()); |
| 115 | } |
| 116 | ARROW_ASSIGN_OR_RAISE(auto raw_scalar, |
| 117 | checked_cast<const StructArray&>(*column).GetScalar(0)); |
| 118 | auto scalar = checked_cast<const StructScalar&>(*raw_scalar); |
| 119 | return FunctionOptionsFromStructScalar(scalar); |
| 120 | #else |
| 121 | return Status::NotImplemented("IPC feature isn't enabled"); |
| 122 | #endif |
| 123 | } |
| 124 | |
| 125 | Status CheckAllArrayOrScalar(const std::vector<Datum>& values) { |
| 126 | for (const auto& value : values) { |
no test coverage detected