You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Julian Reschke <ju...@gmx.de> on 2011/12/09 11:06:45 UTC

Re: [Jackrabbit Wiki] Update of "Jsop" by ThomasMueller

On 2011-12-09 10:06, Apache Wiki wrote:
> Dear Wiki user,
>
> You have subscribed to a wiki page or wiki category on "Jackrabbit Wiki" for change notification.
>
> The "Jsop" page has been changed by ThomasMueller:
> http://wiki.apache.org/jackrabbit/Jsop?action=diff&rev1=28&rev2=29
>
> Comment:
> Preserve order of child nodes
>
>    '''addNodeDiff:'''
>     * + pathString: object
>
> + The added node may contain child nodes. The order of child node is preserved, that means, when requesting the object, the child nodes will appear in the same order as they appear when the node was added. This only applies to child nodes however; it does not apply to the order of properties. For example, an implementation may sort the properties by name.
> +
 > ...

Not sure this is a good idea, as long as we pretend that this format has 
something to do with JSON. The main purpose of JSON is that the objects 
can be instantiated again in JavaScript, at which point the ordering 
becomes undefined.

Best regards, Julian

Re: [Jackrabbit Wiki] Update of "Jsop" by ThomasMueller

Posted by Michael Dürig <md...@apache.org>.
On 9.12.11 11:09, Julian Reschke wrote:
>>> Not sure this is a good idea, as long as we pretend that this format has
>>> something to do with JSON. The main purpose of JSON is that the objects
>>> can be instantiated again in JavaScript, at which point the ordering
>>> becomes undefined.
>>
>> If one possible *client* isn't interested in the order, then that's not a
>> problem. The problem is that the *server* should keep the order, so that
>
> The problem here is that we pretend that part of the syntax use JSON,
> which implies you can use off-the-shelve JSON code to produce or consume
> these parts. But you can't if you pretend that JSON object members have
> an ordering.
>
>> clients that are interested in the order can work. Otherwise "move" with
>> "before" / "after" isn't that meaningful.
>
> For now, JSON Patch allows moving *to* locations that can be identified
> by JSON Pointers, so within the hierarchy and within arrays, but that
> doesn't affect the ordering of non-array members.
>
>> What about making it an optional feature ("may")? It still possible for a
>> client to define the order using many "move" calls, but it's a bit
>> strange
>> I have admit:
>>
>> + "/test": {"a": {}, "b": {}, "c": {}}
>>> "/test/b": { "after": "/test/a" }
>>> "/test/c": { "after": "/test/b" }
>>
>>
>> This will ensure the order is "a", "b", "c".
>
> -1, if this is supposed to be a generic format for use outside
> Jackrabbit. But I'm starting to believe it's not.
>
> To make it a generic format, it needs to make sense in terms of mapping
> a JCR hierarchy to JSON, and operations *applied* to JSON.
>
> *If* we want to support ordered collections, than the JSON mapping
> should contain additional information on the sort order of the members.
> Like this:
>
> {"a": {}, "b": {}, "c": {}, "{somejcrrelateduri}sortorder": [ "a", "b",
> "c" ] }

Ack. This would make the order explicit where it is required. It'd also 
nicely map to JCR's orderable attribute.

Besides, this might also better mach upcoming JCR implementations: if we 
want to support huge child node lists *and* have them orderable, we will 
most likely have to do away with the linked hash map we are using at the 
moment and rather store the permutation along with the child node list 
(much like an index).

Michael


Re: [Jackrabbit Wiki] Update of "Jsop" by ThomasMueller

Posted by Michael Dürig <md...@apache.org>.

On 9.12.11 11:23, Thomas Mueller wrote:
> Hi,
>
>> if this is supposed to be a generic format for use outside
>> Jackrabbit. But I'm starting to believe it's not.
>
>> *If* we want to support ordered collections, than the JSON mapping
>> should contain additional information on the sort order of the members.
>> Like this:
>>
>> {"a": {}, "b": {}, "c": {}, "{somejcrrelateduri}sortorder": [ "a", "b",
>> "c" ] }
>
> -1 that's too weird for me. Also, duplicating data is always problematic.
>
> I would rather say ordering is optional, and within Jackrabbit 3 we just
> happen to support it. At least as long as orderable child nodes need to be
> supported. Which, in my view, doesn't need to be the case. I would just
> define that the order is undefined. File systems don't define an order
> either either, and people don't seem to have a problem with that. If the
> shell or a GUI tool orders them by name, and if they are ordered by name
> on the server because the server uses a b-tree, then that's fine. But I
> think it should not be required standard behavior.
>
> I guess I should create an issue request in JSR-333.

I don't think this is necessary since orderable child nodes are optional 
[1].

Michael

[1] http://www.day.com/specs/jcr/2.0/23_Orderable_Child_Nodes.html



Re: [Jackrabbit Wiki] Update of "Jsop" by ThomasMueller

Posted by Michael Dürig <md...@apache.org>.

On 9.12.11 11:51, Julian Reschke wrote:
>>>> *If* we want to support ordered collections, than the JSON mapping
>>>> should contain additional information on the sort order of the members.
>>>> Like this:
>>>>
>>>> {"a": {}, "b": {}, "c": {}, "{somejcrrelateduri}sortorder": [ "a", "b",
>>>> "c" ] }
>>>
>>> -1 that's too weird for me. Also, duplicating data is always
>>> problematic.
>>
>> What about
>>
>> {[{"a": {}}, {"b": {}}, {"c": {}}]}
>>
>> ? ;-)
>
> Cute, but will make JSON Pointers complicated - so we would trade a
> usable pointer notation for a more compact object representation.

Right, I wasn't too serious about this. I'd rather go with the explicit 
specification of the order as you proposed.

Michael

Re: [Jackrabbit Wiki] Update of "Jsop" by ThomasMueller

Posted by Julian Reschke <ju...@gmx.de>.
On 2011-12-09 12:32, Michael Dürig wrote:
>
>
> On 9.12.11 11:23, Thomas Mueller wrote:
>> Hi,
>>
>>> if this is supposed to be a generic format for use outside
>>> Jackrabbit. But I'm starting to believe it's not.
>>
>>> *If* we want to support ordered collections, than the JSON mapping
>>> should contain additional information on the sort order of the members.
>>> Like this:
>>>
>>> {"a": {}, "b": {}, "c": {}, "{somejcrrelateduri}sortorder": [ "a", "b",
>>> "c" ] }
>>
>> -1 that's too weird for me. Also, duplicating data is always problematic.
>
> What about
>
> {[{"a": {}}, {"b": {}}, {"c": {}}]}
>
> ? ;-)

Cute, but will make JSON Pointers complicated - so we would trade a 
usable pointer notation for a more compact object representation.

Best regards, Julian

Re: [Jackrabbit Wiki] Update of "Jsop" by ThomasMueller

Posted by Michael Dürig <md...@apache.org>.

On 9.12.11 11:23, Thomas Mueller wrote:
> Hi,
>
>> if this is supposed to be a generic format for use outside
>> Jackrabbit. But I'm starting to believe it's not.
>
>> *If* we want to support ordered collections, than the JSON mapping
>> should contain additional information on the sort order of the members.
>> Like this:
>>
>> {"a": {}, "b": {}, "c": {}, "{somejcrrelateduri}sortorder": [ "a", "b",
>> "c" ] }
>
> -1 that's too weird for me. Also, duplicating data is always problematic.

What about

{[{"a": {}}, {"b": {}}, {"c": {}}]}

? ;-)

Michael

Re: [Jackrabbit Wiki] Update of "Jsop" by ThomasMueller

Posted by Julian Reschke <ju...@gmx.de>.
On 2011-12-09 12:23, Thomas Mueller wrote:
> Hi,
>
>> if this is supposed to be a generic format for use outside
>> Jackrabbit. But I'm starting to believe it's not.
>
>> *If* we want to support ordered collections, than the JSON mapping
>> should contain additional information on the sort order of the members.
>> Like this:
>>
>> {"a": {}, "b": {}, "c": {}, "{somejcrrelateduri}sortorder": [ "a", "b",
>> "c" ] }
>
> -1 that's too weird for me. Also, duplicating data is always problematic.
> ...

Well, it's required if you want to be able to produce these documents 
using a JavaScript implementation. If that's not a goal, we may want to 
state that somewhere.

Best regards, Julian

Re: [Jackrabbit Wiki] Update of "Jsop" by ThomasMueller

Posted by Thomas Mueller <mu...@adobe.com>.
Hi,

>if this is supposed to be a generic format for use outside
>Jackrabbit. But I'm starting to believe it's not.

>*If* we want to support ordered collections, than the JSON mapping
>should contain additional information on the sort order of the members.
>Like this:
>
>{"a": {}, "b": {}, "c": {}, "{somejcrrelateduri}sortorder": [ "a", "b",
>"c" ] }

-1 that's too weird for me. Also, duplicating data is always problematic.

I would rather say ordering is optional, and within Jackrabbit 3 we just
happen to support it. At least as long as orderable child nodes need to be
supported. Which, in my view, doesn't need to be the case. I would just
define that the order is undefined. File systems don't define an order
either either, and people don't seem to have a problem with that. If the
shell or a GUI tool orders them by name, and if they are ordered by name
on the server because the server uses a b-tree, then that's fine. But I
think it should not be required standard behavior.

I guess I should create an issue request in JSR-333.

Regards,
Thomas


Re: [Jackrabbit Wiki] Update of "Jsop" by ThomasMueller

Posted by Julian Reschke <ju...@gmx.de>.
On 2011-12-09 11:32, Thomas Mueller wrote:
> Hi,
>
>> Not sure this is a good idea, as long as we pretend that this format has
>> something to do with JSON. The main purpose of JSON is that the objects
>> can be instantiated again in JavaScript, at which point the ordering
>> becomes undefined.
>
> If one possible *client* isn't interested in the order, then that's not a
> problem. The problem is that the *server* should keep the order, so that

The problem here is that we pretend that part of the syntax use JSON, 
which implies you can use off-the-shelve JSON code to produce or consume 
these parts. But you can't if you pretend that JSON object members have 
an ordering.

> clients that are interested in the order can work. Otherwise "move" with
> "before" / "after" isn't that meaningful.

For now, JSON Patch allows moving *to* locations that can be identified 
by JSON Pointers, so within the hierarchy and within arrays, but that 
doesn't affect the ordering of non-array members.

> What about making it an optional feature ("may")? It still possible for a
> client to define the order using many "move" calls, but it's a bit strange
> I have admit:
>
> + "/test": {"a": {}, "b": {}, "c": {}}
>> "/test/b": { "after": "/test/a" }
>> "/test/c": { "after": "/test/b" }
>
>
> This will ensure the order is "a", "b", "c".

-1, if this is supposed to be a generic format for use outside 
Jackrabbit. But I'm starting to believe it's not.

To make it a generic format, it needs to make sense in terms of mapping 
a JCR hierarchy to JSON, and operations *applied* to JSON.

*If* we want to support ordered collections, than the JSON mapping 
should contain additional information on the sort order of the members. 
Like this:

{"a": {}, "b": {}, "c": {}, "{somejcrrelateduri}sortorder": [ "a", "b", 
"c" ] }

Best regards, Julian



Re: [Jackrabbit Wiki] Update of "Jsop" by ThomasMueller

Posted by Thomas Mueller <mu...@adobe.com>.
Hi,

>Not sure this is a good idea, as long as we pretend that this format has
>something to do with JSON. The main purpose of JSON is that the objects
>can be instantiated again in JavaScript, at which point the ordering
>becomes undefined.

If one possible *client* isn't interested in the order, then that's not a
problem. The problem is that the *server* should keep the order, so that
clients that are interested in the order can work. Otherwise "move" with
"before" / "after" isn't that meaningful.


What about making it an optional feature ("may")? It still possible for a
client to define the order using many "move" calls, but it's a bit strange
I have admit:

+ "/test": {"a": {}, "b": {}, "c": {}}
> "/test/b": { "after": "/test/a" }
> "/test/c": { "after": "/test/b" }


This will ensure the order is "a", "b", "c".

Regards,
Thomas