Package

xerial

larray

Permalink

package larray

LArray

xerial.larray.LArray is a large off-heap array that can hold more than 2G (2^31) entries.

Features
Limitations
Source
package.scala
Linear Supertypes
AnyRef, Any
Content Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. larray
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract class AbstractLArrayView[A] extends LArrayView[A]

    Permalink
  2. trait AltLIntArrayImpl extends LArray[Int]

    Permalink

    A common trait for alternative implementations of LArray.

    A common trait for alternative implementations of LArray. This implementation is provided only for testing purpose, so many features might be missing in LArrays impemented this trait.

  3. implicit class AsLRange extends AnyRef

    Permalink
  4. trait BufferedLIterator[+A] extends LIterator[A]

    Permalink
  5. implicit class ConvertArrayToLArray[A] extends AnyRef

    Permalink
  6. implicit class ConvertIterableToLArray[A] extends AnyRef

    Permalink
  7. trait LArray[A] extends LSeq[A] with WritableByteChannel

    Permalink

    LArray is a mutable large array.

    LArray is a mutable large array.

    The differences from the standard Array[A] are:

    • LArray accepts Long type indexes, so it is possible to have more than 2G (2^31-1) entries, which is a limitation of the standard Array[A].
    • The memory resource of LArray[A] resides outside of the normal garbage-collected JVM heap and can be released via xerial.larray.LArray.free.
    • If LArray.free is not called, the acquried memory stays until LArray is collected by GC.
    • LArray elements are not initialized, so explicit initialization using LArray.clear is necessary.

    Usage

    import xerial.larray._
    
    // Create a new LArray of Int type
    val l = LArray.of[Int](5)
    
    // Create an LArray with initial values
    val ll = LArray(3, 5, 9, 10)
    
    // Set elements
    for(i <- 0 until l.size.toInt)
      l(i) = i
    
    // Read elements
    val e0 = l(0)
    val e1 = l(1)
    
    // Print the elements
    println(l.mkString(", ")) // 0, 1, 2, 3, 4
    
    // Traverse the elements with their indexes
    for((e, i) <- l.zipWithIndex)
      println(s"l($i) = $e") // l(0) = 0, l(1) = 1, ...
    
    // Manipulate LArray
    val l2 = l.map(_ * 10) // LArray(0, 10, 20, 30, 40)
    val f = l.filter(_ % 2 == 0) // LArray(0, 2, 4)
    val s = l.slice(2) // LArray(2, 3, 4)
    l.foreach(println(_))
    
    // Build LArray
    val b = LArray.newBuilder[Int]
    for(i <- 0 until (10, step=3))
      b += i
    val lb = b.result // LArray(0, 3, 6, 9)
    
    // Convert to Scala Array
    val arr = l.toArray
    println(arr.mkString(", ")) // 0, 1, 2, 3, 4
    
    // Convert Scala Array to LArray
    val arr2 = Array(1, 3, 5)
    val la = arr2.toLArray
    
    // Save to a file
    import java.io.File
    val file = l.saveTo(new File("target/larray.tmp"))
    // Load from a file
    val l3 = LArray.loadFrom[Int](file) // LArray(0, 1, 2, 3, 4)
    
    // Initialize the array
    l.clear()
    println(l.mkString(", ")) // 0, 0, 0, 0, 0
    
    // Release the memory contents.
    l.free
    l3.free
    
    // You can omit calling free, because GC collects unused LArrays
    A

    element type

  8. class LArray2D[A] extends AnyRef

    Permalink

    LArray2D is a wrapper of LArray to emulate 2-dimensional array using a single array.

  9. abstract class LArrayBuilder[A, Repr <: LArray[A]] extends LBuilder[A, Repr] with LogSupport

    Permalink

    In the following, we need to define builders for every primitive types because if we extract common functions (e.g., resize, mkArray) using type parameter, we cannot avoid boxing/unboxing.

  10. class LArrayOutputStream[A] extends OutputStream

    Permalink

    Create LArray using java.io.OutputStream interface

  11. trait LArrayView[A] extends LSeq[A]

    Permalink

    Shallow-copy reference of the part of LArray

  12. class LBitArray extends LArray[Boolean] with UnsafeArray[Boolean] with LBitArrayOps

    Permalink

    Specialized implementaiton of LArray[Boolean] using LArray[Long] To generate an instance of LBitArray, use LBitArray.newBuilder(Long) or xerial.larray.LBitArray#apply

  13. class LBitArrayBuilder extends LBuilder[Boolean, LBitArray] with LogSupport

    Permalink

    BitVector builder

  14. trait LBitArrayOps extends AnyRef

    Permalink
  15. trait LBuilder[Elem, +To] extends WritableByteChannel

    Permalink

    Extension of scala.collection.mutable.Builder using Long indexes

    Extension of scala.collection.mutable.Builder using Long indexes

    Elem

    element type

    To

    LArray type to generate

  16. class LByteArray extends LArray[Byte] with UnsafeArray[Byte]

    Permalink

    LArray of Byte type

  17. class LByteArrayBuilder extends LArrayBuilder[Byte, LByteArray]

    Permalink
  18. class LByteBuffer extends AnyRef

    Permalink

    ByteBuffer interface of xerial.larray.LArray

  19. class LCharArray extends LArray[Char] with UnsafeArray[Char]

    Permalink
  20. class LCharArrayBuilder extends LArrayBuilder[Char, LCharArray]

    Permalink
  21. class LDoubleArray extends LArray[Double] with UnsafeArray[Double]

    Permalink
  22. class LDoubleArrayBuilder extends LArrayBuilder[Double, LDoubleArray]

    Permalink
  23. class LFloatArray extends LArray[Float] with UnsafeArray[Float]

    Permalink
  24. class LFloatArrayBuilder extends LArrayBuilder[Float, LFloatArray]

    Permalink
  25. class LIntArray extends LArray[Int] with UnsafeArray[Int]

    Permalink

    LArray of Int type

  26. class LIntArrayBuilder extends LArrayBuilder[Int, LIntArray]

    Permalink
  27. class LIntArraySimple extends LArray[Int] with AltLIntArrayImpl

    Permalink

    Alternative implementation of LArray that might be inefficient, but written for comparing performances.

    Alternative implementation of LArray that might be inefficient, but written for comparing performances. LIntArraySimple wraps Array[Int] to support Long-type indexes

  28. trait LIterable[A] extends AnyRef

    Permalink

    Iterable interface for LArray.

  29. trait LIterator[+A] extends AnyRef

    Permalink

    Iterator for LArray.

    Iterator for LArray. It is a extension of scala.collection.Iterable and most of the code is derived from its implementation except that the index type is Long instead of Int.

  30. class LLongArray extends LArray[Long] with UnsafeArray[Long]

    Permalink

    LArray of Long type

  31. class LLongArrayBuilder extends LArrayBuilder[Long, LLongArray]

    Permalink
  32. class LObjectArray32[A] extends LArray[A]

    Permalink

    LArray[A] of Objects.

    LArray[A] of Objects. This implementation is a simple wrapper of Array[A] and used when the array size is less than 2G

    A

    object type

  33. class LObjectArrayBuilder[A] extends LBuilder[A, LArray[A]]

    Permalink
  34. class LObjectArrayLarge[A] extends LArray[A]

    Permalink

    LArray[A] of Object of more than 2G entries.

    LArray[A] of Object of more than 2G entries.

    A

    object type

  35. trait LSeq[A] extends LIterable[A]

    Permalink

    Read-only interface of xerial.larray.LArray

  36. class LShortArray extends LArray[Short] with UnsafeArray[Short]

    Permalink
  37. class LShortArrayBuilder extends LArrayBuilder[Short, LShortArray]

    Permalink
  38. class MappedLByteArray extends RawByteArray[Byte]

    Permalink

    Memory-mapped LByteArray

  39. class MatrixBasedLIntArray extends LArray[Int] with AltLIntArrayImpl

    Permalink

    Emulate large arrays using two-diemensional matrix of Int.

    Emulate large arrays using two-diemensional matrix of Int. Array[Int](page index)(offset in page)

  40. trait RawByteArray[A] extends LArray[A]

    Permalink

    read/write operations that can be supported for LArrays using raw byte arrays as their back-end.

  41. class UInt32Array extends LArray[Long] with UnsafeArray[Long]

    Permalink

    Array of uint32 values.

    Array of uint32 values. The internal array representation is the same with LIntArray, but the apply and update methods are based on Long type values.

Value Members

  1. object BitEncoder

    Permalink

    Helper methods for packing bit sequences into Array[Long]

  2. object LArray

    Permalink

    LArray factory

    LArray factory

    // Create a new LArray[Int] of size 10
    LArray.of[Int](10)
  3. object LArray2D

    Permalink
  4. object LArrayBuilder extends Serializable

    Permalink

  5. object LArrayInputStream

    Permalink
  6. object LArrayView

    Permalink

    Provides view of LArray

  7. object LBitArray extends Serializable

    Permalink

    Utilities to build LBitArray

  8. object LIterator

    Permalink
  9. object LObjectArray

    Permalink
  10. object UInt32Array extends Serializable

    Permalink
  11. object UnsafeUtil extends LogSupport

    Permalink

    Utilities for accessing sun.misc.Unsafe

  12. implicit def defaultAllocator: MemoryAllocator

    Permalink
  13. package example

    Permalink
  14. package japi

    Permalink
  15. package util

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped