dotnet/machinelearning · error · ArgumentException
Strings.MapIndicesExceedsColumnLength
Error message
Strings.MapIndicesExceedsColumnLength
What it means
CloneImplementation(PrimitiveDataFrameColumn<bool> boolColumn) uses the bool column as a filter map, so it must not be longer than the source column; when boolColumn.Length > Length it throws ArgumentException(Strings.MapIndicesExceedsColumnLength, nameof(boolColumn)). Reached via Clone when mapIndices is a bool column.
Solutions
- Trim the bool mask to the column's Length before cloning.
- Build the mask from the same column/DataFrame so lengths always match.
- Assert boolColumn.Length <= column.Length before calling Clone.
- Use a long/int index column instead of a bool mask when lengths may differ.
Example fix
// before
var clone = column.Clone(mask); // mask.Length > column.Length
// after
if (mask.Length > column.Length)
throw new ArgumentException("Mask longer than column");
var clone = column.Clone(mask); Defensive patterns
Strategy: validation
Validate before calling
if (mask is PrimitiveDataFrameColumn<bool> boolMask && boolMask.Length > column.Length)
throw new ArgumentException("Bool mask longer than column"); Type guard
bool isValidMask(PrimitiveDataFrameColumn<bool> mask, DataFrameColumn col) => mask.Length <= col.Length;
Try / catch
try { var clone = column.Clone(mask); }
catch (ArgumentException ex) when (ex.ParamName == "boolColumn")
{ /* mask longer than column: trim mask */ } Prevention
- Build filter masks from the same column being cloned.
- Trim masks to column length before use.
- Assert mask.Length <= column.Length in tests.
- Prefer long index maps over bool masks in new code.
When it happens
Trigger: Calling Clone(mapIndices) where mapIndices is a PrimitiveDataFrameColumn<bool> with more entries than the VBufferDataFrameColumn being cloned.
Common situations: Filter masks built from a longer DataFrame reused against a shorter column; mask columns that grew after earlier appends; combining columns of differing lengths.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- String.Format(Strings.MultipleMismatchedValueType…
- and must be different
- Column lengths are mismatched
- nameof(groupByColumnIndex)
- string.Format(Strings.DuplicateColumnName, column.Name)
AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11).
Data as JSON: /api/errors/c4768d97c24f9193.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.Data.Analysis/DataFrameColumns/VBufferDataFrameColumn.cs:215
if (Length > row)
{
this[row] = value;
}
else if (Length == row)
{
Append(value);
}
else
{
throw new IndexOutOfRangeException(nameof(row));
}
}
private VBufferDataFrameColumn<T> CloneImplementation(PrimitiveDataFrameColumn<bool> boolColumn)
{
if (boolColumn.Length > Length)
throw new ArgumentException(Strings.MapIndicesExceedsColumnLength, nameof(boolColumn));
VBufferDataFrameColumn<T> ret = new VBufferDataFrameColumn<T>(Name, 0);
for (long i = 0; i < boolColumn.Length; i++)
{
bool? value = boolColumn[i];
if (value.HasValue && value.Value == true)
ret.Append(this[i]);
}
return ret;
}
private VBufferDataFrameColumn<T> CloneImplementation(PrimitiveDataFrameColumn<long> mapIndices, bool invertMapIndices = false)
{
mapIndices = mapIndices ?? throw new ArgumentNullException(nameof(mapIndices));
var ret = new VBufferDataFrameColumn<T>(Name, mapIndices.Length);
long rowIndex = 0;
for (int b = 0; b < mapIndices.ColumnContainer.Buffers.Count; b++)
{View on GitHub (pinned to 7b76e69cf9)