-
Notifications
You must be signed in to change notification settings - Fork 30
IPLD Selector #12
Comments
It might be good to design the path traversals as an abstract syntax tree first. They are easy to create and manipulate in programming languages (without invoking a parser in runtime) and they are what binary (de)serializers input/output. When the perfect AST structure is established, that would be a good time to specify a corresponding regexp/glob/XPath-like notation. Since the AST is already set in stone, no character that is ordinary now and does not need to be escaped in path components will become special later and silently break existing expressions. (Alternatively, specify a “multitraversal” notation which indicates its version.) Here’s pseudocode for the AST data types for some of the traversals that would be nice to have. This should map to actual code in any modern programming language rather trivially. data Pattern = Pattern Reference [Traversal]
data Traversal = Glob [Glob]
| RecursiveStar
| Count Natural [Traversal]
| CountMin Natural [Traversal]
| Dereference Pattern
data Glob = Literal String
| Star Some pseudocode expressions using the data types defined above: Pattern ref []
Pattern ref [Glob [Star]]
Pattern ref [RecursiveStar]
Pattern ref [Glob [Star], "bar", RecursiveStar]
Pattern ref [Glob ["foo", Star], Glob [Star, "bar", Star]]
Pattern ref [Count 10 ["parent"], "foo"]
Pattern ref ["movie.mp4", CountMin 1 ["chunks", "0"], Glob [Star]]
Pattern ref1 [Dereference (Pattern ref2 ["followers", "20", "username"])] |
more desired expressions:
|
@ion1 haha i posted these before i read your examples-- nice! and nice AST |
it is looking like XPath has the wanted functionality here. Wonder if there is an XPath subset that's way simpler. |
XPath pros:
XPath cons:
XPath Questions:
|
cc @mildred thoughts? think |
Or do we use JSONPath? http://goessner.net/articles/JsonPath/ https://jsonpath.curiousconcept.com/ likely JSONPath wont work with all the things we may have in ipld? |
The problem I have with XPath is that it is designed to work on XML document semantic. Those have attributes, nodes and a few other oddities that XPath can query. Moreover, it is quite complex. JSONPath seems better to me. It fits the data model more closely. We will probably want to extend it to be able to traverse merkle links. We could use JSONPath doesn't specify a language for expressions. We might want to define a common language for all implementations. |
cc @nicolagreco this is the "IPLD Selector" placeholder issue. we should discuss it more here. |
interesting thought: graphql.org |
Seems like xpath from xslt might be informative james mcfarland
|
TODO eval
|
We are going to have a conversation in Lisbon during the IPFS workshop, this document is listing some points that may be relevant to the conversation. Once the conversation is done, I am going to do a write up. |
It is ideal to have a path notation (for use in bitswap and other tools) that allows expressing ranges of objects and queries.
<path>/*/**
<path>~10
<path>~10:<path>~5
<path>/foo*/*bar*
<path>/[a-z]+
...links:
The text was updated successfully, but these errors were encountered: