Skip to content

Commit

Permalink
Better varname for merge sorter.
Browse files Browse the repository at this point in the history
Also sorted imports.
  • Loading branch information
Antti Kaihola authored and akaihola committed Apr 19, 2024
1 parent f81d542 commit 4fbe76f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pgtricks/pg_dump_splitsort.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ def new_output(filename: str) -> IO[str]:
output.close()
return open(os.path.join(directory, filename), 'w')

copy_lines: MergeSort | None = None
sorted_data_lines: MergeSort | None = None
counter = 0
output = new_output('0000_prologue.sql')
matcher = Matcher()

for line in open(sql_filepath):
if copy_lines is None:
if sorted_data_lines is None:
if line in ('\n', '--\n'):
buf.append(line)
elif line.startswith('SET search_path = '):
Expand All @@ -102,7 +102,7 @@ def new_output(filename: str) -> IO[str]:
schema=matcher.group('schema'),
table=matcher.group('table')))
elif COPY_RE.match(line):
copy_lines = MergeSort(
sorted_data_lines = MergeSort(
key=functools.cmp_to_key(linecomp),
max_memory=max_memory,
)
Expand All @@ -114,11 +114,11 @@ def new_output(filename: str) -> IO[str]:
writelines([line])
else:
if line == "\\.\n":
writelines(copy_lines)
writelines(sorted_data_lines)
writelines(line)
copy_lines = None
sorted_data_lines = None
else:
copy_lines.append(line)
sorted_data_lines.append(line)
flush()


Expand Down

0 comments on commit 4fbe76f

Please sign in to comment.