# Path: py_stringsimjoin/utils/generic_helper.py
# def find_output_attribute_indices(original_columns, output_attributes):
#     output_attribute_indices = []
#     if output_attributes is not None:
#         for attr in output_attributes:
#             output_attribute_indices.append(original_columns.index(attr))
#     return output_attribute_indices
# 
# def get_output_header_from_tables(l_key_attr, r_key_attr,
#                                   l_out_attrs, r_out_attrs,
#                                   l_out_prefix, r_out_prefix):
#     output_header = []
# 
#     output_header.append(l_out_prefix + l_key_attr)
# 
#     output_header.append(r_out_prefix + r_key_attr)
# 
#     if l_out_attrs:
#         for l_attr in l_out_attrs:
#             output_header.append(l_out_prefix + l_attr)
# 
#     if r_out_attrs:
#         for r_attr in r_out_attrs:
#             output_header.append(r_out_prefix + r_attr)
# 
#     return output_header
# 
# def get_output_row_from_tables(l_row, r_row,
#                                l_key_attr_index, r_key_attr_index, 
#                                l_out_attrs_indices=None,
#                                r_out_attrs_indices=None):
#     output_row = []
#     
#     # add ltable id attr
#     output_row.append(l_row[l_key_attr_index])
# 
#     # add rtable id attr
#     output_row.append(r_row[r_key_attr_index])
# 
#     # add ltable output attributes
#     if l_out_attrs_indices:
#         for l_attr_index in l_out_attrs_indices:
#             output_row.append(l_row[l_attr_index])
# 
#     # add rtable output attributes
#     if r_out_attrs_indices:
#         for r_attr_index in r_out_attrs_indices:
#             output_row.append(r_row[r_attr_index])
# 
#     return output_row


import numpy as np
import pandas as pd
import pyprind
import os
from py_stringsimjoin.utils.generic_helper import \
    find_output_attribute_indices, get_output_header_from_tables, \
    get_output_row_from_tables
                                 l_row, r_row,
                                 l_key_attr_index, r_key_attr_index,
                                 l_out_attrs_indices, r_out_attrs_indices)
            else:
                record = [l_row[l_key_attr_index], r_row[r_key_attr_index]]
            output_rows.append(record)

            # Flushing the data onto the disk if in-memory size exceeds the permissible data limit
            if len(output_rows) > data_limit_per_core:
                df = pd.DataFrame(output_rows)
                with open(missing_pairs_file_name, 'a+') as myfile:
                    df.to_csv(myfile, header=False, index=False)
                output_rows = []

        if show_progress:
            prog_bar.update()

    # if output rows have some data left, flush the same to the disk to maintain consistency.
    if len(output_rows) > 0:
        df = pd.DataFrame(output_rows)
        with open(missing_pairs_file_name, 'a+') as myfile:
            df.to_csv(myfile, header=False, index=False)
        output_rows = []

    # For each rtable record with missing value in r_join_attr,
    # output a pair corresponding to every record in ltable which 
    # doesn't have a missing value in l_join_attr.
    for r_row in rtable_missing.itertuples(index=False):
        for l_row in ltable_not_missing.itertuples(index=False):
            if has_output_attributes:

# Path: py_stringsimjoin/utils/generic_helper.py
# def find_output_attribute_indices(original_columns, output_attributes):
#     output_attribute_indices = []
#     if output_attributes is not None:
#         for attr in output_attributes:
#             output_attribute_indices.append(original_columns.index(attr))
#     return output_attribute_indices
# 
# def get_output_header_from_tables(l_key_attr, r_key_attr,
#                                   l_out_attrs, r_out_attrs,
#                                   l_out_prefix, r_out_prefix):
#     output_header = []
# 
#     output_header.append(l_out_prefix + l_key_attr)
# 
#     output_header.append(r_out_prefix + r_key_attr)
# 
#     if l_out_attrs:
#         for l_attr in l_out_attrs:
#             output_header.append(l_out_prefix + l_attr)
# 
#     if r_out_attrs:
#         for r_attr in r_out_attrs:
#             output_header.append(r_out_prefix + r_attr)
# 
#     return output_header
# 
# def get_output_row_from_tables(l_row, r_row,
#                                l_key_attr_index, r_key_attr_index, 
#                                l_out_attrs_indices=None,
#                                r_out_attrs_indices=None):
#     output_row = []
#     
#     # add ltable id attr
#     output_row.append(l_row[l_key_attr_index])
# 
#     # add rtable id attr
#     output_row.append(r_row[r_key_attr_index])
# 
#     # add ltable output attributes
#     if l_out_attrs_indices:
#         for l_attr_index in l_out_attrs_indices:
#             output_row.append(l_row[l_attr_index])
# 
#     # add rtable output attributes
#     if r_out_attrs_indices:
#         for r_attr_index in r_out_attrs_indices:
#             output_row.append(r_row[r_attr_index])
# 
#     return output_row


# Path: py_stringsimjoin/utils/missing_value_handler_disk.py
import numpy as np
import pandas as pd
import pyprind
import os
from py_stringsimjoin.utils.generic_helper import \
    find_output_attribute_indices, get_output_header_from_tables, \
    get_output_row_from_tables

                                 l_row, r_row,
                                 l_key_attr_index, r_key_attr_index,
                                 l_out_attrs_indices, r_out_attrs_indices)
            else:
                record = [l_row[l_key_attr_index], r_row[r_key_attr_index]]
            output_rows.append(record)

            # Flushing the data onto the disk if in-memory size exceeds the permissible data limit
            if len(output_rows) > data_limit_per_core:
                df = pd.DataFrame(output_rows)
                with open(missing_pairs_file_name, 'a+') as myfile:
                    df.to_csv(myfile, header=False, index=False)
                output_rows = []

        if show_progress:
            prog_bar.update()

    # if output rows have some data left, flush the same to the disk to maintain consistency.
    if len(output_rows) > 0:
        df = pd.DataFrame(output_rows)
        with open(missing_pairs_file_name, 'a+') as myfile:
            df.to_csv(myfile, header=False, index=False)
        output_rows = []

    # For each rtable record with missing value in r_join_attr,
    # output a pair corresponding to every record in ltable which 
    # doesn't have a missing value in l_join_attr.
    for r_row in rtable_missing.itertuples(index=False):
        for l_row in ltable_not_missing.itertuples(index=False):
            if has_output_attributes:

                record = get_output_row_from_tables(