wgtmac commented on code in PR #77:
URL: https://github.com/apache/iceberg-cpp/pull/77#discussion_r2049982557


##########
src/iceberg/struct_like.h:
##########
@@ -0,0 +1,278 @@
+/*
+ * 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 <string>
+#include <vector>
+
+#include "iceberg/iceberg_export.h"
+#include "iceberg/result.h"
+#include "iceberg/type.h"
+
+namespace iceberg {
+
+class Scalar;
+class StructScalar;
+class ArrayScalar;
+class ScalarVisitor;
+class StructLike;
+class StructLikeVisitor;
+/**
+ * @brief Base class representing a generic scalar value.
+ */
+class ICEBERG_EXPORT Scalar {
+ public:
+  virtual ~Scalar() = default;
+
+  /**
+   * @brief Checks if the scalar represents a null value.
+   * @return true if the value is null, false otherwise.
+   */
+  virtual bool IsNull() const = 0;
+
+  /**
+   * @brief Casts the scalar to a specific derived type.
+   * @tparam T The target derived Scalar type.
+   * @return Reference to the casted value.
+   * @throws std::bad_cast if the cast fails.
+   */
+  template <typename T>
+  const T& as() const {
+    auto ptr = dynamic_cast<const T*>(this);
+    if (!ptr) throw std::bad_cast();
+    return *ptr;
+  }
+
+  /**
+   * @brief Creates a deep copy of the scalar.
+   * @return A shared pointer to the cloned scalar.
+   */
+  virtual std::shared_ptr<Scalar> clone() const = 0;
+
+  /**
+   * @brief Accepts a visitor for dispatching based on scalar type.
+   * @param visitor The visitor to accept.
+   */
+  virtual void accept(ScalarVisitor& visitor) const = 0;
+};
+
+/**
+ * @brief Visitor interface for Scalar, supporting type-dispatched operations.
+ */
+class ICEBERG_EXPORT ScalarVisitor {
+ public:
+  virtual ~ScalarVisitor() = default;
+
+  /// Visit methods for primitive types
+  virtual void visit(int32_t value) = 0;

Review Comment:
   If it accepts physical values instead of typed values, how can it 
differentiate between the actual types? For example, long and timestamp both 
use `int64_t`.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to