Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote NodeAssembler/NodeStyle interface rework to core, and use improved basicnode implementation. #49

Merged
merged 12 commits into from
Mar 27, 2020
Merged
12 changes: 6 additions & 6 deletions _rsrch/nodesolution/HACKME.md → HACKME.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ appropriately converted.)

Any of these paths counts as "recursive assembly process":

- `MapNodeAssembler.KeyStyle()`
- `MapNodeAssembler.ValueStyle(string)`
- `MapNodeAssembler.AssembleKey().Style()`
- `MapNodeAssembler.AssembleValue().Style()`
- `ListNodeAssembler.ValueStyle()`
- `ListNodeAssembler.AssembleValue().Style()`
- `MapAssembler.KeyStyle()`
- `MapAssembler.ValueStyle(string)`
- `MapAssembler.AssembleKey().Style()`
- `MapAssembler.AssembleValue().Style()`
- `ListAssembler.ValueStyle()`
- `ListAssembler.AssembleValue().Style()`

### NodeStyle for carrying ADL configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ high level rules of builders and assemblers
- Errors should be returned as soon as possible.
- That means an error like "repeated key in map" should be returned by the key assembler!
- Either 'NodeAssembler.AssignString' should return this (for simple keys on untyped maps, or on structs, etc)...
- ... or 'MapNodeAssembler.Finish' (in the case of complex keys in a typed map).
- ... or 'MapAssembler.Finish' (in the case of complex keys in a typed map).

- Logical integrity checks must be done locally -- recursive types rely on their contained types to report errors, and the recursive type wraps the assemblers of their contained type in order to check and correctly invalidate/rollback the recursive construction.

Expand Down Expand Up @@ -40,8 +40,8 @@ but the caller tries to continue anyway.
- assigning a key with 'AssembleKey':
- in case of success: clearly 'AssembleValue' should be ready to use next.
- in case of failure from repeated key:
- the error must be returned immediately from either the 'NodeAssembler.AssignString' or the 'MapNodeAssembler.Finish' method.
- 'AssignString' for any simple keys; 'MapNodeAssembler.Finish' may be relevant in the case of complex keys in a typed map.
- the error must be returned immediately from either the 'NodeAssembler.AssignString' or the 'MapAssembler.Finish' method.
- 'AssignString' for any simple keys; 'MapAssembler.Finish' may be relevant in the case of complex keys in a typed map.
- implementers take note: this implies the `NodeAssembler` returned by `AssembleKey` has some way to refer to the map assembler that spawned it.
- no side effect should be visible if 'AssembleKey' is called again next.
- (typically this doesn't require extra code for the string case, but it may require some active zeroing in the complex key case.)
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ The most central interfaces are the base package,
but you'll certainly need to import additional packages to get concrete implementations into action.

Roughly speaking, the core package interfaces are all about the IPLD Data Model;
the encoding packages contain some codecs, and turn serial data into Data Model;
the codec packages contain functions for parsing serial data into the IPLD Data Model,
and converting Data Model content back into serial formats;
the traversal package is an example of higher-order functions on the Data Model;
concrete 'Node' implementations ready to use can be found under 'impl/*';
and several additional packages contain advanced features such as IPLD Schemas.
Expand All @@ -31,9 +32,9 @@ or new codecs, or new higher-order order functions!)
- `github.com/ipld/go-ipld-prime/impl/cbor` -- imported as `ipldcbor` -- provides concrete implementations of `Node` and `NodeBuilder` which have some special features to accelerate certain workloads with CBOR.
- `github.com/ipld/go-ipld-prime/traversal` -- contains higher-order functions for traversing graphs of data easily.
- `github.com/ipld/go-ipld-prime/traversal/selector` -- contains selectors, which are sort of like regexps, but for trees and graphs of IPLD data!
- `github.com/ipld/go-ipld-prime/encoding` -- parent package of all the codec implementations!
- `github.com/ipld/go-ipld-prime/encoding/dagcbor` -- implementations of marshalling and unmarshalling as CBOR (a fast, binary serialization format).
- `github.com/ipld/go-ipld-prime/encoding/dagjson` -- implementations of marshalling and unmarshalling as JSON (a popular human readable format).
- `github.com/ipld/go-ipld-prime/codec -- parent package of all the codec implementations!
- `github.com/ipld/go-ipld-prime/codec/dagcbor` -- implementations of marshalling and unmarshalling as CBOR (a fast, binary serialization format).
- `github.com/ipld/go-ipld-prime/codec/dagjson` -- implementations of marshalling and unmarshalling as JSON (a popular human readable format).
- `github.com/ipld/go-ipld-prime/linking/cid` -- imported as `cidlink` -- provides concrete implementations of `Link` as a CID. Also, the multicodec registry.
- `github.com/ipld/go-ipld-prime/schema` -- contains the `schema.Type` and `schema.TypedNode` interface declarations, which represent IPLD Schema type information.
- `github.com/ipld/go-ipld-prime/impl/typed` -- provides concrete implementations of `schema.TypedNode` which decorate a basic `Node` at runtime to have additional features described by IPLD Schemas.
Expand Down
14 changes: 7 additions & 7 deletions _rsrch/nodeassembler/nodeAssembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Maybe. Let's see.
*/

type NodeAssembler interface {
BeginMap() MapNodeAssembler
BeginList() ListNodeAssembler
BeginMap() MapAssembler
BeginList() ListAssembler
AssignNull()
AssignBool(bool)
AssignInt(int)
Expand All @@ -45,7 +45,7 @@ type NodeAssembler interface {
CheckError() error // where are these stored? when each child is done, could check this. and have it stored in each child. means each allocs (nonzero struct)... but isn't that true anyway? yeah. well, except now you're apparently getting that for scalars, which is bad.
}

type MapNodeAssembler interface {
type MapAssembler interface {
AssembleKey() MapKeyAssembler

Insert(string, Node)
Expand All @@ -61,7 +61,7 @@ type MapValueAssembler interface {
NodeAssembler
}

type ListNodeAssembler interface {
type ListAssembler interface {
AssembleValue() NodeAssembler

Append(Node)
Expand All @@ -80,9 +80,9 @@ type Node interface {

func demo() {
var nb NodeBuilder
func(mb MapNodeAssembler) {
func(mb MapAssembler) {
mb.AssembleKey().AssignString("key")
func(mb MapNodeAssembler) {
func(mb MapAssembler) {
mb.AssembleKey().AssignString("nested")
mb.AssembleValue().AssignBool(true)
mb.Done()
Expand Down Expand Up @@ -129,6 +129,6 @@ Notes:
- a natively-typed assign method that works by value is the only way to minimize all the costs at once.
- we do still need it though: `Assign2(Node,Node)` is the only way to copy an existing typed map key generically (without the temp-copy lamented above for the `AssembleKey.Assign` chain).
- the `Append` and `Assign` method names might be too terse -- we didn't leave space for the natively typed methods, which we generally want to be the shortest ones.
- 'Assign' being a symbol on both NodeAssemler and MapNodeAssembler with different arity might be unfortunate -- would make it impossible to supply both with one concrete type.
- 'Assign' being a symbol on both NodeAssemler and MapAssembler with different arity might be unfortunate -- would make it impossible to supply both with one concrete type.

*/
10 changes: 0 additions & 10 deletions _rsrch/nodesolution/doc.go

This file was deleted.

80 changes: 0 additions & 80 deletions _rsrch/nodesolution/errors.go

This file was deleted.

1 change: 0 additions & 1 deletion _rsrch/nodesolution/kind.go

This file was deleted.

4 changes: 0 additions & 4 deletions _rsrch/nodesolution/link.go

This file was deleted.

Loading