2016-10-10 3 views
0

나는 예 : 사용자 정의 카산드라의 유형과 테이블을 정의했다?팬텀 DSL 및 카산드라 사용자 정의 열 유형

class MyTable extends CassandraTable[X, Y] { 
    object user extends UserColumn(this) with PartitionKey[User] 
         ^^^^^???       ^^^??? 

어떻게이 UserType에 대한 사용자 정의 UserColumn를 구현할 수있다? 필자는 열 구현에 대한 Phantom 코드를 확인했지만 예제 및/또는 설명은 훌륭했습니다.

답변

1

2 주 시간에 가입 할를 사용할 수있는, 유일한 프로 :

class MyTable extends CassandraTable[MyTable , Y] { 
    object user extends UDTColumn[MyTable, Y, User](this) with PartitionKey[User] 
} 

이렇게하면 자동화 된 스키마 생성 및 모든 el se, UDT의 자동 초기화 포함.

1

그래서 라이브러리의 저자에 따르면, 사용자 정의 형 팬텀의 오픈 소스 버전에서 지원되지 않는 그러나 https://github.com/outworkers/phantom/issues/496

, 당신이 여기에 설명 된 바와 같이 부분적으로 MapColumn을 확장하여 그것을 극복 할 수 있습니다 : Phantom-DSL cassandra with frozen type. 물론 완벽하지는 않습니다. 당신은 스키마 생성을 위해 CQL을 생성 할 수 없을 것이고 수동 파이프 작업을해야 할 것입니다.

그래서 더 많거나 적은 다음과 같이 같은 수 있었다 : 다음 UDTColumn를 사용

@Udt case class User(
    id: String, 
    firstname: String, 
    lastname: String 
) 

과 : 팬텀에서

class MyTable extends CassandraTable[MyTable , Y] { 
    object user extends MapColumn[MyTable , Y, String, String](this) with PartitionKey[MapColumn...] 
+0

PR을 알려 주셔서 감사합니다! – Bruckwald

관련 문제