Ecosyste.ms: Packages

An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 2.6% on proxy.golang.org
Top 0.1% dependent packages on proxy.golang.org
Top 0.2% dependent repos on proxy.golang.org
Top 5.6% forks on proxy.golang.org
Top 0.7% docker downloads on proxy.golang.org

proxy.golang.org : github.com/google/orderedcode

Package orderedcode provides a byte encoding of a sequence of typed items. The resulting bytes can be lexicographically compared to yield the same ordering as item-wise comparison on the original sequences. More precisely, suppose: Then comparing A versus B lexicographically is the same as comparing the vectors [A_1..A_n] and [B_1..B_n] lexicographically. Furthermore, if i < j then [A_1..A_i]'s encoding is a prefix of [A_1..A_j]'s encoding. The order-maintaining and prefix properties described above are useful for generating keys for databases like Bigtable. Call Append(buffer, item1, ..., itemN) to construct the encoded bytes. The valid item types are: As a convenience, orderedcode.Infinity is a value of type struct{}. For example, to encode a sequence of two strings, an 'infinity' and an uint64: Alternatively, encoding can be done in multiple steps: Call Parse(encoded, &item1, ..., &itemN) to deconstruct an encoded string. The valid argument types are the pointers to the valid encoding types. For example: Alternatively: A TrailingString is a string that, if present, must be the last item appended or parsed. It is not mandatory to use a TrailingString; it is valid for the last item to be a standard string or any other type listed above. A TrailingString simply allows a more efficient encoding while retaining the lexicographic order-maintaining property. If used, you cannot append a TrailingString and parse the result as a standard string, or as a StringOrInfinity. For example: The same sequence of types should be used for encoding and decoding (although StringOrInfinity can substitute for either a string or a struct{}, but not for a TrailingString). The wire format is not fully self-describing: "\x00\x01\x04\x03\x02\x00\x01" is a valid encoding of both ["", "\x04\x03\x02"] and [uint64(0), uint64(4), uint64(0x20001)]. Decoding into a pointer of the wrong type may return corrupt data and no error. Each item can optionally be encoded in decreasing order. If the i'th item is and the lexicographic comparison of A and B comes down to A_i versus B_i, then A < B will equal A_i > B_i. To encode in decreasing order, wrap the item in an orderedcode.Decr value. To decode, wrap the item pointer in an orderedcode.Decr. For example: Each item's ordering is independent from other items, but the same ordering should be used to encode and decode the i'th item.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/google/orderedcode
License: Apache-2.0
Latest release: over 5 years ago
First release: over 5 years ago
Namespace: github.com/google
Dependent packages: 3,002
Dependent repositories: 2,119
Stars: 39 on GitHub
Forks: 14 on GitHub
Docker dependents: 269
Docker downloads: 223,485
See more repository details: repos.ecosyste.ms
Last synced: 13 days ago

    Loading...
    Readme
    Loading...