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

Create pipestat iter for dbbackend #97

Closed
donaldcampbelljr opened this issue Oct 16, 2023 · 3 comments
Closed

Create pipestat iter for dbbackend #97

donaldcampbelljr opened this issue Oct 16, 2023 · 3 comments
Milestone

Comments

@donaldcampbelljr
Copy link
Contributor

may be useful in tandem with seq col project

@donaldcampbelljr donaldcampbelljr added this to the v0.7.0 milestone Oct 16, 2023
@donaldcampbelljr
Copy link
Contributor Author

given filter conditions, returned paged iterator.
pipestat currently has a dynamic_filter function which modifies the sql statement before execution.

@nsheff
Copy link
Contributor

nsheff commented Oct 31, 2023

Here's an implementation of this I wrote for seqcolapi.

https://github.com/refgenie/seqcolapi/blob/91326936f2dcd847ba8be28e703a5c0d77377429/seqcolapi/scconf.py#L24-L68

It may just work to take these functions and stick them on the class in pipestat. Then, it will be an iterable MutableMapping with caching.

One thing we should change, though: this code is based on an offset-based pagination. I think we should switch to a cursor-based pagination, which will be more performant -- and in fact, since @donaldcampbelljr already implemented this in pipestat, we should just use that for the 'next page' functionality here.

@donaldcampbelljr
Copy link
Contributor Author

I modified pipestat's iterator to use the cursor position and limit.

It can be used like so:

psm_iterable = psm.__iter__(limit=100, cursor=5)

for i in psm_iterable:
   print(i) # prints the record

a = next(psm_iterable)

Because pipestat inherits from mutable_mapping, I could only modify __iter__ and not __next__.

donaldcampbelljr added a commit that referenced this issue Jan 16, 2024
* initial test #97

* iterate on select_records if file backend

* Implement iterator with cursor and limit, finish tests

* update docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants