rok commented on code in PR #38008:
URL: https://github.com/apache/arrow/pull/38008#discussion_r1409313225


##########
cpp/src/arrow/extension/fixed_shape_tensor.h:
##########
@@ -15,9 +15,21 @@
 // specific language governing permissions and limitations
 // under the License.
 
+#pragma once
+
 #include "arrow/extension_type.h"
 
 namespace arrow {
+namespace internal {

Review Comment:
   Moved to `arrow/cpp/src/arrow/extension/tensor_internal.h`



##########
cpp/src/arrow/extension/variable_shape_tensor.h:
##########
@@ -0,0 +1,115 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "arrow/extension_type.h"
+
+namespace arrow {
+namespace extension {
+
+class ARROW_EXPORT VariableShapeTensorArray : public ExtensionArray {
+ public:
+  using ExtensionArray::ExtensionArray;
+
+  /// \brief Get a Tensor of VariableShapeTensorArray at i
+  ///
+  /// This method will return a Tensor from VariableShapeTensorArray with 
strides
+  /// derived from shape and permutation of VariableShapeTensorType. Shape and
+  /// dim_names will be permuted according to permutation stored in the
+  /// VariableShapeTensorType metadata.
+  const Result<std::shared_ptr<Tensor>> GetTensor(const int64_t i) const;
+};
+
+/// \brief Concrete type class for variable-shape Tensor data.
+/// This is a canonical arrow extension type.
+/// See: https://arrow.apache.org/docs/format/CanonicalExtensions.html
+class ARROW_EXPORT VariableShapeTensorType : public ExtensionType {
+ public:
+  VariableShapeTensorType(const std::shared_ptr<DataType>& value_type,
+                          const uint32_t& ndim,
+                          const std::vector<int64_t>& permutation = {},
+                          const std::vector<std::string>& dim_names = {},
+                          const std::vector<std::optional<int64_t>>& 
uniform_shape = {})
+      : ExtensionType(struct_({::arrow::field("shape", 
fixed_size_list(uint32(), ndim)),
+                               ::arrow::field("data", list(value_type))})),
+        value_type_(value_type),
+        permutation_(permutation),
+        dim_names_(dim_names),
+        uniform_shape_(uniform_shape) {}

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to