Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[join-] load all sheets before joins #2351

Merged
merged 3 commits into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions visidata/features/join.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def ensureLoaded(vd, sheets):

@asyncthread
def _appendRowsAfterLoading(joinsheet, origsheets):
if vd.ensureLoaded(origsheets):
with Progress(gerund='loading'):
vd.ensureLoaded(origsheets)
vd.sync()

colnames = {c.name:c for c in joinsheet.visibleCols}
Expand Down Expand Up @@ -184,8 +185,9 @@ class JoinSheet(Sheet):
def loader(self):
sheets = self.sources

vd.ensureLoaded(sheets)
vd.sync()
with Progress(gerund='loading'):
vd.ensureLoaded(sheets)
vd.sync()

# first item in joined row is the key tuple from the first sheet.
# first columns are the key columns from the first sheet, using its row (0)
Expand Down Expand Up @@ -266,8 +268,9 @@ def ExtendedSheet_reload(self, sheets):
# first item in joined row is the key tuple from the first sheet.
# first columns are the key columns from the first sheet, using its row (0)

vd.ensureLoaded(sheets)
vd.sync()
with Progress(gerund='loading'):
vd.ensureLoaded(sheets)
vd.sync()

self.columns = []
for i, c in enumerate(sheets[0].keyCols):
Expand Down Expand Up @@ -331,11 +334,11 @@ def iterload(self):
# only one column with each name allowed per sheet
keyedcols = collections.defaultdict(dict) # name -> { sheet -> col }

with Progress(gerund='loading'):
vd.ensureLoaded(self.source)
vd.sync()
with Progress(gerund='joining', sheet=self, total=sum(vs.nRows for vs in self.source)) as prog:
for sheet in self.source:
if sheet.ensureLoaded():
vd.sync()

for r in sheet.rows:
yield (sheet, r)
prog.addProgress(1)
Expand Down