aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/bmcluster/bm_feed_params.h
blob: bc9924229820e4ed3fbf080c55412f07250e6619 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <cstdint>
#include <vespa/vespalib/stllike/string.h>

namespace search::bmcluster {

class BmRange;

/*
 * Parameters for generating synthetic feed of documents and for
 * feeding them to the cluster.
 */
class BmFeedParams
{
    uint32_t _client_threads;
    uint32_t _documents;
    uint32_t _max_pending;
    uint32_t get_start(uint32_t thread_id) const {
        return (_documents / _client_threads) * thread_id + std::min(thread_id, _documents % _client_threads);
    }
public:
    BmFeedParams();
    ~BmFeedParams();
    uint32_t get_client_threads() const { return _client_threads; }
    uint32_t get_documents() const { return _documents; }
    uint32_t get_max_pending() const { return _max_pending; }
    BmRange get_range(uint32_t thread_id) const;
    void set_documents(uint32_t documents_in) { _documents = documents_in; }
    void set_client_threads(uint32_t threads_in) { _client_threads = threads_in; }
    void set_max_pending(uint32_t max_pending_in) { _max_pending = max_pending_in; }
    bool check() const;
};

}