ArrayRecord

com.github.tarao.record4s.ArrayRecord
See theArrayRecord companion object
abstract class ArrayRecord[R] extends ProductRecord, Dynamic

Record class with constant-time field access.

It provides extensible records in a different way than %. There are following differences compared to %.

  • Field access is faster (constant time)
  • Creation is faster
  • Update time grows significantly when record size grows
  • Compilation is a bit slower
  • No implicit upcast

Example

val r = ArrayRecord(name = "tarao", age = 3)
// val r: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int))] = ArrayRecord(name = tarao, age = 3)
r.name
// val res0: String = tarao
r.age
// val res1: Int = 3

Attributes

Companion
object
Source
ArrayRecord.scala
Graph
Supertypes
trait Dynamic
trait Product
trait Equals
trait Record
class Object
trait Matchable
class Any
Show all
Known subtypes
class VectorRecord

Members list

Value members

Concrete methods

inline def +: Extensible[R]
Extension method from ArrayRecord

Alias for updated

Alias for updated

Attributes

Source
ArrayRecord.scala
inline def ++[R2 : RecordLike, RR <: ProductRecord](other: R2)(implicit evidence$1: RecordLike[R2], c: Concat[R, R2]): c.Out
Extension method from ArrayRecord

Alias for concat

Alias for concat

Attributes

Source
ArrayRecord.scala
inline def apply[S <: Tuple, RR <: %](s: Selector[S])(using r: RecordLike[ArrayRecord[R]], ev: Aux[R, S, RR], rr: RecordLike[RR]): ArrayRecord[rr.TupledFieldTypes]
Implicitly added by OpsCompat

Create a new record by selecting some fields of an existing record.

Create a new record by selecting some fields of an existing record.

Type parameters

RR

type of the new record

S

list of selected field as a Tuple

Value parameters

s

selection of fields created by select

Attributes

Returns

a new record with the selected fields

Example
 val r1 = ArrayRecord(name = "tarao", age = 3, email = "[email protected]")
 val r2 = r1(select.name.age)
 // val r2: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int))] = ArrayRecord(name = tarao, age = 3)
 val r3 = r1(select.name(rename = "nickname").age)
 // val r3: com.github.tarao.record4s.ArrayRecord[(("nickname", String), ("age", Int))] = ArrayRecord(nickname = tarao, age = 3)
Source
ArrayRecord.scala
inline def apply[U <: Tuple, R2 <: %, RR <: %](u: Unselector[U])(using r: Aux[ArrayRecord[R], R2], ev: Aux[R2, U, RR], rr: RecordLike[RR]): ArrayRecord[Zip[rr.ElemLabels, rr.ElemTypes]]
Implicitly added by OpsCompat

Create a new record by unselecting some fields of an existing record.

Create a new record by unselecting some fields of an existing record.

Type parameters

RR

type of the new record

U

list of unselected field as a Tuple

Value parameters

u

unselection of fields created by unselect

Attributes

Returns

a new record without the unselected fields

Example
 val r1 = ArrayRecord(name = "tarao", age = 3, email = "[email protected]")
 val r2 = r1(unselect.email)
 // val r2: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int))] = ArrayRecord(name = tarao, age = 3)
Source
ArrayRecord.scala
inline def concat[R2 : RecordLike, RR <: ProductRecord](other: R2)(implicit evidence$1: RecordLike[R2], c: Concat[R, R2]): c.Out
Extension method from ArrayRecord

Concatenate this record and another record.

Concatenate this record and another record.

If the both record has a field of the same name, then it takes the field from the latter record.

Type parameters

R2

a record type (given RecordLike[R2])

Value parameters

other

a record to concatenate

Attributes

Returns

a new record which has the both fields from this record and other

Example
 val r1 = ArrayRecord(name = "tarao", age = 3)
 val r2 = ArrayRecord(age = 4, email = "[email protected]")
 val r3 = r1 ++ r2
 // val r3: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int), ("email", String))] = ArrayRecord(name = tarao, age = 4, email = [email protected])
Source
ArrayRecord.scala
override def productPrefix: String

Attributes

Definition Classes
Source
ArrayRecord.scala
transparent inline def selectDynamic[L <: String & Singleton](name: L): Any

Attributes

Source
ArrayRecord.scala
def tag[T]: ArrayRecord[R & Tag[T]]
Extension method from ArrayRecord

Give a type tag to this record.

Give a type tag to this record.

Type parameters

T

an arbitrary type used as a tag

Attributes

Returns

the same record with a tag type

Example
 trait Person; object Person {
   extension [T <: Tuple](p: ArrayRecord[(("name", String) *: T) & Tag[Person]]) {
     def firstName: String = p.name.split(" ").head
   }
 }
 val r = ArrayRecord(name = "tarao fuguta", age = 3).tag[Person]
 r.firstName
 // val res0: String = tarao
Source
ArrayRecord.scala
def to[To](using conv: Converter[ArrayRecord[R], To]): To
Implicitly added by OpsCompat

Convert this record to a To.

Convert this record to a To.

Type parameters

To

a type to which the record is converted

Attributes

Returns

a new product instance

Example
 case class Person(name: String, age: Int)
 val r = ArrayRecord(name = "tarao", age = 3)
 r.to[Person]
 // val res0: Person = Person(tarao,3)
Source
ArrayRecord.scala
inline def toRecord[RR <: %](using Aux[ArrayRecord[R], RR]): RR
Extension method from ArrayRecord

Convert to a record of type %.

Convert to a record of type %.

Attributes

Returns

a record of type %

Example
 val r1 = ArrayRecord(name = "tarao", age = 3)
 // val r1: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int))] = ArrayRecord(name = tarao, age = 3)
 r1.toRecord
 // val res0: com.github.tarao.record4s.%{val name: String; val age: Int} = %(name = tarao, age = 3)
Source
ArrayRecord.scala
inline def toTuple(using r: RecordLike[ArrayRecord[R]], conv: Converter[ArrayRecord[R], r.ElemTypes]): Zip[r.ElemLabels, r.ElemTypes]
Extension method from ArrayRecord

Convert this record to a Tuple.

Convert this record to a Tuple.

Attributes

Returns

fields of label-value pairs as a tuple

Example
 val r1 = ArrayRecord(name = "tarao", age = 3)
 r1.toTuple
 // val res0: (("name", String), ("age", Int)) = ((name,tarao),(age,3))
Source
ArrayRecord.scala
transparent inline def upcast[R2]: Any
Extension method from ArrayRecord

Upcast the record to specified type.

Upcast the record to specified type.

Type parameters

R2

target type

Attributes

Returns

a record containing only fields in the target type

Example
 val r1 = ArrayRecord(name = "tarao", age = 3, email = "[email protected]")
 // val r1: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int), ("email", String))] = ArrayRecord(name = tarao, age = 3, email = [email protected])
 val r2 = r1.upcast[(("name", String), ("age", Int))]
 // val r2: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int))] = ArrayRecord(name = tarao, age = 3)
Source
ArrayRecord.scala
Extension method from ArrayRecord

Extend the record by fields.

Extend the record by fields.

If a new field has the same name as the existing field, then the new field overrides the old one.

Attributes

Returns

an object to define new fields

Example
 val r = ArrayRecord(name = "tarao") + (age = 3, email = "[email protected]")
 // val r: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int), ("email", String))] = ArrayRecord(name = tarao, age = 3, email = [email protected])
Source
ArrayRecord.scala
Extension method from ArrayRecord

Return values of this record as a Tuple.

Return values of this record as a Tuple.

Attributes

Returns

values of the record as a tuple

Example
 val r1 = ArrayRecord(name = "tarao", age = 3)
 r1.values
 // val res0: (String, Int) = (tarao,3)
Source
ArrayRecord.scala

Inherited methods

override def canEqual(that: Any): Boolean

Attributes

Definition Classes
Inherited from:
ProductRecord
Source
ArrayRecord.scala
override def equals(other: Any): Boolean

Compares the receiver object (this) with the argument object (that) for equivalence.

Compares the receiver object (this) with the argument object (that) for equivalence.

Any implementation of this method should be an equivalence relation:

  • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
  • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

true if the receiver object is equivalent to the argument; false otherwise.

Definition Classes
ProductRecord -> Equals -> Any
Inherited from:
ProductRecord
Source
ArrayRecord.scala
override def productArity: Int

Attributes

Definition Classes
Inherited from:
ProductRecord
Source
ArrayRecord.scala
override def productElement(n: Int): Any

Attributes

Definition Classes
Inherited from:
ProductRecord
Source
ArrayRecord.scala
override def productElementName(n: Int): String

Attributes

Definition Classes
Inherited from:
ProductRecord
Source
ArrayRecord.scala

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product
override def toString(): String

Stringify the record.

Stringify the record.

The order of key-value pairs is exactly the same as that of the static field types.

Attributes

Definition Classes
ProductRecord -> Any
Inherited from:
ProductRecord
Source
ArrayRecord.scala