-
Notifications
You must be signed in to change notification settings - Fork 448
Add env variables to configure manifest cache #2993
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
base: main
Are you sure you want to change the base?
Changes from all commits
07e5008
2001cca
ee95c46
f411547
a87cc1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ | |
| StringType, | ||
| StructType, | ||
| ) | ||
| from pyiceberg.utils.config import Config | ||
|
|
||
| UNASSIGNED_SEQ = -1 | ||
| DEFAULT_BLOCK_SIZE = 67108864 # 64 * 1024 * 1024 | ||
|
|
@@ -891,13 +892,16 @@ def __hash__(self) -> int: | |
| return hash(self.manifest_path) | ||
|
|
||
|
|
||
| # Global cache for ManifestFile objects, keyed by manifest_path. | ||
| # This deduplicates ManifestFile objects across manifest lists, which commonly | ||
| # share manifests after append operations. | ||
| _manifest_cache: LRUCache[str, ManifestFile] = LRUCache(maxsize=128) | ||
kris-gaudel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Lock for thread-safe cache access | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor detail, but I would keep these original comments. Or is there a specific reason to remove them? |
||
| _DEFAULT_MANIFEST_CACHE_SIZE = 128 | ||
| _manifest_cache_size = Config().get_int("manifest-cache-size") or _DEFAULT_MANIFEST_CACHE_SIZE | ||
| _manifest_cache_lock = threading.RLock() | ||
| _manifest_cache: LRUCache[str, ManifestFile] = LRUCache(maxsize=_manifest_cache_size) | ||
|
|
||
|
|
||
| def clear_manifest_cache() -> None: | ||
| """Clear the manifest cache.""" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a specific use case / scenario, where one would use this method? It might be helpful to mention them here, as I assume in most cases, users wouldn't ever call this method - except for very specific scenarios. |
||
| with _manifest_cache_lock: | ||
| _manifest_cache.clear() | ||
|
|
||
|
|
||
| def _manifests(io: FileIO, manifest_list: str) -> tuple[ManifestFile, ...]: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor detail, but I would keep these original comments. Or is there a specific reason to remove them?