levy5307 commented on a change in pull request #603: URL: https://github.com/apache/incubator-pegasus/pull/603#discussion_r490687622
########## File path: src/server/hotkey_fine_data_collector.h ########## @@ -0,0 +1,53 @@ +// 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 "base/pegasus_utils.h" +#include <readerwriterqueue/readerwriterqueue.h> + +namespace pegasus { +namespace server { + +// hotkey_fine_data_collector handles the second procedure (FINE) of hotkey detection. +// It captures only the data mapping to the "hot" bucket. +// +// To prevent locking on the read path, we create one queue per thread of THREAD_POOL_LOCAL_APP. +// The read request is captured right inside its execution thread. +// +// For writes we do not apply this optimization. + +typedef std::vector<moodycamel::ReaderWriterQueue<std::pair<dsn::blob, uint64_t>>> + lockfree_capture_queues; + +class hotkey_fine_data_collector +{ +public: + // capture `hash_key` into internal storage structure + void capture_data(const dsn::blob &hash_key, uint64_t size); + + // Timely to analyze the data of the internal storage structure + // returns: true, result is the hotkey + // false, not find the hotkey + bool analyse_data(std::string &result); Review comment: add `/*out*/` ---------------------------------------------------------------- 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: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
