Thrift
Thrift (스리프트)
druid-thrift-extensions 확장은 Druid가 Kafka와 Kinesis 같은 스트리밍 소스에서 Thrift 인코딩 데이터를 수집할 수 있게 해줘요. Thrift 입력 포맷으로 중첩된 Thrift struct에서 필드를 추출할 수 있어요.
출처: 문서
본문
이 Apache Druid 확장을 사용하려면 extensions load list에 druid-thrift-extensions를 포함해 주세요.
druid-thrift-extensions
이 확장은 Druid가 Kafka와 Kinesis 같은 스트리밍 소스에서 Thrift 인코딩 데이터를 수집할 수 있게 해줘요.
다른 버전의 thrift를 사용하고 싶다면 pom에서 의존성을 바꾸고 직접 컴파일하면 돼요.
Thrift input format
스트리밍 수집(Kafka, Kinesis)을 위한 Thrift 인코딩 데이터는 Thrift 입력 포맷으로 수집할 수 있어요. JSONPath 표현식으로 중첩된 Thrift struct에서 필드를 추출하는 flattenSpec을 지원해요.
| 필드 | 타입 | 설명 | 필수 |
|---|---|---|---|
type |
String | 반드시 thrift여야 해요. |
yes |
thriftClass |
String | 역직렬화할 Thrift 생성 TBase 클래스의 정규화된 클래스 이름. |
yes |
thriftJar |
String | Thrift 클래스를 담고 있는 JAR 파일의 경로. 제공되지 않으면 클래스는 classpath에서 조회돼요. | no |
flattenSpec |
JSON Object | 중첩된 Thrift struct의 평탄화(flattening)를 지정해요. 자세한 내용은 Flattening nested data 참고. | no |
Example: Kafka ingestion
다음 Thrift 스키마 정의를 생각해 볼게요.
namespace java com.example.druid
struct Author {
1: string firstName;
2: string lastName;
}
struct Book {
1: string date;
2: double price;
3: string title;
4: Author author;
}
이를 컴파일해서 com.example.druid.Book(및 com.example.druid.Author)을 만들고, 결과 JAR를 Druid 프로세스의 classpath에 넣거나 thriftJar로 참조해 주세요.
다음 Kafka supervisor 스펙은 compact 인코딩 Book 메시지를 수집하고, flattenSpec으로 중첩된 author.lastName 필드를 추출해요.
{
"type": "kafka",
"spec": {
"dataSchema": {
"dataSource": "books",
"timestampSpec": {
"column": "date",
"format": "auto"
},
"dimensionsSpec": {
"dimensions": [
"title",
"lastName"
]
},
"granularitySpec": {
"type": "uniform",
"segmentGranularity": "DAY",
"queryGranularity": "NONE"
}
},
"tuningConfig": {
"type": "kafka"
},
"ioConfig": {
"type": "kafka",
"consumerProperties": {
"bootstrap.servers": "localhost:9092"
},
"topic": "books",
"inputFormat": {
"type": "thrift",
"thriftClass": "com.example.druid.Book",
"flattenSpec": {
"useFieldDiscovery": true,
"fields": [
{
"type": "path",
"name": "lastName",
"expr": "$.author.lastName"
}
]
}
},
"taskCount": 1,
"replicas": 1,
"taskDuration": "PT1H"
}
}
}