Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-28 08:26:56

0001 // Licensed to the Apache Software Foundation (ASF) under one
0002 // or more contributor license agreements.  See the NOTICE file
0003 // distributed with this work for additional information
0004 // regarding copyright ownership.  The ASF licenses this file
0005 // to you under the Apache License, Version 2.0 (the
0006 // "License"); you may not use this file except in compliance
0007 // with the License.  You may obtain a copy of the License at
0008 //
0009 //   http://www.apache.org/licenses/LICENSE-2.0
0010 //
0011 // Unless required by applicable law or agreed to in writing,
0012 // software distributed under the License is distributed on an
0013 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0014 // KIND, either express or implied.  See the License for the
0015 // specific language governing permissions and limitations
0016 // under the License.
0017 
0018 // NOTE: API is EXPERIMENTAL and will change without going through a
0019 // deprecation cycle.
0020 
0021 #pragma once
0022 
0023 #include "arrow/compute/type_fwd.h"
0024 #include "arrow/result.h"
0025 #include "arrow/status.h"
0026 #include "arrow/type_fwd.h"
0027 #include "arrow/util/visibility.h"
0028 
0029 namespace arrow {
0030 namespace compute {
0031 
0032 /// \addtogroup compute-functions
0033 /// @{
0034 
0035 /// \brief Extension point for defining options outside libarrow (but
0036 /// still within this project).
0037 class ARROW_EXPORT FunctionOptionsType {
0038  public:
0039   virtual ~FunctionOptionsType() = default;
0040 
0041   virtual const char* type_name() const = 0;
0042   virtual std::string Stringify(const FunctionOptions&) const = 0;
0043   virtual bool Compare(const FunctionOptions&, const FunctionOptions&) const = 0;
0044   virtual Result<std::shared_ptr<Buffer>> Serialize(const FunctionOptions&) const;
0045   virtual Result<std::unique_ptr<FunctionOptions>> Deserialize(
0046       const Buffer& buffer) const;
0047   virtual std::unique_ptr<FunctionOptions> Copy(const FunctionOptions&) const = 0;
0048 };
0049 
0050 /// \brief Base class for specifying options configuring a function's behavior,
0051 /// such as error handling.
0052 class ARROW_EXPORT FunctionOptions : public util::EqualityComparable<FunctionOptions> {
0053  public:
0054   virtual ~FunctionOptions() = default;
0055 
0056   const FunctionOptionsType* options_type() const { return options_type_; }
0057   const char* type_name() const { return options_type()->type_name(); }
0058 
0059   bool Equals(const FunctionOptions& other) const;
0060   std::string ToString() const;
0061   std::unique_ptr<FunctionOptions> Copy() const;
0062   /// \brief Serialize an options struct to a buffer.
0063   Result<std::shared_ptr<Buffer>> Serialize() const;
0064   /// \brief Deserialize an options struct from a buffer.
0065   /// Note: this will only look for `type_name` in the default FunctionRegistry;
0066   /// to use a custom FunctionRegistry, look up the FunctionOptionsType, then
0067   /// call FunctionOptionsType::Deserialize().
0068   static Result<std::unique_ptr<FunctionOptions>> Deserialize(
0069       const std::string& type_name, const Buffer& buffer);
0070 
0071  protected:
0072   explicit FunctionOptions(const FunctionOptionsType* type) : options_type_(type) {}
0073   const FunctionOptionsType* options_type_;
0074 };
0075 
0076 ARROW_EXPORT void PrintTo(const FunctionOptions&, std::ostream*);
0077 
0078 /// @}
0079 
0080 }  // namespace compute
0081 }  // namespace arrow