msort

package
v0.0.0-...-4dcfcdd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package msort contains utility functions for sorting and de-duplicating batches of mutations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UniqueByKey

func UniqueByKey(x []types.Mutation) []types.Mutation

UniqueByKey implements a "last one wins" approach to removing mutations with duplicate keys from the input slice. If two mutations share the same Key, then the one with the later Time is returned. If there are mutations with identical Keys and Times, exactly one of the values will be chosen arbitrarily.

A new slice is returned.

This function will panic if any of the mutation Key fields are entirely empty. An empty json array (i.e. `[]`) is acceptable.

func UniqueByTimeKey

func UniqueByTimeKey(x []types.Mutation) []types.Mutation

UniqueByTimeKey implements a "last one wins" approach to removing mutations with duplicate (time, key) tuples from the input slice. If two mutations share the same (time, key) pair, then the one later in the input slice is returned.

A new slice is returned.

This function will panic if any of the mutation Key fields are entirely empty. An empty json array (i.e. `[]`) is acceptable.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL