zhjwpku commented on code in PR #60: URL: https://github.com/apache/iceberg-cpp/pull/60#discussion_r2041395083
########## src/iceberg/snapshot.cc: ########## @@ -0,0 +1,55 @@ +/* + * 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. + */ + +#include "iceberg/snapshot.h" + +namespace iceberg { + +SnapshotRefType SnapshotRef::type() const noexcept { + return std::visit( + [&](const auto& retention) -> SnapshotRefType { + using T = std::decay_t<decltype(retention)>; + if constexpr (std::is_same_v<T, Branch>) { + return SnapshotRefType::kBranch; + } else { + return SnapshotRefType::kTag; + } + }, + retention); +} + +std::optional<std::string_view> Snapshot::operation() const { + auto it = summary.find(SnapshotSummaryFields::kOperation); + if (it != summary.end()) { + return it->second; + } + return std::nullopt; +} + +bool Snapshot::Equals(const Snapshot& other) const { + if (this == &other) { + return true; + } + return snapshot_id == other.snapshot_id && Review Comment: Here I just follow the java impl, suggested by @wgtmac. We can add the retention if needed in the future. ``` public boolean equals(Object o) { if (this == o) { return true; } if (o instanceof BaseSnapshot) { BaseSnapshot other = (BaseSnapshot) o; return this.snapshotId == other.snapshotId() && Objects.equal(this.parentId, other.parentId()) && this.sequenceNumber == other.sequenceNumber() && this.timestampMillis == other.timestampMillis() && Objects.equal(this.schemaId, other.schemaId()); } return false; } ``` -- 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