Esempio n. 1
0
def gen_register_di(query_dir, rule_count):
    '''
    Generate register text for Di queries
    '''
    query_name = 'd' + str(rule_count) + '_pref'
    filename = query_dir + os.sep + query_name + '.cql'
    text = REG_Q_STR.format(qname=query_name, qfile=filename)
    query_name = 'd' + str(rule_count) + '_nonpref'
    filename = query_dir + os.sep + query_name + '.cql'
    text += REG_Q_STR.format(qname=query_name, qfile=filename)
    query_name = 'd' + str(rule_count)
    filename = query_dir + os.sep + query_name + '.cql'
    text += REG_Q_STR.format(qname=query_name, qfile=filename)
    return text
Esempio n. 2
0
def gen_cql_env(configuration, experiment_conf, output):
    '''
    Generate environment files for StremPref
    '''
    text = get_register_stream(configuration, experiment_conf)
    query_dir = get_query_dir(configuration, experiment_conf)
    # Environment files for equivalent CQL queries
    filename = query_dir + os.sep + 'table_ots.cql'
    text += REG_Q_STR.format(qname='table_ots', qfile=filename)
    filename = query_dir + os.sep + 'stream_ots.cql'
    text += REG_Q_STR.format(qname='stream_ots', qfile=filename)
    filename = query_dir + os.sep + 'z.cql'
    text += REG_Q_STR.format(qname='z', qfile=filename)
    filename = query_dir + os.sep + 'z_prime.cql'
    text += REG_Q_STR.format(qname='z_prime', qfile=filename)
    filename = query_dir + os.sep + 'p_start.cql'
    text += REG_Q_STR.format(qname='p_start', qfile=filename)
    filename = query_dir + os.sep + 'p_end.cql'
    text += REG_Q_STR.format(qname='p_end', qfile=filename)
    filename = query_dir + os.sep + 'p_start_end.cql'
    text += REG_Q_STR.format(qname='p_start_end', qfile=filename)
    # Final equivalent query
    filename = query_dir + os.sep + 'equiv.cql'
    if output:
        # Get output filename
        out_file = get_out_file(configuration, experiment_conf)
        text += REG_Q_OUTPUT_STR.format(qname='equiv', qfile=filename,
                                        ofile=out_file)
    else:
        text += REG_Q_STR.format(qname='equiv', qfile=filename)
    filename = get_env_file(configuration, experiment_conf)
    write_to_txt(filename, text)
Esempio n. 3
0
def gen_util_env(configuration, experiment_conf):
    '''
    Generate environment
    '''
    text = get_register_stream(configuration, experiment_conf)
    # Get query filename
    filename = get_query_util_file(configuration, experiment_conf)
    # Register query
    text += REG_Q_STR.format(qname='util', qfile=filename)
    # Get environment filename
    filename = get_env_util_file(configuration, experiment_conf)
    write_to_txt(filename, text)
Esempio n. 4
0
def gen_reg_rules_queries(configuration, query_dir, experiment_conf):
    '''
    Generate rules queries
    '''
    text = ''
    # Get rule list
    rule_list = get_rule_list(configuration, experiment_conf)
    for r_count, rule in enumerate(rule_list):
        if rule[TYPE] == FIRST:
            # ri (first)
            query_name = 'r' + str(r_count + 1)
            filename = query_dir + os.sep + query_name + '.cql'
            text += REG_Q_STR.format(qname=query_name, qfile=filename)
        # Simple rules
        elif rule[TYPE] == PREV:
            # prev formula
            query_name = 'r' + str(r_count + 1) + '_f1'
            filename = query_dir + os.sep + query_name + '.cql'
            text += REG_Q_STR.format(qname=query_name, qfile=filename)
            # someprev formula
            # m_sp (min_someprev)
            query_name = 'm_sp' + str(r_count + 1)
            filename = query_dir + os.sep + query_name + '.cql'
            text += REG_Q_STR.format(qname=query_name, qfile=filename)
            # ri (someprev)
            query_name = 'r' + str(r_count + 1) + '_f2'
            filename = query_dir + os.sep + query_name + '.cql'
            text += REG_Q_STR.format(qname=query_name, qfile=filename)
            # allprev formula
            # nv_ap (nonvalid_allprev)
            query_name = 'nv_ap' + str(r_count + 1)
            filename = query_dir + os.sep + query_name + '.cql'
            text += REG_Q_STR.format(qname=query_name, qfile=filename)
            # m_ap (min_allprev)
            query_name = 'm_ap' + str(r_count + 1)
            filename = query_dir + os.sep + query_name + '.cql'
            text += REG_Q_STR.format(qname=query_name, qfile=filename)
            # ri (allprev)
            query_name = 'r' + str(r_count + 1) + '_f3'
            filename = query_dir + os.sep + query_name + '.cql'
            text += REG_Q_STR.format(qname=query_name, qfile=filename)
            # ri
            query_name = 'r' + str(r_count + 1)
            filename = query_dir + os.sep + query_name + '.cql'
            text += REG_Q_STR.format(qname=query_name, qfile=filename)
        text += gen_register_di(query_dir, r_count + 1)
    return text
Esempio n. 5
0
def gen_endseq_env(configuration, experiment_conf, output):
    '''
    Generate environment files for ENDSEQ operator
    '''
    text = get_register_stream(configuration, experiment_conf)
    # Get query filename
    query_dir = get_query_dir(configuration, experiment_conf)
    filename = query_dir + os.sep + 'endseq.cql'
    # Register query
    if output:
        # Get output filename
        out_file = get_out_file(configuration, experiment_conf)
        text += REG_Q_OUTPUT_STR.format(qname='endseq', qfile=filename,
                                        ofile=out_file)
    else:
        text += REG_Q_STR.format(qname='endseq', qfile=filename)
    # Get environment filename
    filename = get_env_file(configuration, experiment_conf)
    write_to_txt(filename, text)
Esempio n. 6
0
def gen_cql_env(configuration, experiment_conf, output):
    '''
    Generate environment files for StremPref
    '''
    text = get_register_stream(configuration, experiment_conf)
    query_dir = get_query_dir(configuration, experiment_conf)
    # Environment files for equivalent CQL queries
    # RPOS
    filename = query_dir + os.sep + 'rpos.cql'
    text += REG_Q_STR.format(qname='rpos', qfile=filename)
    # SPOS
    filename = query_dir + os.sep + 'spos.cql'
    text += REG_Q_STR.format(qname='spos', qfile=filename)
    # W
    filename = query_dir + os.sep + 'w.cql'
    text += REG_Q_STR.format(qname='w', qfile=filename)
    # W1 and P1
    filename = query_dir + os.sep + 'w1.cql'
    text += REG_Q_STR.format(qname='w1', qfile=filename)
    filename = query_dir + os.sep + 'p1.cql'
    text += REG_Q_STR.format(qname='p1', qfile=filename)
    # W_i and P_i
    range_value = experiment_conf[RAN]
    for pos in range(2, range_value + 1):
        filename = query_dir + os.sep + 'w' + str(pos) + '.cql'
        text += REG_Q_STR.format(qname='w' + str(pos), qfile=filename)
        filename = query_dir + os.sep + 'p' + str(pos) + '.cql'
        text += REG_Q_STR.format(qname='p' + str(pos), qfile=filename)
    # Final equivalent query
    filename = query_dir + os.sep + 'equiv.cql'
    if output:
        # Get output filename
        out_file = get_out_file(configuration, experiment_conf)
        text += REG_Q_OUTPUT_STR.format(qname='equiv',
                                        qfile=filename,
                                        ofile=out_file)
    else:
        text += REG_Q_STR.format(qname='equiv', qfile=filename)
    filename = get_env_file(configuration, experiment_conf)
    write_to_txt(filename, text)
Esempio n. 7
0
def gen_cql_env(configuration, experiment_conf, output):
    '''
    Generate environment files for StremPref
    '''
    # Register stream
    text = get_register_stream(configuration,
                               experiment_conf,
                               include_tup=True)
    query_dir = get_query_dir(configuration, experiment_conf)
    filename = query_dir + os.sep + 'z.cql'
    text += REG_Q_STR.format(qname='z', qfile=filename)
    filename = query_dir + os.sep + 'p_join.cql'
    text += REG_Q_STR.format(qname='p_join', qfile=filename)
    filename = query_dir + os.sep + 'p.cql'
    text += REG_Q_STR.format(qname='p', qfile=filename)
    text += gen_reg_rules_queries(configuration, query_dir, experiment_conf)
    query_name = 't1'
    filename = query_dir + os.sep + query_name + '.cql'
    text += REG_Q_STR.format(qname=query_name, qfile=filename)
    level = experiment_conf[LEV]
    for number in range(2, level + 1):
        query_name = 't' + str(number)
        filename = query_dir + os.sep + query_name + '.cql'
        text += REG_Q_STR.format(qname=query_name, qfile=filename)
    query_name = 'id'
    filename = query_dir + os.sep + query_name + '.cql'
    text += REG_Q_STR.format(qname=query_name, qfile=filename)
    query_name = 'equiv'
    filename = query_dir + os.sep + query_name + '.cql'
    if output:
        # Get output filename
        out_file = get_out_file(configuration, experiment_conf)
        text += REG_Q_OUTPUT_STR.format(qname=query_name,
                                        qfile=filename,
                                        ofile=out_file)
    else:
        text += REG_Q_STR.format(qname=query_name, qfile=filename)
    # Get environment filename
    filename = get_env_file(configuration, experiment_conf)
    write_to_txt(filename, text)