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.
LArray is a mutable large array.
LArray is a mutable large array.
The differences from the standard Array[A] are:
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
element type
LArray2D is a wrapper of LArray to emulate 2-dimensional array using a single array.
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.
Create LArray using java.io.OutputStream interface
Shallow-copy reference of the part of LArray
Specialized implementaiton of LArray[Boolean] using LArray[Long]
To generate an instance of LBitArray, use or xerial.larray.LBitArray#apply
LBitArray.newBuilder(Long)
BitVector builder
Extension of scala.collection.mutable.Builder using Long indexes
Extension of scala.collection.mutable.Builder using Long indexes
element type
LArray type to generate
LArray of Byte type
ByteBuffer interface of xerial.larray.LArray
LArray of Int type
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
Iterable interface for LArray.
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.
LArray of Long type
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
object type
LArray[A] of Object of more than 2G entries.
LArray[A] of Object of more than 2G entries.
object type
Read-only interface of xerial.larray.LArray
Memory-mapped LByteArray
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)
read/write operations that can be supported for LArrays using raw byte arrays as their back-end.
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.
Helper methods for packing bit sequences into Array[Long]
LArray factory
LArray factory
// Create a new LArray[Int] of size 10 LArray.of[Int](10)
Provides view of LArray
Utilities to build LBitArray
Utilities for accessing sun.misc.Unsafe
LArray
xerial.larray.LArray is a large off-heap array that can hold more than 2G (2^31) entries.
Features
Limitations
LArray[Byte], then align your object data on the array. Object parameters can be retrieved withLArray[Byte].getInt(offset),getFloat(offset), etc.