chaoyli commented on a change in pull request #3462: URL: https://github.com/apache/incubator-doris/pull/3462#discussion_r420023841
########## File path: be/src/olap/memory/hash_index.h ########## @@ -0,0 +1,92 @@ +// 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. + +#ifndef DORIS_BE_SRC_OLAP_MEMORY_HASH_INDEX_H_ +#define DORIS_BE_SRC_OLAP_MEMORY_HASH_INDEX_H_ + +#include <stdint.h> + +#include <atomic> +#include <string> +#include <vector> + +#include "gutil/ref_counted.h" + +namespace doris { + +struct HashChunk; + +// A hash index, which maps uint64_t hashcode(key) to uint32_t rowid(value). +// +// From the user's perspective, it doesn't store row-key values, so when user +// lookup a row-key, user need to first calculate row-key's hashcode, then +// query the hash index to get a list of candidate rowids, then check all +// the candidates rowids for equality. +// +// Note: this hash index do not support delete. +// +// Note: This hash index is thread-safe, but it only support +// single-writer/multi-reader style concurrency. When hash index reaches it's +// capacity, a writer need to expand&rebuild, this is not thread-safe, so the +// writer need to do a copy-on-write, and make it's owner to link to the new +// reference, while readers still reading the old reference. +// +// Note: for more info, please refer to: +// https://engineering.fb.com/developer-tools/f14/ +class HashIndex : public RefCountedThreadSafe<HashIndex> { Review comment: I think you should add some comment to elaborate the hash algorithm. From the principle and the specific addd/set/find function. SIMD also can be introduced with some description. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org