Ocaml bonsai partial render table: when ocaml only has partial data

  1. I am more familiar with the incremental partial render example than bonsai/examples/partial_render_table at master · janestreet/bonsai · GitHub – so apologies if I am getting things wrong.

  2. In my limited understanding, this solves the following problems: (a) we have 10,000 rows in OCaml; (b) we can only view 40 rows, and (c) we want to render the visible rows.

My question: is this easily adapted to the situation where OCaml itself does not have the full 10,000 rows in OCaml heap ?

For example, this could be a situation where the 10,000 rows is in some MySQL / Postgres db, which we do not load into OCaml/js all at once, but which OCaml/jjs only keeps say a 200 row “window” around the current view.

So the problem here is OCaml heap does not have the full data and we have to request it on demand.

Is it easy to modify the bonsai partial render table code for such situations ?

Thanks!

Yes, the table was actually designed with this use-case in mind. We call this “server-side rendering”. You need to use the the Expert module, which has this function. It takes a _ Collated.t that can be computed on the server and then sent over to the client. The result of that function contains the current visible range, which you need to keep sending back to the server so that it knows which rows to included in the collated data.