Back to home page

EIC code displayed by LXR

 
 

    


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

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 #pragma once
0019 
0020 #include "arrow/extension_type.h"
0021 #include "arrow/type.h"
0022 
0023 namespace arrow::extension {
0024 
0025 /// \brief Opaque is a placeholder for a type from an external (usually
0026 ///   non-Arrow) system that could not be interpreted.
0027 class ARROW_EXPORT OpaqueType : public ExtensionType {
0028  public:
0029   /// \brief Construct an OpaqueType.
0030   ///
0031   /// \param[in] storage_type The underlying storage type.  Should be
0032   ///   arrow::null if there is no data.
0033   /// \param[in] type_name The name of the type in the external system.
0034   /// \param[in] vendor_name The name of the external system.
0035   explicit OpaqueType(std::shared_ptr<DataType> storage_type, std::string type_name,
0036                       std::string vendor_name)
0037       : ExtensionType(std::move(storage_type)),
0038         type_name_(std::move(type_name)),
0039         vendor_name_(std::move(vendor_name)) {}
0040 
0041   std::string extension_name() const override { return "arrow.opaque"; }
0042   std::string ToString(bool show_metadata) const override;
0043   bool ExtensionEquals(const ExtensionType& other) const override;
0044   std::string Serialize() const override;
0045   Result<std::shared_ptr<DataType>> Deserialize(
0046       std::shared_ptr<DataType> storage_type,
0047       const std::string& serialized_data) const override;
0048   /// Create an OpaqueArray from ArrayData
0049   std::shared_ptr<Array> MakeArray(std::shared_ptr<ArrayData> data) const override;
0050 
0051   std::string_view type_name() const { return type_name_; }
0052   std::string_view vendor_name() const { return vendor_name_; }
0053 
0054  private:
0055   std::string type_name_;
0056   std::string vendor_name_;
0057 };
0058 
0059 /// \brief Opaque is a wrapper for (usually binary) data from an external
0060 ///   (often non-Arrow) system that could not be interpreted.
0061 class ARROW_EXPORT OpaqueArray : public ExtensionArray {
0062  public:
0063   using ExtensionArray::ExtensionArray;
0064 };
0065 
0066 /// \brief Return an OpaqueType instance.
0067 ARROW_EXPORT std::shared_ptr<DataType> opaque(std::shared_ptr<DataType> storage_type,
0068                                               std::string type_name,
0069                                               std::string vendor_name);
0070 
0071 }  // namespace arrow::extension