Multiset Maximum Union Cardinality

Calculate typed multiset maximum-union cardinality including keys absent from one operand; no scalar type coercion.

Description

Calculate typed multiset maximum-union cardinality including keys absent from one operand; no scalar type coercion.

Multiset union can use the maximum of each value's two counts, rather than adding counts. Its cardinality follows that convention.

When to use this tool

Calculate typed multiset maximum-union cardinality including keys absent from one operand; no scalar type coercion.

  • Prepare the supplied leftJson, rightJson fields for this operation.
  • Compare the complete example with the representation used by your own input before carrying the result into another step.

How to use the tool and how it works

  1. Enter leftJson, rightJson. Use the exact text syntax, units and index conventions explained below.
  2. Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
  3. Read result.cardinality. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.

Normalize both value/count tables, visit the union of typed JSON keys and sum max(left count,right count), treating missing counts as zero.1

Input fieldMeaning and representationAccepted input
leftJsonJSON text, entered as one text field. The decoded structure is illustrated below; it is not a separate file.Text
rightJsonJSON text, entered as one text field. The decoded structure is illustrated below; it is not a separate file.Text

For the JSON text fields, the following decoded structures show the example records before they are serialized into input strings. Keep field names, list nesting and value types as shown.

json
[
  {
    "field": "leftJson",
    "decoded": [
      {
        "value": "a",
        "count": 3
      },
      {
        "value": "b",
        "count": 1
      }
    ]
  },
  {
    "field": "rightJson",
    "decoded": [
      {
        "value": "a",
        "count": 2
      },
      {
        "value": "c",
        "count": 2
      }
    ]
  }
]
Output fieldInterpretation
resultObject containing the named outputs below.
result.cardinalityThe cardinality value under the stated formula or text convention.
json
{
  "input": {
    "leftJson": "[{\"value\":\"a\",\"count\":3},{\"value\":\"b\",\"count\":1}]",
    "rightJson": "[{\"value\":\"a\",\"count\":2},{\"value\":\"c\",\"count\":2}]"
  },
  "output": {
    "result": {
      "cardinality": 6
    }
  }
}

Limitations and assumptions

  • This is maximum union, not additive bag concatenation or distinct-value count. No occurrence sequence is retained.
  • All declared input fields are required and unexpected top-level fields are rejected. Numbers must be finite; lists are limited to 128 entries and ordinary text fields to 8,192 UTF-16 code units, with tighter limits where stated.
  • JSON text inputs must parse within bounded nesting and size limits. Numeric outputs outside the safe finite range are rejected; large exact integer results use decimal strings. Indexes and half-open spans are zero-based unless a rank is explicitly described as one-based.

Alternative or Complementary methods

Keep occurrence sequences separate from count tables. Choose maximum union, additive concatenation or allocation deliberately, and apply any real inventory changes through a system that controls concurrent updates.

References

  1. Tool behavior and example: Multiset Maximum Union Cardinality — tool.io

Similar or alternative tools

  • Multiset Capped Count Table

    Cap each normalized typed multiplicity at an explicit nonnegative integer and omit resulting zeros; no proportional redistribution.

  • Multiset Complete Kit Count

    Count complete typed kits consumable from an explicit inventory using the limiting required multiplicity; empty kit requirements are rejected.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies