ff-notes / ron

Haskell implementation of RON and RON-RDT
BSD 3-Clause "New" or "Revised" License
65 stars 9 forks source link

Add RGA.getAliveRefs #126

Closed mputz86 closed 4 years ago

mputz86 commented 4 years ago

Added method to get ObjectRefs out of a recursive RGA structure.

Is this correct and does it make sense?


This change is Reviewable

cblp commented 4 years ago

Could you describe a use-case for this?

mputz86 commented 4 years ago

Could you describe a use-case for this?

Sure: I have a LWW, where the structure occurs recursively in the RGA. In the UI I get the root of the structure and with the getAliveRefs I can get the children and show them (not just the indices). Moreover, I need the children's UUIDs in order to do random access within the "RootObjectFrame" to manipulate the children. Does this already make sense? :) Is there a better way to achieve this?

cblp commented 4 years ago

Yes, it makes some sense.

This will be merged.

But, do you actually want the whole tree (or graph) inside one document? Wouldn't it be better to put each layer in its own document?

If you use such schema:

(struct_set Node
  subnodes (RGA (ObjectRef Node)))

then you can put into subnodes references to nodes, whose values are located in other documents.

mputz86 commented 4 years ago

then you can put into subnodes references to nodes, whose values are located in other documents.

Good point. I don't need the whole graph, but for now, it is convenient (I can either traverse the real tree, or use the refs). Later I guess it would be great to fetch only "up to a certain depth" from a starting point. So... I guess splitting in different documents already would be a future-proof approach.

So: If I do it as you said, this method will become superfluous in my case, maybe not for others?

cblp commented 4 years ago

I'm thinking of getting rid of documents and object frames at all.

cblp commented 4 years ago

...leaving ObjectRef as the only option.

mputz86 commented 4 years ago

...leaving ObjectRef as the only option.

This seems to me to fit well with database models like NoSQL. So the expected way to handle, query and update the data.

cblp commented 4 years ago

In NoSQL databases like Mongo it's completely OK to have small arrays and dictionaries right inside documents.

cblp commented 4 years ago

Yes, it makes some sense. This will be merged.

Well, I think, no.

mputz86 commented 4 years ago

In NoSQL databases like Mongo it's completely OK to have small arrays and dictionaries right inside documents.

I guess we are thinking about different applications. So in my case I would have a rather big and huge tree - so loading and getting all at once is not desired.

Yes, it makes some sense. This will be merged.

Well, I think, no.

:)

cblp commented 4 years ago

in my case I would have a rather big and huge tree

Then RGA (ObjectRef Node) field type is strongly recommended.