- 21 Mar, 2019 1 commit
-
-
Eric Myhre authored
We now have both MapIterator and ListIterator interfaces. Both return key-value (or index-value) pairs, rather than just keys. List iterators may seem a tad redundant: you just loop over the length, right? Well, sure. But there's one place a list iterator shines: selecting only a subset of elements. And indeed, we'll be doing exactly that in the traversal/selector package; therefore, we definitely need list iterators. We might want keys-only iterators again in the future, but at present, I'm deferring that. It's definitely true that we should have iterators returning values as a core feature, since they're likely to be more efficiently supportable than "random" access (especially when we get to some Advanced Layout data systems), so we'll implement those first. Additionally, note that MapIterator now returns a Node for the key. This is to account for that fact that when using the schema system and typed nodes, map keys can be more *specific* types. Such nodes are still required to be kind==ReprKind_String, but string might not be their *preferred* native format (think: tuples with serialized to be delimiter-separated strings); we need to account for that. (MapBuilder.Insert method already takes a Node parameter for similar reasons: so it can take *typed* nodes. Node.TraverseField accepting a plain string is the oddball out here, and should be rectified.) Signed-off-by: Eric Myhre <hash@exultant.us>
-
- 19 Mar, 2019 1 commit
-
-
Eric Myhre authored
Having a function called "Kind" return a "ReprKind" was inconsistent. Also, we want to introduce a "Kind" method on `typed.Node` in the future. No logical content to this change: you can safely refactor with sed. Signed-off-by: Eric Myhre <hash@exultant.us>
-
- 16 Mar, 2019 1 commit
-
-
Eric Myhre authored
We now have CIDs support! You can create links backed by cids, and marshal them with dag-cbor; and you can unmarshal cbor data with dag-cbor and expect things with the CID link tag to be parsed into CIDs and exposed as IPLD Links. Yay! (Dag-json is lagging. The parse for those links is... more involved. When supported, it'll similarly have its own unmarshal and marshal just like the ones this diff introduces for dag-cbor.) Signed-off-by: Eric Myhre <hash@exultant.us>
-
- 21 Feb, 2019 1 commit
-
-
Eric Myhre authored
We have both generic marshal and unmarshal -- they should work for any current or future ipld.Node implementation, and for any encoding mechanism that can be bridged to via refmt tokens. Tests are also updated to use builders rather than the ancient "mutable node" nonsense, which removes... I think nearly the last incident of that stuff; maybe we can remove it entirely soon. As when we moved the unmarshal code into its generic form, most of this code already existed and needed minor modification. Git even correctly detects it as a rename this time since the diff is so small. And as when we moved the unmarshal code, now we also remove the whole PushTokens interface; we've gotten to something better now. Finally we're getting to the point we can look at wiring these up together with all the multicodec glue and get link loading wizardry at full voltage. Yesss. Sooon. Signed-off-by: Eric Myhre <hash@exultant.us>
-
- 20 Feb, 2019 1 commit
-
-
Eric Myhre authored
This unmarshal works for any NodeBuilder implementation, tada! Old ipldfree.Node-specific unmarshal dropped... as well as that entire system of interfaces. They were first-pass stuff, and I think now it's pretty clear that it was barking up the wrong tree, and we've got better ideas to go with now instead. (Also, as is probably obvious from a skim, the old code flipped pretty clearly into the new code.) Turns out refmt tokens aren't a very relevant interface in IPLD. I'm still using them... internally, to wire up the CBOR and JSON parsers without writing those again. But the rest of IPLD is more like a full-on and principled alternative to refmt/obj and all its reflection code, and that's... pretty great. Earlier, I had a suspicion that we would want more interfaces for token handling on each Node implementation directly, and in particular I suspected we might use those token-based interfaces for doing transcription features that flip data from one concrete Node implementation into another. (That's why we had this ipldfree.Node-specialized impl in the first place.) **This turns out to have been wrong!** Instead, now that we have the ipld.NodeBuilder interface standard, that turns out to be much better suited to solving the same needs, and it can do so: - without adding tokens to the picture (simpler), - without requiring tokenization-based interfaces be implemented per concrete ipld.Node implementation (OH so much simpler), - and arguably NodeBuilder is even doing it *better* because it doesn't need to force linearization (and while usually that doesn't matter... one can perhaps imagine it coming up if we wanted to do a data transcription in memory into a Node implementation which has an orderings requirement). So yeah, this is a nice thing to have been wrong about. Much simpler now. Old ipldfree.Node-specialized 'PushTokens' is still around. Not for long, though; it just hasn't finished being ported to the new properly generalized style quite yet. Note, this is not the *whole* story, still, either. For example, still expect to have an ipldcbor.Node which someday has a *significantly* different set of marshal and unmarshal methods -- it may eschew refmt entirely, and take the (very) different strategy of building a skiplist over raw byte slices! -- that will exist *in addition* to the generic implementations we're doing here and now. More on that soon. Yeah. A lot of interfaces to get lined up, here. Some of them tug in such different directions that picking the right ones to make it all possible seems roughly like solving one of the NP-hard satisfiability problems. (Good thing it's actually with a small enough number of choices that it's tractable; on the other hand, enumerating those choices isn't fast, and the 'verifier' function here ain't fast either, and being a "design" thing, it can only be evaluated on human wetware. So yeah, an NP problem on a tractable domain but slow setup and slow verifier. Sounds about right.) (uh, I'm going to write a book "Design: It's Hard: The Novel" after this.) Tests are patched enough to keep working where they are; I think it's possible that a reshuffle of some of them to be more closely focused on the marshal code rather than the node implementation packages might be in order, but I'm going to let that be a future issue. (Oh, and they did shine a light on one quick issue about MapBuilder initialization, which is also now fixed.) Signed-off-by: Eric Myhre <hash@exultant.us>
-
- 05 Feb, 2019 2 commits
-
-
Eric Myhre authored
Hej, we can finally unmarshal things again. Plug a cbor parser in from the refmt library and go go go! This doesn't use any of the mutablenode stuff because, as remarked upon a (quite a) few commits back, we want to replace that with NodeBuilder interfaces; but, furthermore, we actually don't *need* those interfaces for anything in an unmarshalling path (because I don't expect we'll seriously need to switch result Node impl in mid-unmarshalling stream); so. You can imagine that the cbor.Node system will have a *very* different implementation of this interface (and probably another method that doesn't match this interface at all, and is more directly byte stream based); but that's for later work. And tests! Signed-off-by: Eric Myhre <hash@exultant.us>
-
Eric Myhre authored
Signed-off-by: Eric Myhre <hash@exultant.us>
-
- 10 Jan, 2019 1 commit
-
-
Eric Myhre authored
You could now readily rig up the ipldfree.Node implementation to a refmt cbor.TokenSink, for example, and go to town. (At the moment, doing so is left as an exercise to the reader. We'll make that a smooth built-in/one-word function at some point, but I'm not yet sure exactly how that should look, so it's deferred for now.) While working on this, a lot of other things are cooking on simmer: I'm churning repeatedly over a lot of thoughts about A) API semantics in general, B) how to cache CIDs of nodes, and C) how to memoize serializations / reduce memcopies during partial tree updates... And (unsurprisingly) I keep coming back to the conclusion that the API for dang near everything should be immutable at heart in order to keep things sane. The problem is figuring out how to pursue this A) efficiently, B) in tandem with reasonably low-friction nativeness (i.e. I want autocompletion in a standard golang editor to be as useful as possible!), and C) given an (as yet) lack of good builder or mutation-applier patterns. ipldbind was meant to be a solution to the majority of the B and C issues there, but that rubs smack against the grain of "let's be immutable" in golang >:/ So... a rock and a hard place, in short. Signed-off-by: Eric Myhre <hash@exultant.us>
-