Skip to content

[python] Add caching infrastructure and utilities#7347

Open
tub wants to merge 7 commits intoapache:masterfrom
tub:python-streaming-1a-caching
Open

[python] Add caching infrastructure and utilities#7347
tub wants to merge 7 commits intoapache:masterfrom
tub:python-streaming-1a-caching

Conversation

@tub
Copy link
Contributor

@tub tub commented Mar 5, 2026

Summary

  • Add backtick quoting to Identifier for SQL-safe formatting
  • Add ChangelogProducer enum to core_options
  • Add exists_batch() for bulk file existence checks
  • Add LRU caching to ManifestFileManager and ManifestListManager
  • Add snapshot caching and traversal helpers to SnapshotManager
  • Add cachetools dependency

Stacked PR series

This is PR 1a/5 in the Python streaming read series:

Test plan

  • flake8 passes on all changed files
  • python -m pytest passes (630/630, 9 pre-existing lance skips)
  • New tests: identifier_test.py, manifest_cache_test.py

- Add backtick quoting to Identifier for SQL-safe formatting
- Add ChangelogProducer enum to core_options
- Add exists_batch() for bulk file existence checks
- Add LRU caching to ManifestFileManager and ManifestListManager
- Add snapshot caching and traversal helpers to SnapshotManager
- Add cachetools dependency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tub and others added 2 commits March 5, 2026 18:07
…tEquals

Extract shared base class for ManifestFileCacheTest and ManifestListCacheTest,
add _make_snapshot() helper, and fix deprecated assertEquals (removed in 3.12).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tub tub marked this pull request as draft March 6, 2026 11:25
tub and others added 2 commits March 6, 2026 12:21
…rim docs, remove ChangelogProducer

- Upgrade cachetools to >=7,<8 for cachedmethod(info=True) support
- Remove ChangelogProducer enum (belongs in apache#7348 scanners branch)
- Replace manual cache hit/miss counters with @cachedmethod(info=True)
  decorator on ManifestFileManager, ManifestListManager, SnapshotManager
- Trim verbose docstrings across identifier, file_io, pyarrow_file_io,
  manifest_list_manager, and snapshot_manager
- Update cache tests to use cache_info() instead of manual counters

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…efault-size tests

- Move shared cache-behaviour tests (second_read, disabled_when_zero)
  into _CacheBehaviourMixin so they run for both manager types without
  duplication
- Extract _EMPTY_ROW / _EMPTY_STATS module constants to reduce
  DataFileMeta boilerplate
- Remove test_default_cache_size tests (just assert constructor defaults)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tub added a commit to tub/paimon that referenced this pull request Mar 6, 2026
…rim docs, remove ChangelogProducer

- Upgrade cachetools to >=7,<8 for cachedmethod(info=True) support
- Remove ChangelogProducer enum (belongs in apache#7348 scanners branch)
- Replace manual cache hit/miss counters with @cachedmethod(info=True)
  decorator on ManifestFileManager, ManifestListManager, SnapshotManager
- Trim verbose docstrings across identifier, file_io, pyarrow_file_io,
  manifest_list_manager, and snapshot_manager
- Update cache tests to use cache_info() instead of manual counters

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tub added a commit to tub/paimon that referenced this pull request Mar 6, 2026
…rim docs, remove ChangelogProducer

- Upgrade cachetools to >=7,<8 for cachedmethod(info=True) support
- Remove ChangelogProducer enum (belongs in apache#7348 scanners branch)
- Replace manual cache hit/miss counters with @cachedmethod(info=True)
  decorator on ManifestFileManager, ManifestListManager, SnapshotManager
- Trim verbose docstrings across identifier, file_io, pyarrow_file_io,
  manifest_list_manager, and snapshot_manager
- Update cache tests to use cache_info() instead of manual counters

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tub added a commit to tub/paimon that referenced this pull request Mar 6, 2026
…rim docs, remove ChangelogProducer

- Upgrade cachetools to >=7,<8 for cachedmethod(info=True) support
- Remove ChangelogProducer enum (belongs in apache#7348 scanners branch)
- Replace manual cache hit/miss counters with @cachedmethod(info=True)
  decorator on ManifestFileManager, ManifestListManager, SnapshotManager
- Trim verbose docstrings across identifier, file_io, pyarrow_file_io,
  manifest_list_manager, and snapshot_manager
- Update cache tests to use cache_info() instead of manual counters

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tub added a commit to tub/paimon that referenced this pull request Mar 6, 2026
…rim docs, remove ChangelogProducer

- Upgrade cachetools to >=7,<8 for cachedmethod(info=True) support
- Remove ChangelogProducer enum (belongs in apache#7348 scanners branch)
- Replace manual cache hit/miss counters with @cachedmethod(info=True)
  decorator on ManifestFileManager, ManifestListManager, SnapshotManager
- Trim verbose docstrings across identifier, file_io, pyarrow_file_io,
  manifest_list_manager, and snapshot_manager
- Update cache tests to use cache_info() instead of manual counters

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tub tub marked this pull request as ready for review March 6, 2026 12:44
tub and others added 2 commits March 6, 2026 14:00
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cachetools 7.x requires Python >=3.10 but the project supports 3.6+.
Drop info=True and explicit key= from @cachedmethod (both 7.x-only
features) while keeping the decorator itself (available since 4.x).

Replace cache_info()-based test assertions with unittest.mock spies on
file_io.new_input_stream, testing the actual caching effect without any
production code counters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

return results

def find_next_scannable(
Copy link
Contributor

@JingsongLi JingsongLi Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need it? Just reading the snapshot file to determine, does this really need to be optimized?

@JingsongLi
Copy link
Contributor

Can you explain the specific function of Cache? It seems that streaming reading does not repeat reading files?

pyarrow>=6,<7; python_version < "3.8"
pyarrow>=16,<20; python_version >= "3.8"
pylance>=0.20,<1; python_version>="3.9"
pylance>=0.10,<1; python_version>="3.8" and python_version<"3.9"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a small commit to remove these deps. Please rebase master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants