Skip to content

Main content

Run Length Record Range Splice

Run lengths are positive exact integer decimal strings with literal string values, never expanded; splice a bounded exact half-open range with encoded replacement records and compact the resulting join boundaries.

Loading tool…

Description

Splice a bounded exact half-open range with encoded replacement records and compact the resulting join boundaries.

Run-length records represent repeated observations without expanding them. Each record pairs a literal string value with a positive exact integer length; neighboring equal values can be valid but noncompact. Expanded offsets count observations rather than run records, and half-open ranges include their start while excluding their end.

Splice a bounded exact half-open range with encoded replacement records and compact the resulting join boundaries.

When to use this tool

Use this tool to splice a bounded exact half-open range with encoded replacement records and compact the resulting join boundaries.

How to use the tool and how it works

  1. Enter runsJson, start, end, replacementJson using the definitions below. Serialize JSON text fields in the decoded shape shown below.
  2. Run the operation. Resolve input-format errors before interpreting an output.
  3. Read result.runs, using the stated boundary, ordering, sign and absence conventions.

Validate 0≤start≤end≤total, preserve the prefix before start and suffix from end onward, insert the replacement run sequence between them, then compact adjacent equal values.1

Input fieldMeaning and unitsAccepted input
runsJsonJSON array of {value,length} records: literal string value and positive exact decimal-string length.Text, at most 8,192 UTF-16 code units; narrower grammar/range rules also apply.
startInclusive expanded-observation offset as nonnegative exact decimal text.Text, at most 8,192 UTF-16 code units; narrower grammar/range rules also apply.
endExclusive expanded-observation offset as exact decimal text, at least start and no greater than total.Text, at most 8,192 UTF-16 code units; narrower grammar/range rules also apply.
replacementJsonReplacement run sequence in the same exact {value,length} JSON format; may be empty.Text, at most 8,192 UTF-16 code units; narrower grammar/range rules also apply.

These decoded structures show the examples inside JSON text fields. Supply their serialized JSON strings as input.

json
{
  "runsJson": [
    {
      "value": "a",
      "length": "3"
    },
    {
      "value": "a",
      "length": "2"
    },
    {
      "value": "b",
      "length": "4"
    }
  ],
  "replacementJson": [
    {
      "value": "c",
      "length": "1"
    }
  ]
}
Output fieldInterpretation
resultObject containing the fields below.
result.runsResulting {value,length} records, with exact positive decimal lengths and the stated compaction policy.
json
{
  "input": {
    "runsJson": "[{\"value\": \"a\", \"length\": \"3\"}, {\"value\": \"a\", \"length\": \"2\"}, {\"value\": \"b\", \"length\": \"4\"}]",
    "start": "2",
    "end": "6",
    "replacementJson": "[{\"value\":\"c\",\"length\":\"1\"}]"
  },
  "output": {
    "result": {
      "runs": [
        {
          "value": "a",
          "length": "2"
        },
        {
          "value": "c",
          "length": "1"
        },
        {
          "value": "b",
          "length": "3"
        }
      ]
    }
  }
}

Limitations and assumptions

  • The splice can change expanded length. Resulting compact records must fit 128 entries; no expanded sequence is materialized.
  • Run records contain string value and positive length as exact decimal integer text. Lengths and offset inputs support up to 256 decimal digits before operation-specific checks; results use decimal text and do not expand the repeated observations.
  • Every declared outer field is required and unknown outer fields are rejected. Strings and JSON text have size limits, lists are bounded to 128 entries, and JSON nesting/node counts are bounded. Tighter operation-specific bounds stated above take precedence.
  • Ordinary numeric outputs must be finite and within safe-integer magnitude. Exact large lengths/counts use decimal strings. Original record indexes and code-unit positions are zero-based; span ends are exclusive unless stated otherwise.

Alternative or Complementary methods

Use compaction for a canonical adjacent-run layout and boundary-aware operations when provenance matters. Retain exact decimal lengths rather than converting long totals to floating-point numbers.

References

  1. Tool behavior and example: Run Length Record Range Splice — tool.io

Similar or alternative tools

  • Run Length Record Range Slice

    Run lengths are positive exact integer decimal strings with literal string values, never expanded; slice an exact half-open logical interval without expansion, preserving interior source-run boundaries.

  • Run Length Record Adjacent Compaction

    Run lengths are positive exact integer decimal strings with literal string values, never expanded; compact adjacent exactly equal values by summing exact lengths, not global deduplication.