trait ReIndexer[T] extends AnyRef
We often need to "reindex" one array/vec/series/frame so as to produce a new one.
First, note that an array A of values of type T is actually a mapping defined as
f [0, A.length) => {T}
That is, each integer index of the array yields a value of type T when it is de-referenced.
ReIndexer has two fields, lTake and rTake, which are array-based maps defined for some integers M and N as
g [0, N) => [-1, M)
In other words, lTake and rTake are arrays of length N whose entries are integers between -1 and M-1. We call these "indexers".
Given a reindexer, g, a re-indexing operation on array A yields a new array B of length N which represents the following mapping:
B [0, N) => {T} where B(i) == f(g(i)) if g(i) != -1 == NA if g(i) == -1
For this to work, the maximum value M in the co-domain of g must be <= A.length. We also augment the mapping f to send -1 to the corresponding NA value of type T.
For example, suppose we have Index(0,1,2,4) and Index(0,1,2,3). Performing a full outer join would yield the following ReIndexer:
- lTake = {0, 1, 2, -1, 3},
- rTake = {0, 1, 2, 3, -1},
- index = Index(0, 1, 2, 3, 4).
These indexers are then amenable to using with org.saddle.array.take to select elements out of an indexed data structure.
A performance optimization is to make lTake and rTake of type Option[Array], where we make a value of None behave as if it were an array of [0, N). So, the "taking" code knows to take the original values. You will therefore see code that looks like:
val v = Vec(...) val ixer = ReIndexer(...) ixer.lTake.map(x => v.take(x)) getOrElse v
- Alphabetic
- By Inheritance
- ReIndexer
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def swap: ReIndexer[T]
Return ReIndexer with lTake and rTake swapped
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()