Re: [Cbor] "ordered hash"

Michael Richardson <mcr+ietf@sandelman.ca> Fri, 31 July 2020 17:34 UTC

Return-Path: <mcr+ietf@sandelman.ca>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id ECC9F3A0BD5 for <cbor@ietfa.amsl.com>; Fri, 31 Jul 2020 10:34:13 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.898
X-Spam-Level:
X-Spam-Status: No, score=-1.898 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mBQWXGoTd803 for <cbor@ietfa.amsl.com>; Fri, 31 Jul 2020 10:34:11 -0700 (PDT)
Received: from tuna.sandelman.ca (tuna.sandelman.ca [209.87.249.19]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id A73BF3A0BD1 for <cbor@ietf.org>; Fri, 31 Jul 2020 10:34:11 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1]) by tuna.sandelman.ca (Postfix) with ESMTP id 23A4C389AE; Fri, 31 Jul 2020 13:13:26 -0400 (EDT)
Received: from tuna.sandelman.ca ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with LMTP id nTrF8ZF8a9ge; Fri, 31 Jul 2020 13:13:20 -0400 (EDT)
Received: from sandelman.ca (unknown [209.87.249.21]) by tuna.sandelman.ca (Postfix) with ESMTP id E8B6038998; Fri, 31 Jul 2020 13:13:19 -0400 (EDT)
Received: from localhost (localhost [IPv6:::1]) by sandelman.ca (Postfix) with ESMTP id 70D88319; Fri, 31 Jul 2020 13:33:34 -0400 (EDT)
From: Michael Richardson <mcr+ietf@sandelman.ca>
To: Carsten Bormann <cabo@tzi.org>, Kio Smallwood <kio@mothers-arms.co.uk>, cbor@ietf.org, Brendan Moran <Brendan.Moran@arm.com>
In-Reply-To: <CB724CD0-52AC-4036-B5BA-70D7F056E4B6@tzi.org>
References: <25163.1596045376@localhost> <DA6A1A7E-59E8-42C9-A294-7D23BFD4BF0A@arm.com> <0A0FEABF-ADF2-4342-9AC3-42F768F14CCF@mothers-arms.co.uk> <CB724CD0-52AC-4036-B5BA-70D7F056E4B6@tzi.org>
X-Mailer: MH-E 8.6+git; nmh 1.7+dev; GNU Emacs 26.1
X-Face: $\n1pF)h^`}$H>Hk{L"x@)JS7<%Az}5RyS@k9X%29-lHB$Ti.V>2bi.~ehC0; <'$9xN5Ub# z!G,p`nR&p7Fz@^UXIn156S8.~^@MJ*mMsD7=QFeq%AL4m<nPbLgmtKK-5dC@#:k
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-="; micalg="pgp-sha512"; protocol="application/pgp-signature"
Date: Fri, 31 Jul 2020 13:33:34 -0400
Message-ID: <28261.1596216814@localhost>
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/zw3xsYviJkyao8irTSkEczGDpLI>
Subject: Re: [Cbor] "ordered hash"
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 31 Jul 2020 17:34:14 -0000

Carsten Bormann <cabo@tzi.org> wrote:
    > By using the exact structure of a map (except that the array head will
    > have double the argument that the map head has), we can save 1 byte per
    > k/v pair (“flattened alist”):

    > FAList<K, V> = [* (K, V)]

    > So [[“a”, 1], [“b”, 2]] becomes [“a”, 1, “b”, 2]

    > I’m not sure which of these MCR was inquiring on.  The first is
    > definitely an alist, and there is no need for a new term.  The second
    > can be called an ordered multimap, but there are other structures that
    > also deserve this name.

I am definitely referring to this.
"flattened alist" is a new term to me, and I'm mostly happen with this term.
I am unclear what the "second one" is.

I think that:
 Alist: [[“a”, 1], [“b”, 2]]
 flatened alist: [“a”, 1, “b”, 2]

    > OMList<K, V> = [* (K, [2* V] / V)]

    > So [[“aaa”, 1], [“aaa”, 2], [“bbb”, 3]] becomes [“aaa”, [1, 2], “bbb”, 3]

It's an optimization which is not preserve the order.
That is:
   [[“aaa”, 1], [“aaa”, 2], [“bbb”, 3]]
vs:[[“aaa”, 1], [“bbb”, 3], [“aaa”, 2]]
vs:[[“aaa”, 2], [“bbb”, 3], [“aaa”, 1]]

I agree that a tag may be in order.

--
Michael Richardson <mcr+IETF@sandelman.ca>, Sandelman Software Works
 -= IPv6 IoT consulting =-