nickva commented on code in PR #6050:
URL: https://github.com/apache/couchdb/pull/6050#discussion_r3492546794


##########
src/couch/src/couch_ejson_compare.erl:
##########
@@ -58,6 +60,35 @@ less_json_ids({JsonA, IdA}, {JsonB, IdB}) ->
 less_json(A, B) ->
     less(A, B) < 0.
 
+% Encode ejson to terms with native `less` ordering matching less/2 ICU
+% collation order. The leading integer is the ejson object rank see [1]. The
+% collection order is:
+%
+%   null < false < true < num < str < array < object
+%
+% Sort keys should not be stored or compared against sort key generated by
+% other major libicu version. The intent so to use these only at runtime, in
+% memory on the same node (on the coordinator mostly likely when merge-sorting
+% incoming view rows).
+%
+% [1] 
https://docs.couchdb.org/en/stable/ddocs/views/collation.html#collation-specification
+%
+sort_key(null) -> {0};

Review Comment:
   I borrowed the idea from the FDB sort key implementation 
https://github.com/apache/couchdb/blob/fa5ef27e24a4f24ea0cbb8ca0474e0b169131b8c/src/couch_views/src/couch_views_encoding.erl#L44-L77



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to