|
| 1 | +from __future__ import absolute_import |
| 2 | +from __future__ import division |
| 3 | +from __future__ import print_function |
| 4 | + |
| 5 | +import logging |
| 6 | +import argparse |
| 7 | +import ray |
| 8 | +import os |
| 9 | +import modin.pandas as pd |
| 10 | + |
| 11 | +from utils import time_logger |
| 12 | + |
| 13 | + |
| 14 | +parser = argparse.ArgumentParser(description='arithmetic benchmark') |
| 15 | +parser.add_argument('--left', dest='left', help='path to the left csv data ' |
| 16 | + 'file') |
| 17 | +parser.add_argument('--right', dest='right', help='path to the right csv data ' |
| 18 | + 'file') |
| 19 | +parser.add_argument('--logfile', dest='logfile', help='path to the log file') |
| 20 | +args = parser.parse_args() |
| 21 | +file_left = args.left |
| 22 | +file_size_left = os.path.getsize(file_left) |
| 23 | + |
| 24 | +file_right = args.right |
| 25 | +file_size_right = os.path.getsize(file_right) |
| 26 | + |
| 27 | +if not os.path.exists(os.path.split(args.logfile)[0]): |
| 28 | + os.makedirs(os.path.split(args.logfile)[0]) |
| 29 | + |
| 30 | +logging.basicConfig(filename=args.logfile, level=logging.INFO) |
| 31 | + |
| 32 | +df_left = pd.read_csv(file_left) |
| 33 | +df_right = pd.read_csv(file_right) |
| 34 | + |
| 35 | +blocks = df_left._block_partitions.flatten().tolist() |
| 36 | +ray.wait(blocks, len(blocks)) |
| 37 | +blocks = df_right._block_partitions.flatten().tolist() |
| 38 | +ray.wait(blocks, len(blocks)) |
| 39 | + |
| 40 | +with time_logger("Inner Join: {} & {}; Left Size: {} bytes; Right Size: {} " |
| 41 | + "bytes".format(file_left, file_right, file_size_left, |
| 42 | + file_size_right)): |
| 43 | + result = df_left.join(df_right, how="inner", lsuffix='left_') |
| 44 | + ray.wait(result._block_partitions.flatten().tolist()) |
| 45 | + |
| 46 | +with time_logger("Outer Join: {} & {}; Left Size: {} bytes; Right Size: {} " |
| 47 | + "bytes".format(file_left, file_right, file_size_left, |
| 48 | + file_size_right)): |
| 49 | + result = df_left.join(df_right, how="outer", lsuffix='left_') |
| 50 | + ray.wait(result._block_partitions.flatten().tolist()) |
| 51 | + |
| 52 | +with time_logger("Inner Merge: {} & {}; Left Size: {} bytes; Right Size: {} " |
| 53 | + "bytes".format(file_left, file_right, file_size_left, |
| 54 | + file_size_right)): |
| 55 | + result = df_left.merge(df_right, how="inner", |
| 56 | + left_index=True, right_index=True) |
| 57 | + ray.wait(result._block_partitions.flatten().tolist()) |
| 58 | + |
| 59 | +with time_logger("Outer Merge: {} & {}; Left Size: {} bytes; Right Size: {} " |
| 60 | + "bytes".format(file_left, file_right, file_size_left, |
| 61 | + file_size_right)): |
| 62 | + result = df_left.merge(df_right, how="outer", |
| 63 | + left_index=True, right_index=True) |
| 64 | + ray.wait(result._block_partitions.flatten().tolist()) |
0 commit comments