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 0643ebd commit d9685d7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pgtricks/pg_dump_splitsort.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import re
import sys
from typing import IO, List, Match, Optional, Pattern, Tuple, Union, cast, Iterable
from typing import IO, Iterable, List, Match, Optional, Pattern, Tuple, Union, cast

from pgtricks.mergesort import MergeSort

Expand Down Expand Up @@ -75,13 +75,13 @@ def new_output(filename: str) -> IO[str]:
output.close()
return open(os.path.join(directory, filename), 'w')

copy_lines: Optional[MergeSort] = None
sorted_data_lines: Optional[MergeSort] = 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 @@ -95,7 +95,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
)
elif SEQUENCE_SET_RE.match(line):
Expand All @@ -106,11 +106,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 d9685d7

Please sign in to comment.