ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Kuznetsov <akuznet...@gridgain.com>
Subject Re: How to solve the 22 parameters' limit under scala 2.10 in the case class?
Date Fri, 01 Apr 2016 09:25:56 GMT
Why do you need case classes?
It is possible to use usual classes?

Here my code that works:

import org.apache.ignite.cache.query.annotations.{QuerySqlField,
QueryTextField}

import scala.annotation.meta.field

/**
 * Scala wrappers for java SQL annotations.
 */
object SqlAnnotations {
    type ScalaCacheQueryTextField = QueryTextField @field
    type ScalaCacheQuerySqlField = QuerySqlField @field
    type ScalaCacheQuerySqlFieldGroup = QuerySqlField.Group @field
}

class Card(
    @ScalaCacheQuerySqlField(index = true) val cardId: Long = 0L,
    @ScalaCacheQuerySqlField(index = true) val cardNumber: String = null,
 }

Could you try this approach?


On Fri, Apr 1, 2016 at 3:30 PM, F7753 <mabiaocsu@foxmail.com> wrote:

> Here are some details:
>   I created the case class A which parameter is less than 22 and the case
> class B which has more than 22 parameters, I want to let ignite to create
> index on the fields , so the case class is like:
>
> ---------------------------------------------------------------------------------------------------------------------
>   case class A (
>       @ScalarCacheQuerySqlField field0: String,
>       @ScalarCacheQuerySqlField field1: BigInt,
>       @ScalarCacheQuerySqlField field2: String,
>      ....
>       @ScalarCacheQuerySqlField field15: String,
>   )
>     case class B (
>       @ScalarCacheQuerySqlField field0: String,
>       @ScalarCacheQuerySqlField field1: BigInt,
>       @ScalarCacheQuerySqlField field2: String,
>      ....
>       @ScalarCacheQuerySqlField field50: String,
>   )
>
> -------------------------------------------------------------------------------------------------------------------
> then I use maven to compile the project, it alert the error:
>
>  error: Implementation restriction: case classes cannot have more than 22
> parameters.
>
> I found that in scala2.10 you can just create no more than 22 parameters in
> a case class, so I try to use StructType to see whether it can solve this,
> the code is like:
>
> --------------------------------------------------------------------------------------------------------------------
> object Schema{
>     val A = StructType( Array(
>                StructField("field0", StringType),
>                StructField("field1", LongType),
>                  .....
>                StructField("field15", StringType),
>                )
>     val B = StructType( Array(
>                StructField("field0", StringType),
>                StructField("field1", LongType),
>                  .....
>                StructField("field50", StringType),
>                )
> }
>
> --------------------------------------------------------------------------------------------------------------------
>
> How to add the annotation '@ScalarCacheQuerySqlField' ?
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/How-to-solve-the-22-parameters-limit-under-scala-2-10-in-the-case-class-tp3847p3849.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>



-- 
Alexey Kuznetsov
GridGain Systems
www.gridgain.com

Mime
View raw message