<commit_before>import time
from typing import List, Tuple

from logger import logger
from perfrunner.helpers import local
from perfrunner.helpers.cbmonitor import timeit, with_stats
from perfrunner.helpers.worker import tpcds_initial_data_load_task
from perfrunner.tests import PerfTest
from perfrunner.tests.rebalance import RebalanceTest
from perfrunner.workloads.bigfun.driver import bigfun
from perfrunner.workloads.bigfun.query_gen import Query
from perfrunner.workloads.tpcdsfun.driver import tpcds


class BigFunTest(PerfTest):

    COLLECTORS = {'analytics': True}

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.num_items = 0

    def create_datasets(self, bucket: str):
        logger.info('Creating datasets')
        for dataset, key in (
            ('GleambookUsers', 'id'),
            ('GleambookMessages', 'message_id'),
            ('ChirpMessages', 'chirpid'),
        ):
            statement = "CREATE DATASET `{}` ON `{}` WHERE `{}` IS NOT UNKNOWN;"\
                .format(dataset, bucket, key)
            self.rest.exec_analytics_statement(self.analytics_nodes[0],
                                               statement)

    def create_index(self):
        logger.info('Creating indexes')
        for statement in (
            "CREATE INDEX usrSinceIdx   ON `GleambookUsers`(user_since: string);",
            "CREATE INDEX gbmSndTimeIdx ON `GleambookMessages`(send_time: string);",
            "CREATE INDEX cmSndTimeIdx  ON `ChirpMessages`(send_time: string);",
        ):
            self.rest.exec_analytics_statement(self.analytics_nodes[0],
                                               statement)

    def disconnect_bucket(self, bucket: str):
        logger.info('Disconnecting the bucket: {}'.format(bucket))
        statement = 'DISCONNECT BUCKET `{}`;'.format(bucket)
        self.rest.exec_analytics_statement(self.analytics_nodes[0],
                                           statement)

    def connect_buckets(self):
        logger.info('Connecting all buckets')
        statement = "CONNECT link Local"
        self.rest.exec_analytics_statement(self.analytics_nodes[0],
                                           statement)

    def disconnect(self):
        for target in self.target_iterator:
            self.disconnect_bucket(target.bucket)<commit_msg>disconnect link before creating dataset<commit_after>import time
from typing import List, Tuple

from logger import logger
from perfrunner.helpers import local
from perfrunner.helpers.cbmonitor import timeit, with_stats
from perfrunner.helpers.worker import tpcds_initial_data_load_task
from perfrunner.tests import PerfTest
from perfrunner.tests.rebalance import RebalanceTest
from perfrunner.workloads.bigfun.driver import bigfun
from perfrunner.workloads.bigfun.query_gen import Query
from perfrunner.workloads.tpcdsfun.driver import tpcds


class BigFunTest(PerfTest):

    COLLECTORS = {'analytics': True}

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.num_items = 0

    def create_datasets(self, bucket: str):
        self.disconnect_link()
        logger.info('Creating datasets')
        for dataset, key in (
            ('GleambookUsers', 'id'),
            ('GleambookMessages', 'message_id'),
            ('ChirpMessages', 'chirpid'),
        ):
            statement = "CREATE DATASET `{}` ON `{}` WHERE `{}` IS NOT UNKNOWN;"\
                .format(dataset, bucket, key)
            self.rest.exec_analytics_statement(self.analytics_nodes[0],
                                               statement)

    def create_index(self):
        logger.info('Creating indexes')
        for statement in (
            "CREATE INDEX usrSinceIdx   ON `GleambookUsers`(user_since: string);",
            "CREATE INDEX gbmSndTimeIdx ON `GleambookMessages`(send_time: string);",
            "CREATE INDEX cmSndTimeIdx  ON `ChirpMessages`(send_time: string);",
        ):
            self.rest.exec_analytics_statement(self.analytics_nodes[0],
                                               statement)

    def disconnect_bucket(self, bucket: str):
        logger.info('Disconnecting the bucket: {}'.format(bucket))
        statement = 'DISCONNECT BUCKET `{}`;'.format(bucket)
        self.rest.exec_analytics_statement(self.analytics_nodes[0],
                                           statement)

    def connect_buckets(self):
        logger.info('Connecting all buckets')
        statement = "CONNECT link Local"
        self.rest.exec_analytics_statement(self.analytics_nodes[0],
                                           statement)

    def disconnect_link(self):
        logger.info('DISCONNECT LINK Local')
        statement = "DISCONNECT LINK Local"
        self.rest.exec_analytics_statement(self.analytics_nodes[0],
                                           statement)

    def disconnect(self):
        for target in self.target_iterator:
            self.disconnect_bucket(target.bucket)
{'fraction_non_alphanumeric': 0.09500998003992016, 'fraction_numerical': 0.0021956087824351296, 'mean_word_length': 2.443986254295533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3195524', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1378, 'n_words': 305}