DataSketches Tuple Sketch 모듈
DataSketches Tuple Sketch 모듈
Apache DataSketches 라이브러리의 Tuple sketch를 기반으로 한 애그리게이터를 제공하는 모듈이에요. ArrayOfDoublesSketch는 고유 키와 연관된 double 값 배열을 추가해 개수 세기용 Theta sketch의 기능을 확장해요.
출처: 문서
본문
이 모듈은 Apache DataSketches 라이브러리의 Tuple sketch를 기반으로 한 Apache Druid 애그리게이터를 제공해요. ArrayOfDoublesSketch sketch는 고유 키와 연관된 double 값 배열을 추가해 개수 세기용 Theta sketch의 기능을 확장해요.
이 애그리게이터를 사용하려면 config 파일에 확장 기능을 포함하세요:
druid.extensions.loadList=["druid-datasketches"]
Druid가 지원하는 추가 sketch 유형은 DataSketches extension을 참고하세요.
애그리게이터 (Aggregator)
{
"type" : "arrayOfDoublesSketch",
"name" : <output_name>,
"fieldName" : <metric_name>,
"nominalEntries": <number>,
"metricColumns" : <array of strings>,
"numberOfValues" : <number>
}
| Property | Description | Required? | | type | This string should always be "arrayOfDoublesSketch" | yes | | name | String representing the output column to store sketch values. | yes | | fieldName | A string for the name of the input field. | yes | | nominalEntries | Parameter that determines the accuracy and size of the sketch. Higher k means higher accuracy but more space to store sketches. Must be a power of 2. See the Theta sketch accuracy for details. | no, defaults to 16384 | | metricColumns | When building sketches from raw data, an array input column that contain numeric values to associate with each distinct key. If not provided, assumes fieldName is an arrayOfDoublesSketch | no, if not provided fieldName is assumed to be an arrayOfDoublesSketch | | numberOfValues | Number of values associated with each distinct key. | no, defaults to the length of metricColumns if provided and 1 otherwise |
arrayOfDoublesSketch 애그리게이터는 다음에 사용할 수 있어요:
- 원시 데이터에서 스케치 생성. 이 경우
metricColumns를 배열로 설정하세요. - 기존 ArrayOfDoubles sketch에서 스케치 생성. 이 경우
metricColumns를 설정하지 않고fieldName을numberOfValues의 doubles를 가진 ArrayOfDoubles sketch로 설정하세요. 인제이션 시점에 ArrayOfDoubles sketch를 인제이션 시점에 base64 인코딩해야 해요.
원시 데이터 예제 (Example on top of raw data)
고유 사용자의 theta를 계산해요. 각 사용자에 대해 추가(added) 및 삭제(deleted) 점수를 저장해요. 새 스케치 컬럼은 users_theta라고 부를 거예요.
{
"type": "arrayOfDoublesSketch",
"name": "users_theta",
"fieldName": "user",
"nominalEntries": 16384,
"metricColumns": ["added", "deleted"],
}
사전 계산된 스케치 컬럼 인제스트 예제 (Example ingesting a precomputed sketch column)
배열에 두 double의 base64 인코딩 값이 있는 user_sketches라는 스케치 컬럼을 인제스트하고 users_theta라는 컬럼에 저장해요.
{
"type": "arrayOfDoublesSketch",
"name": "users_theta",
"fieldName": "user_sketches",
"nominalEntries": 16384,
"numberOfValues": 2,
}
Post aggregator (Post aggregators)
고유 키 수 추정 (Estimate of the number of distinct keys)
주어진 ArrayOfDoublesSketch에서 고유 개수 추정치를 반환해요.
{
"type" : "arrayOfDoublesSketchToEstimate",
"name": <output name>,
"field" : <post aggregator that refers to an ArrayOfDoublesSketch (fieldAccess or another post aggregator)>
}
오차 경계가 있는 고유 키 수 추정 (Estimate of the number of distinct keys with error bounds)
주어진 ArrayOfDoublesSketch에서 고유 개수 추정치와 오차 경계를 반환해요. 결과는 세 double 값: 고유 키 수 추정치, 하한, 상한이에요. 경계는 주어진 표준편차 수(선택 사항, 기본 1)에서 제공돼요. 이는 대략 68.3%, 95.4%, 99.7% 신뢰 구간에 해당하는 정수 값 1, 2 또는 3이어야 해요.
{
"type" : "arrayOfDoublesSketchToEstimateAndBounds",
"name": <output name>,
"field" : <post aggregator that refers to an ArrayOfDoublesSketch (fieldAccess or another post aggregator)>,
"numStdDevs", <number from 1 to 3>
}
보유 항목 수 (Number of retained entries)
주어진 ArrayOfDoublesSketch에서 보유 항목 수를 반환해요.
{
"type" : "arrayOfDoublesSketchToNumEntries",
"name": <output name>,
"field" : <post aggregator that refers to an ArrayOfDoublesSketch (fieldAccess or another post aggregator)>
}
각 컬럼의 평균 값 (Mean values for each column)
주어진 ArrayOfDoublesSketch에서 평균 값 목록을 반환해요. 결과는 N개의 double 값이며, N은 키당 스케치에 보관된 double 값 수예요.
{
"type" : "arrayOfDoublesSketchToMeans",
"name": <output name>,
"field" : <post aggregator that refers to a DoublesSketch (fieldAccess or another post aggregator)>
}
각 컬럼의 분산 값 (Variance values for each column)
주어진 ArrayOfDoublesSketch에서 분산 값 목록을 반환해요. 결과는 N개의 double 값이며, N은 키당 스케치에 보관된 double 값 수예요.
{
"type" : "arrayOfDoublesSketchToVariances",
"name": <output name>,
"field" : <post aggregator that refers to a DoublesSketch (fieldAccess or another post aggregator)>
}
컬럼에서 분위수 스케치 (Quantiles sketch from a column)
주어진 ArrayOfDoublesSketch의 주어진 값 컬럼에서 분위수 스케치의 정확도와 크기를 결정하는 선택적 매개변수 k를 사용해 구성된 quantiles DoublesSketch를 반환해요. Quantiles Sketch Module을 참고하세요.
컬럼 번호는 1부터 시작하며 선택 사항(기본 1)이에요.
매개변수 k는 선택 사항(기본값은 스케치 라이브러리에 정의됨)이에요.
결과는 quantiles sketch예요.
{
"type" : "arrayOfDoublesSketchToQuantilesSketch",
"name": <output name>,
"field" : <post aggregator that refers to a DoublesSketch (fieldAccess or another post aggregator)>,
"column" : <number>,
"k" : <parameter that determines the accuracy and size of the quantiles sketch>
}
집합 연산 (Set operations)
주어진 스케치 배열에 대해 지정된 집합 연산의 결과를 반환해요. 지원되는 연산은 union, intersection, set difference입니다(UNION, INTERSECT, NOT).
{
"type" : "arrayOfDoublesSketchSetOp",
"name": <output name>,
"operation": <"UNION"|"INTERSECT"|"NOT">,
"fields" : <array of post aggregators to access sketch aggregators or post aggregators to allow arbitrary combination of set operations>,
"nominalEntries" : <parameter that determines the accuracy and size of the sketch>,
"numberOfValues" : <number of values associated with each distinct key>
}
Student의 t-test
두 개의 ArrayOfDoublesSketch 인스턴스가 주어지면 Student의 t-test를 수행하고 p-값 목록을 반환해요. 결과는 N개의 double 값이며, N은 키당 스케치에 보관된 double 값 수예요. t-test 문서를 참고하세요.
{
"type" : "arrayOfDoublesSketchTTest",
"name": <output name>,
"fields" : <array with two post aggregators to access sketch aggregators or post aggregators referring to an ArrayOfDoublesSketch>,
}
Sketch summary
주어진 ArrayOfDoublesSketch의 사람이 읽을 수 있는 요약을 반환해요. 이는 스케치의 toString() 메서드가 반환한 문자열이에요. 디버깅에 유용할 수 있어요.
{
"type" : "arrayOfDoublesSketchToString",
"name": <output name>,
"field" : <post aggregator that refers to an ArrayOfDoublesSketch (fieldAccess or another post aggregator)>
}
상수 ArrayOfDoublesSketch (Constant ArrayOfDoublesSketch)
이 post aggregator는 다른 post aggregator에서 사용할 수 있는 Base64로 인코딩된 상수 ArrayOfDoublesSketch 값을 추가해요.
{
"type": "arrayOfDoublesSketchConstant",
"name": DESTINATION_COLUMN_NAME,
"value": CONSTANT_SKETCH_VALUE
}
ArrayOfDoublesSketch의 Base64 출력 (Base64 output of ArrayOfDoublesSketch)
이 post aggregator는 다른 post aggregator에서 사용할 수 있는 상수 tuple sketch 값을 저장하는 Base64로 인코딩된 문자열로 ArrayOfDoublesSketch를 출력해요.
{
"type": "arrayOfDoublesSketchToBase64String",
"name": DESTINATION_COLUMN_NAME,
"field": <post aggregator that refers to a ArrayOfDoublesSketch (fieldAccess or another post aggregator)>
}
ArrayOfDoublesSketch 각 컬럼의 추정 메트릭 값 (Estimated metrics values for each column of ArrayOfDoublesSketch)
주어진 ArrayOfDoublesSketch의 키-값 쌍에 대해 이 post aggregator는 키 전체에 걸친 각 값 집합의 합을 추정해요. 예를 들어 다음 키-값 쌍에 대해 post aggregator는 {3.0, 8.0}을 반환해요:
Key_1, {1.0, 3.0}
Key_2, {2.0, 5.0}
post aggregator는 N개의 double 값을 반환하며, N은 각 키와 연관된 값 수예요.
{
"type": "arrayOfDoublesSketchToMetricsSumEstimate",
"name": DESTINATION_COLUMN_NAME,
"field": <post aggregator that refers to a ArrayOfDoublesSketch (fieldAccess or another post aggregator)>
}