trait
ReIndexer[T] extends AnyRef
Abstract Value Members
-
abstract
def
index: Index[T]
-
abstract
def
lTake: Option[Array[Int]]
-
abstract
def
rTake: Option[Array[Int]]
Concrete Value Members
-
final
def
!=(arg0: AnyRef): Boolean
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: AnyRef): Boolean
-
final
def
==(arg0: Any): Boolean
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
finalize(): Unit
-
final
def
getClass(): java.lang.Class[_]
-
def
hashCode(): Int
-
final
def
isInstanceOf[T0]: Boolean
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Inherited from AnyRef
Inherited from Any
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
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
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:
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:
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: