Class

com.outworkers.phantom.macros

TableHelperMacro

Related Doc: package macros

Permalink

class TableHelperMacro extends WhiteboxToolbelt with RootMacro

Linear Supertypes
RootMacro, HListHelpers, WhiteboxToolbelt, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TableHelperMacro
  2. RootMacro
  3. HListHelpers
  4. WhiteboxToolbelt
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new TableHelperMacro(c: Context)

    Permalink

Type Members

  1. implicit class FieldOps extends AnyRef

    Permalink
    Definition Classes
    RootMacro
  2. implicit class ListMapOps[K, V, M[X] <: Traversable[X]] extends AnyRef

    Permalink
    Definition Classes
    RootMacro
  3. case class MatchedField(left: Field, right: Field) extends RecordMatch with Product with Serializable

    Permalink
    Definition Classes
    RootMacro
  4. trait RecordMatch extends AnyRef

    Permalink
    Definition Classes
    RootMacro
  5. trait RootField extends AnyRef

    Permalink
    Definition Classes
    RootMacro
  6. case class TableDescriptor(tableTpe: scala.reflect.macros.Universe.Type, recordType: scala.reflect.macros.Universe.Type, members: Seq[Field], matches: Seq[RecordMatch] = immutable.this.Nil) extends Product with Serializable

    Permalink
    Definition Classes
    RootMacro
  7. case class Unmatched(field: Field, reason: String = "") extends RecordMatch with Product with Serializable

    Permalink
    Definition Classes
    RootMacro

Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. object Column

    Permalink
    Definition Classes
    RootMacro
  5. object Record

    Permalink
    Definition Classes
    RootMacro
  6. object TableDescriptor extends Serializable

    Permalink
    Definition Classes
    RootMacro
  7. def abort(msg: String): Nothing

    Permalink
    Definition Classes
    WhiteboxToolbelt
  8. def adjustedTableName(table: String): scala.reflect.macros.Universe.Tree

    Permalink

    This will search the implicit scope for a NamingStrategy defined.

    This will search the implicit scope for a NamingStrategy defined. If none is found, this will return the table name as is.

    table

    The name of the table as derived from the user input.

    returns

    A new table name adjusted according to the NamingStrategy.

  9. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  10. val builder: scala.reflect.macros.Universe.Select

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  11. val builderPkg: scala.reflect.macros.Universe.Select

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  12. val c: Context

    Permalink
    Definition Classes
    TableHelperMacroRootMacroHListHelpers → WhiteboxToolbelt
  13. def caseFields(tpe: scala.reflect.macros.Universe.Type): Seq[(scala.reflect.macros.Universe.Name, scala.reflect.macros.Universe.Type)]

    Permalink
    Definition Classes
    RootMacro
  14. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  15. val colSymbol: scala.reflect.macros.Universe.Symbol

    Permalink
    Definition Classes
    RootMacro
  16. val colType: scala.reflect.macros.Universe.ExistentialTypeTree

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  17. val collections: scala.reflect.macros.Universe.Select

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  18. def determineReferenceTable(tpe: scala.reflect.macros.Universe.Type): Option[scala.reflect.macros.Universe.Symbol]

    Permalink

    Finds the first type in the type hierarchy for which columns exist as direct members.

    Finds the first type in the type hierarchy for which columns exist as direct members.

    tpe

    The type of the table.

    returns

    An optional symbol, if such a type was found in the type hierarchy.

  19. def devarargify(tpe: scala.reflect.macros.Universe.Type): scala.reflect.macros.Universe.Type

    Permalink
    Definition Classes
    HListHelpers
  20. def echo(msg: String): Unit

    Permalink
    Definition Classes
    WhiteboxToolbelt
  21. val enginePkg: scala.reflect.macros.Universe.Select

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  22. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  24. def error(msg: String): Unit

    Permalink
    Definition Classes
    WhiteboxToolbelt
  25. val exclusions: (scala.reflect.macros.Universe.Symbol) ⇒ Option[scala.reflect.macros.Universe.Symbol]

    Permalink
  26. def extractColumnMembers(table: scala.reflect.macros.Universe.Type, columns: List[scala.reflect.macros.Universe.Symbol]): List[Field]

    Permalink
    Definition Classes
    RootMacro
  27. def extractRecordMembers(tpe: scala.reflect.macros.Universe.Type): Seq[Field]

    Permalink

    A "generic" type extractor that's meant to produce a list of fields from a record type.

    A "generic" type extractor that's meant to produce a list of fields from a record type. We support a narrow domain of types for automated generation, currently including: - Case classes - Tuples

    To achieve this, we simply have specific ways of extracting the types from the underlying records, and producing a Record.Field for each of the members in the product type,

    tpe

    The underlying record type that was passed as the second argument to a Cassandra table.

    returns

    An iterable of fields, each containing a TermName and a Type that describe a record member.

    Definition Classes
    RootMacro
  28. def extractTableName(source: scala.reflect.macros.Universe.Type): String

    Permalink

    Extracts the name of the table that will be generated and used in Cassandra.

    Extracts the name of the table that will be generated and used in Cassandra. This can be changed at runtime by the user by overriding CassandraTable.tableName. This mechanism is incompatible with the historical way we used to do this, effectively using the type inferred by the final database object.

    Instead, at present times, it is the type hierarchy that dictates what a table will be called, and the first member of the type hierarchy of a table type with columns defined will dictate the name.

    source

    The source table type to extract the name from. We rely on this to be the first in the hierarchy to contain column definitions, determined by determineReferenceTable() above.

  29. def extractor[T](tableTpe: scala.reflect.macros.Universe.Type, recordTpe: scala.reflect.macros.Universe.Type, columns: List[scala.reflect.macros.Universe.Symbol]): TableDescriptor

    Permalink

    Materializes an extractor method for a table, the so called "fromRow" method.

    Materializes an extractor method for a table, the so called "fromRow" method.

    This will only work if the types of the record type match the types inferred by the return types of the columns inside the table.

    If the implementation could not be inferred, the output of this method will be the unimplemented method exception and the user will have to manually override the fromRow definition and create one themselves.

    def fromRow(row: Row): R = ???

    The fields do not have to be in the same order in both the record and the table. The macro algorithm will go to some length to try and figure out a correct match even if the fields are in random order.

    case class MyRecord(
      id: UUID,
      email: String,
      date: DateTime
    )
    
    class MyTable extends Table[MyTable, MyRecord] {
      object id extends UUIDColumn with PartitionKey
      object email extends StringColumn
      object date extends DateTimeColumn
    }

    For example, the below will be a perfect match as well:

    case class MyRecord(
      date: DateTime
      id: UUID,
      email: String,
    )
    
    class MyTable extends Table[MyTable, MyRecord] {
      object id extends UUIDColumn with PartitionKey
      object email extends StringColumn
      object date extends DateTimeColumn
    }

    For a more detailed description on how this method works, see extractorRec.

    returns

    An interpolated tree that will contain the automatically generated implementation of the fromRow method in a Cassandra Table. Alternatively, this will return an unimplemented ??? method, provided a correct definition could not be inferred.

  30. def extractorRec(columnFields: ListMap[scala.reflect.macros.Universe.Type, Seq[scala.reflect.macros.Universe.TermName]], recordFields: List[Field], descriptor: TableDescriptor, unprocessed: List[Field] = immutable.this.Nil): TableDescriptor

    Permalink

    This works by recursively parsing a list of fields extracted here as record members.

    This works by recursively parsing a list of fields extracted here as record members. The algorithm will take every fiel from the record and: - If there are record fields to address left, we will search within the available columns for a type that either matches or can be implicitly converted to the record type. - If a single match is found, we declare that as a match, without comparing the field names. - If there is more than one match found, we look for a column with a name that matches the record field name. - If a matching name is found, it means we have both a matching type and name and we consider that a correct match. - If no matching name is found, this is appended to the unprocessed list of record fields. We do this because we need to resort to different techniques to deal with unmatched record fields or fields with multiple possible matches. Until 2.6.0, we resorted to using the first column field of the correct type as per user input, in situations where a given record type cou;d match more than one column. However, this introduces a subtle problem as we risk "using up" a column field with a potentially incorrect matching record field because we do not exhaust all "direct" easy matches before attempting to handle the more complex situations. - If a direct match is found or no matching type is found we recursively remove from both the list of record fields to look for and also from the dictionary of column members to look up from.

    columnFields

    An ordered "as-written" map of column types with a list of terms associated with it. This is used to deal with the fact that multiple table columns can have the same Scala type.

    recordFields

    An ordered "as-written" list of record fields.

    descriptor

    A table descriptor, built recursively, which will hold all the information we need to generate the extractor at the end of this recursive cycle.

    unprocessed

    The list of unprocessed record fields, dealt with last to avoid the above described scenario. We attempt to make all "easy matches" before analysing situations where it's harder to derive a simple field match.

    returns

    A TableDescriptor, which contains all the information needed to create a full cassandra table.

  31. def filterColumns(columns: Seq[scala.reflect.macros.Universe.Type], filter: scala.reflect.macros.Universe.Type): Seq[scala.reflect.macros.Universe.Type]

    Permalink
    Definition Classes
    RootMacro
  32. def filterColumns[Filter](columns: Seq[scala.reflect.macros.Universe.Type])(implicit arg0: scala.reflect.macros.Universe.TypeTag[Filter]): Seq[scala.reflect.macros.Universe.Type]

    Permalink
    Definition Classes
    RootMacro
  33. def filterMembers[T, Filter](exclusions: (scala.reflect.macros.Universe.Symbol) ⇒ Option[scala.reflect.macros.Universe.Symbol] = ...)(implicit arg0: scala.reflect.macros.Universe.WeakTypeTag[T], arg1: scala.reflect.macros.Universe.TypeTag[Filter]): Seq[scala.reflect.macros.Universe.Symbol]

    Permalink
    Definition Classes
    RootMacro
  34. def filterMembers[Filter](tpe: scala.reflect.macros.Universe.Type, exclusions: (scala.reflect.macros.Universe.Symbol) ⇒ Option[scala.reflect.macros.Universe.Symbol])(implicit arg0: scala.reflect.macros.Universe.TypeTag[Filter]): Seq[scala.reflect.macros.Universe.Symbol]

    Permalink
    Definition Classes
    RootMacro
  35. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  36. val fromRowName: scala.reflect.macros.Universe.TermName

    Permalink
    Definition Classes
    RootMacro
  37. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  38. def hardMatch(columnFields: ListMap[scala.reflect.macros.Universe.Type, Seq[scala.reflect.macros.Universe.TermName]], unprocessed: List[Field], descriptor: TableDescriptor): TableDescriptor

    Permalink
  39. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  40. def hconsTpe: scala.reflect.macros.Universe.Type

    Permalink
    Attributes
    protected[this]
    Definition Classes
    HListHelpers
  41. def hlistTpe: scala.reflect.macros.Universe.Type

    Permalink
    Attributes
    protected[this]
    Definition Classes
    HListHelpers
  42. def hnilTpe: scala.reflect.macros.Universe.Type

    Permalink
    Attributes
    protected[this]
    Definition Classes
    HListHelpers
  43. def inferPrimaryKey(tableName: String, table: scala.reflect.macros.Universe.Type, columns: Seq[scala.reflect.macros.Universe.Type]): scala.reflect.macros.Universe.Tree

    Permalink

    This method will check for common Cassandra anti-patterns during the intialisation of a schema.

    This method will check for common Cassandra anti-patterns during the intialisation of a schema. If the Schema definition violates valid CQL standard, this function will throw an error.

    A perfect example is using a mixture of Primary keys and Clustering keys in the same schema. While a Clustering key is also a primary key, when defining a clustering key all other keys must become clustering keys and specify their order.

    We could auto-generate this order but we wouldn't be making false assumptions about the desired ordering.

  44. def info(msg: String, force: Boolean = false): Unit

    Permalink
    Definition Classes
    WhiteboxToolbelt
  45. val inputTerm: scala.reflect.macros.Universe.TermName

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  46. def insertQueryType(table: scala.reflect.macros.Universe.Type, record: scala.reflect.macros.Universe.Type): scala.reflect.macros.Universe.Tree

    Permalink
    Attributes
    protected[this]
  47. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  48. def isVararg(tpe: scala.reflect.macros.Universe.Type): Boolean

    Permalink
    Definition Classes
    HListHelpers
  49. val keyspaceType: scala.reflect.macros.Universe.Select

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  50. val knownList: List[String]

    Permalink
    Definition Classes
    RootMacro
  51. def lowercased(term: scala.reflect.macros.Universe.TermName): scala.reflect.macros.Universe.TermName

    Permalink
  52. def macroImpl(tableType: scala.reflect.macros.Universe.Type, recordType: scala.reflect.macros.Universe.Type): scala.reflect.macros.Universe.Tree

    Permalink
  53. val macroPkg: scala.reflect.macros.Universe.Select

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  54. def materialize[T, R](implicit arg0: scala.reflect.macros.Universe.WeakTypeTag[T], arg1: scala.reflect.macros.Universe.WeakTypeTag[R]): scala.reflect.macros.Universe.Tree

    Permalink
  55. def memoize[A, B](cache: Cache)(a: A, f: (A) ⇒ B): B

    Permalink
    Definition Classes
    WhiteboxToolbelt
  56. def mkCompoundTpe(nil: scala.reflect.macros.Universe.Type, cons: scala.reflect.macros.Universe.Type, items: List[scala.reflect.macros.Universe.Type]): scala.reflect.macros.Universe.Type

    Permalink
    Definition Classes
    HListHelpers
  57. def mkHListType(col: List[scala.reflect.macros.Universe.Type]): scala.reflect.macros.Universe.Type

    Permalink
    Definition Classes
    HListHelpers
  58. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  59. val notImplemented: scala.reflect.macros.Universe.Symbol

    Permalink
    Definition Classes
    RootMacro
  60. val notImplementedName: scala.reflect.macros.Universe.TermName

    Permalink
    Definition Classes
    RootMacro
  61. val nothingTpe: scala.reflect.macros.Universe.Type

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  62. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  63. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  64. def prefix(tpe: scala.reflect.macros.Universe.Type): scala.reflect.macros.Universe.Type

    Permalink
    Definition Classes
    HListHelpers
  65. def printType(tpe: scala.reflect.macros.Universe.Type): String

    Permalink
    Definition Classes
    HListHelpers
  66. val rootConn: scala.reflect.macros.Universe.Symbol

    Permalink
    Definition Classes
    RootMacro
  67. val rowTerm: scala.reflect.macros.Universe.TermName

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  68. val rowType: scala.reflect.macros.Universe.Select

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  69. val sasiIndexTpe: scala.reflect.macros.Universe.Type

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  70. val selectTable: scala.reflect.macros.Universe.Symbol

    Permalink
    Definition Classes
    RootMacro
  71. lazy val showAborts: Boolean

    Permalink
    Definition Classes
    WhiteboxToolbelt
  72. lazy val showCache: Boolean

    Permalink
    Definition Classes
    WhiteboxToolbelt
  73. def showCollection[M[X] <: TraversableOnce[X]](traversable: M[scala.reflect.macros.Universe.Type], sep: String = ", "): String

    Permalink
    Definition Classes
    HListHelpers
  74. def showHList(tpe: scala.reflect.macros.Universe.Type): String

    Permalink
    Definition Classes
    HListHelpers
  75. lazy val showTrees: Boolean

    Permalink
    Definition Classes
    WhiteboxToolbelt
  76. val strTpe: scala.reflect.macros.Universe.Select

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  77. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  78. val tableSym: scala.reflect.macros.Universe.Symbol

    Permalink
    Definition Classes
    RootMacro
  79. val tableTerm: scala.reflect.macros.Universe.TermName

    Permalink
    Attributes
    protected[this]
    Definition Classes
    RootMacro
  80. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  81. def tupleTerm(index: Int, aug: Int = 1): scala.reflect.macros.Universe.TermName

    Permalink
    Definition Classes
    RootMacro
  82. def unpackHListTpe(tpe: scala.reflect.macros.Universe.Type): List[scala.reflect.macros.Universe.Type]

    Permalink
    Definition Classes
    HListHelpers
  83. def variations(term: scala.reflect.macros.Universe.TermName): List[scala.reflect.macros.Universe.TermName]

    Permalink
  84. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  87. def warning(msg: String): Unit

    Permalink
    Definition Classes
    WhiteboxToolbelt

Inherited from RootMacro

Inherited from HListHelpers

Inherited from WhiteboxToolbelt

Inherited from AnyRef

Inherited from Any

Ungrouped