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

Function DeserializeFunctionOptions

cpp/src/arrow/compute/function_internal.cc:92–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92Result<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
125Status CheckAllArrayOrScalar(const std::vector<Datum>& values) {
126 for (const auto& value : values) {

Callers 1

DeserializeMethod · 0.85

Calls 10

FromStringFunction · 0.85
InvalidFunction · 0.50
NotImplementedFunction · 0.50
ToStringMethod · 0.45
num_rowsMethod · 0.45
num_columnsMethod · 0.45
columnMethod · 0.45
idMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected