westonpace commented on a change in pull request #12279: URL: https://github.com/apache/arrow/pull/12279#discussion_r802240769
########## File path: cpp/src/arrow/engine/substrait/extension_set.cc ########## @@ -0,0 +1,346 @@ +// 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 "arrow/engine/substrait/extension_set.h" + +#include <unordered_map> +#include <unordered_set> + +#include "arrow/util/hash_util.h" +#include "arrow/util/hashing.h" +#include "arrow/util/string_view.h" + +namespace arrow { +namespace engine { +namespace { + +struct TypePtrHashEq { + template <typename Ptr> + size_t operator()(const Ptr& type) const { + return type->Hash(); + } + + template <typename Ptr> + bool operator()(const Ptr& l, const Ptr& r) const { + return *l == *r; + } +}; + +struct IdHashEq { + using Id = ExtensionSet::Id; + + size_t operator()(Id id) const { + constexpr ::arrow::internal::StringViewHash hash = {}; + auto out = static_cast<size_t>(hash(id.uri)); + ::arrow::internal::hash_combine(out, hash(id.name)); + return out; + } + + bool operator()(Id l, Id r) const { return l.uri == r.uri && l.name == r.name; } +}; + +} // namespace + +struct ExtensionSet::Impl { + void AddUri(util::string_view uri, ExtensionSet* self) { + if (uris_.find(uri) != uris_.end()) return; + + self->uris_.push_back(uri); + uris_.insert(self->uris_.back()); // lookup helper's keys should reference memory + // owned by this ExtensionSet Review comment: The `Impl` itself is the "lookup helper". It's not really an "impl" in the traditional sense as there is no interface it is implementing. It's just an anonymous type that we are using internally. -- 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]
