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

How to load initial state or backfill the stream dataframe #452

Open
demiladef opened this issue Jun 23, 2022 · 2 comments
Open

How to load initial state or backfill the stream dataframe #452

demiladef opened this issue Jun 23, 2022 · 2 comments

Comments

@demiladef
Copy link

Is it possible to start a sdf or stream with an initial state or backfill the sdf with values from a database or cache?

@martindurant
Copy link
Member

An dfs or stream doesn't have a state; but you probably mean the various kinds of aggregations and other operations which do. Some of these allow you to specify state upon creation (e.g., DataFrame.aggregate), others maintain their stage in insrtance attributes, so that you can set them whenever you want

s = streamz.Stream()
u = s.unique()
u.sink(print)
u.seen = {1: 1}  # mark value 1 as already seen
s.emit(0)  # prints "0"
s.emit(1)  # doesn't print anything, already seen

You can also pass events in from your original stream (s.emit()) or a stream made for the purpose, to prime the stage of your aggregation node, or even call the node's update method to simulate the same.

@demiladef
Copy link
Author

thanks! yes I meant for aggregation. Priming the stage for aggregation using emit makes sense

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

No branches or pull requests

2 participants