> For the complete documentation index, see [llms.txt](https://nag-9-s.gitbook.io/machine-learning/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nag-9-s.gitbook.io/machine-learning/mlib/data-types/matrices/distributed-matrix/indexedrowmatrix.md).

# IndexedRowMatrix

An `IndexedRowMatrix` stores a row index prefixed to the row entry. This is useful in executing joins. You need to pass `IndexedRow` objects to create an `IndexedRowMatrix`. An `IndexedRow` object is a wrapper with a long `Index` and a `Vector` of row elements.

like a row matrix, but with meaningful row indices.

Spark In Action

IndexedRowMatrix is an RDD of IndexedRow objects, each containing an index of the row and a Vector with row data. Although there is no built-in method for converting a RowMatrix to an IndexedRowMatrix, it’s fairly easy to do:

![](https://422781072-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LsbZSeL57mlsVm1bwrG%2F-LsbZa1KWgHxmC9yq5FP%2F-LsbZeZXQUM6Cp1dihCB%2FindexedRowMatrix.png?generation=1572621954921508\&alt=media)

![](https://422781072-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LsbZSeL57mlsVm1bwrG%2F-LsbZa1KWgHxmC9yq5FP%2F-LsbZeZZb6pwB2eeD3pE%2FindexedRow.png?generation=1572621961912358\&alt=media)
