-
Notifications
You must be signed in to change notification settings - Fork 12
Conversation
5bff9a5
to
102908c
Compare
I added tests for NodeReader, and I believe it is ready to be used. I have a few things that I would still like to improve. @jbenet, tell me what you think of it.
Once this is done, I'd like to make sure that ipld implements the draft spec (and perhaps drop |
49fc5bd
to
feaaa98
Compare
Depends on:
It can't compile unless those pull requests are merged (especially the CBOR PR). |
this is looking like a great start. Im not sure that the interface here should look like. i wont know well until i use it for something... maybe we can make some examples if we want to accelerate that. |
I am not sure the interface should look like this either, but I thought I would take the closest interface I could have to the parsers, with as little overhead as possible. With the idea we could develop other interfaces more convenient for use if necessary. |
0a368f0
to
a3cb0a5
Compare
I am satisfied with the state of this PR. I think it is ready for review. Here is how the code is organized:
How you would want to use it:
The walk functions are in the memory package. I think we need to define what use case we want to have and then implement them for NodeReader in general. |
@jbenet could you look at that, or invite other people who might be interested in looking at this code? |
For example of use, see https://github.com/mildred/go-ipfs/commits/ipld-wip |
ee7b1d5
to
2d9d5bc
Compare
Requires whyrusleeping/cbor#4 |
Tests are failing for two reasons: the dependency on new features in the CBOR lib, and the dependency to JSON features that are in Go 1.5 but not 1.4 (json token reader) |
698a5d7
to
fd396c6
Compare
For Go 1.4, I vendored the |
@mildred lmk when you want review here |
The interface above was almost impossible to implement. I found a better interface that works (I got a first implementation):
|
e79e62c
to
ded931c
Compare
@jbenet @davidar, please review these commits. Don't hesitate to look at the code commit by commit. The commits are mostly independent and I rebased the whole thing so each commit stands on its own. Some features from last time are not included (they are still in the The basic interface in in I'm still not using the Also, implementing multicodecs without the |
(some tests are failing, this is a data race, I'll fix it, but that should not impact the review very much) |
317620b
to
f6617df
Compare
@mildred I can't comment on golang specifics |
I still havent reviewed the code sorry. Up front, i think the iterator route is great! much, much nicer to do that. I would go for: type NodeIterator interface {
Next() bool // in streaming implementations, automatically Skips all children iterators
Children() NodeIterator // instead of Iterate
Skip() // instead of abort.
Key() interface{}
Value() interface{}
} |
|
With code like: iter := iterateOverReader(reader)
printLinks(iter)
def printLinks(iter NodeIterator) {
for iter.Next() {
if c.Key() == "/" {
fmt.Println("found link to", c.Value())
}
printLinks(iter.Children())
}
} |
On Sat, 21 May 2016 22:26:51 -0700
The key can be an integer (for arrays) or a string (for maps/objects). Perhaps that could be separated in two functions (Key() and Index()). That should be easy, but what should Key() return on objects? Mildred Ki'Lya mildred@mildred.fr |
- add protocol buffer reader (and use the /mdagv1 multicodec prefix) - regenerate protocol buffer code - make the codec package stream oriented - remove use of the Multicodec type as it is buffer oriented - general cleanup
- Decode to the NodeReader interface - Add writeable support for JSON and CBOR from memory - Implement CBOR link tag for reading and writing - Force JSON & CBOR to be constructed from io.ReadSeeker - Ensure only one NodeReader is active at a single time NodeReader: test Skip and Abort for all readers (and fix it)
Need Go 1.5 for its new JSON features. Could be backported to Go 1.4 but IPFS is already limiting to Go 1.5
Until now I didn't see you wanted renames in the NodeInterface. I performed these. @jbenet, could you look into this PR, or tell me what I can do to help the review (splitting, ...). Every commit is understandable by itself if that can help. I take care to rebase my changes every time. Also, this PR is not up to date to the latest spec. In particular the link key is not yet "/" and the code still supports having attributes along with the link itself. I'd like to have it merged before updating these. These modifications are also pending on ipfs/specs#111. I'd like to implement it using proper EJSON. |
Hi @mildred, I've been playing with this branch a bit to try to see how I can help with go-ipld, since we're planning to use it in the mediachain project. I'm still learning my way around go, so I'll probably miss some obvious things :) I noticed that links aren't getting encoded to cbor tags, which seems to be because there's two Also the Overall this seems great, although I don't really know enough go for that opinion to have much weight 😄 I really like the Anyway, if there's anything I can help you with, please let me know. |
See issue #17
Do not merge yet, tests are still needed, and I would like to use this interface in some places instead of the Node type. This will allow implementations that do not require buffering the whole node in memory.