org.saddle.index

ReIndexer

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:

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
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. ReIndexer
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def index: Index[T]

    The new index

  2. abstract def lTake: Option[Array[Int]]

    Offsets into left index corresponding to new index

  3. abstract def rTake: Option[Array[Int]]

    Offsets into right index corresponding to new index

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  8. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  13. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  17. def swap: ReIndexer[T]

    Return ReIndexer with lTake and rTake swapped

  18. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  19. def toString(): String

    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  21. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  22. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any