Skip to content

Commit

Permalink
Merge pull request #857 from roflcoopter/feature/check-tier-cursor-fix
Browse files Browse the repository at this point in the history
dont materialize when using yield_per
  • Loading branch information
roflcoopter authored Dec 12, 2024
2 parents 07679e5 + e53a3e0 commit 2b39598
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions viseron/components/storage/tier_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,23 +215,17 @@ def _check_tier(self, get_session: Callable[[], Session]) -> None:
)

# Process in batches to avoid memory issues
for batch in file_ids.yield_per(100):
# Materialize current batch
files = [
{"path": file.path, "tier_path": file.tier_path} for file in batch
]
for file in files:
handle_file(
get_session,
self._storage,
self._camera.identifier,
self._tier,
self._next_tier,
file["path"],
file["tier_path"],
self._logger,
)
# Commit batch
for file in file_ids.yield_per(100):
handle_file(
get_session,
self._storage,
self._camera.identifier,
self._tier,
self._next_tier,
file[1],
file[2],
self._logger,
)
session.flush()
session.commit()

Expand Down

0 comments on commit 2b39598

Please sign in to comment.