-
Notifications
You must be signed in to change notification settings - Fork 12
Replace the Node type (which is a map) with an interface ? #17
Comments
|
No problem for that
The new The idea is that the functions of this new
I wasn't planning on removing it. As this is higher level, it would be implemented on top, or alongside the other functions.
This needs to be possible of course. A simple solution would be to use the |
I am working on my fork (the break branch) on an implementation of that (and everything else). There, I created an implementation of the reader interface for JSON and for CBOR. Works great! |
Fantastic! :) 👍 |
Currently, the
Node
type is defined as :This makes all IPLD users very dependent on the implementation of the Node object, and forces IPLD to parse everything on the JSON/CBOR data to put it in the map. The alternative is to provide only a handle on the data and decode it on demand, and let the Node consumer store just the things he needs.
Say an application just need some small keys on many Node objects which otherwise are also containing huge chunks of data. We can imagine a mode of operation where the huge data is left on the disk while the file is merely traversed to look for the small keys the application needs. The big data shouldn't need to be kept on memory if we don't use it.
To allow this, I'd propose to make
Node
an interface equipped with a walk function (that would walk the JSON-like data structure, not local paths as the current walk function does) :And then:
An example of decoding the following JSON:
Would result in the walk function being called this way:
This would be a very low level block that will be used to implement higher level functions, like path walking within an object, or decoding to application specific formats.
To provide compatibility with ipfs/merkledag, we could add to the interface a few functions:
The
Links
andData
function would traverse the object using the walk function to provide a list of links and the data bytes required for ipfs/merkledag users.The text was updated successfully, but these errors were encountered: