You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: trie_series.rs
    path of file: ./repos/joystream/analyses/bench/src
    
    the code of the file until where you have to start completion: // This file is part of Substrate.

// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Trie benchmark (integrated).

use hash_db::Prefix;
use kvdb::KeyValueDB;
use lazy_static::lazy_static;
use rand::Rng;
use sp_state_machine::Backend as _;
use sp_trie::{trie_types::TrieDBMut, TrieMut as _};
use std::{borrow::Cow, collections::HashMap, sync::Arc};

use node_primitives::Hash;

use crate::{
    common::DatabaseSize,
    core::{self, Mode, Path},
    generator::generate_trie,
    simple_trie::SimpleTrie,
    tempdb::{DatabaseType, TempDatabase},
};

pub const SAMPLE_SIZE: usize = 50;

pub type KeyValue = (Vec<u8>, Vec<u8>);
pub type KeyValues = Vec<KeyValue>;

lazy_static! {
    static ref KUSAMA_STATE_DISTRIBUTION: SizePool =
        SizePool::from_histogram(crate::state_sizes::KUSAMA_
    
    fn setup(self: Box<Self>) -> Box<dyn core::Benchmark> {
        let mut database = TempDatabase::new();

        let mut rng = rand::thread_rng();
        let warmup_prefix = KUSAMA_STATE_DISTRIBUTION.key(&mut rng);

        let mut key_values = KeyValues::new();
        let mut warmup_keys = KeyValues::new();
        let mut query_keys = KeyValues::new();
        let every_x_key = self.database_size.keys() / SAMPLE_SIZE;
        for idx in 0..self.database_size.keys() {
            let kv = (
                KUSAMA_STATE_DISTRIBUTION.key(&mut rng).to_vec(),
                KUSAMA_STATE_DISTRIBUTION.value(&mut rng),
            );

            if idx % every_x_key == 0 {
                // warmup keys go to separate tree with high prob
                let mut actual_warmup_key = warmup_prefix.clone();
                actual_warmup_key[16..].copy_from_slice(&kv.0[16..]);
                warmup_keys.push((actual_warmup_key.clone(), kv.1.clone()));
                key_values.push((actual_warmup_key.clone(), kv.1.clone()));
            }

            key_values.push(kv)
        }

        for i in (1..self.max_sample_size).step_by(self.max_sample_size / SAMPLE_SIZE) {
            let kv = (
                KUSAMA_STATE_DISTRIBUTION.key(&mut rng).to_vec(),
                random_vec(&mut rng, i),
            );

            query_keys.push(kv.clone());
            key_values.push(kv)
        }

        assert_eq!(warmup_keys.len(), SAMPLE_SIZE);
        assert_eq!(query_keys.len(), SAMPLE_SIZE);

        let root = generate_trie(database.open(self.database_type), key_values);

        Box::new(TrieReadSeriesBenchmark {
            database,
            root,
            warmup_keys,
            query_keys,
            database_type: self.database_type,
        })
    }