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

default content addressable id for snapshots #101

Open
samuelstroschein opened this issue Oct 16, 2024 — with Linear · 3 comments
Open

default content addressable id for snapshots #101

samuelstroschein opened this issue Oct 16, 2024 — with Linear · 3 comments

Comments

Copy link
Member

Context

Problems: 

  • joining if change.snapshot_id can be nullable
  • if for every nukllable snapshot a row is created (same snapshot.id) = bloat

Solution: 

  1. change.snapshot_id is always defined
  2. file handlers create an id from the blob of a snapshot value → nullable snapshot all refer to the same snapshot id → no bloat 

Proposal

Use an id on insert that is content addressable by default.

  • users don't need to think about ids
  • default = if not content addressable is desired, provide your own id

CleanShot 2024-10-16 at 15.31.54@2x.png

Copy link
Member Author

samuelstroschein commented Oct 16, 2024

EDIT: Haha nvm. We concluded that if the id function can detect the undefined snapshot, it will take the const EMPTY_SNAPSHOT_ID, reducing the need to handle empty snapshots in user land.

@martin.lysk1 inserting the nullable snapshot row does make sense in the schema.

Otherwise, detect changes has to insert an empty snapshot every time a delete change is detected.

CleanShot 2024-10-16 at 16.41.55@2x.png

The following is easier

  • check if a snapshot exists for the detected change
  • if yes, let the databsae generate the id, if not choose the empty snapshot id

CleanShot 2024-10-16 at 16.43.47@2x.png

Copy link
Member Author

Sync with @martin.lysk1

Decisions

  1. Snapshot.value is BLOB 
  2. snapshot gets no additional properties because content addressable 
  3. SDK inserts snapshot with cast as jsonb if plugin returns Record<string, any>
  4. utility function for testing jsonSnapshot 

CleanShot 2024-10-17 at [email protected]

Copy link
Member Author

image.png

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

1 participant