DataSketches Quantiles Sketch 모듈
DataSketches Quantiles Sketch 모듈
Apache DataSketches 라이브러리의 DoublesSketch 기반 분위수(quantiles) 애그리게이터를 제공하는 모듈이에요. 값의 근사 분포를 얻어 순위, 분위수, 히스토그램을 계산해요.
출처: 문서
본문
이 모듈은 Apache DataSketches 라이브러리를 기반으로 한 분위수(quantiles) sketch 애그리게이터를 제공해요. sketch는 비교 가능한 값들의 근사 분포를 얻기 위한 병합 가능한 스트리밍 알고리즘이에요. sketch는 Druid 외부에서 인제스트하거나 인제이션 또는 쿼리 시점에 원시 데이터에서 만들 수 있어요. sketch는 페이지네이션 방법 없이 즉시 사용 가능한 형식으로 Druid 세그먼트에 저장될 수 있어요.
이 애그리게이터를 사용하려면 config 파일에 확장 기능을 포함하세요:
druid.extensions.loadList=["druid-datasketches"]
Druid가 지원하는 추가 sketch 유형은 DataSketches extension을 참고하세요.
애그리게이터 (Aggregator)
이것은 DoublesSketch를 만드는 근사 분위수 sketch 애그리게이터예요. 스케치의 입력은 모든 숫자 값이 될 수 있어요. DoublesSketch는 이 애그리게이터의 결과이며 이를 post-aggregator의 입력으로 사용해 분위수와 히스토그램을 계산할 수 있어요.
{
"type" : "quantilesDoublesSketch",
"name" : <output_name>,
"fieldName" : <metric_name>,
"k": <parameter that controls size and accuracy>,
"maxStreamLength": <parameter that controls memory allocation>
}
| Property | Description | Required? | | type | This String should always be "quantilesDoublesSketch" | yes | | name | A String for the output (result) name of the calculation. | yes | | fieldName | A String for the name of the input field (can contain sketches or raw numeric values). | yes | | k | 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 from 2 to 32768. See Quantiles Sketch Accuracy and Size for more details. | no, defaults to 128 | | maxStreamLength | Parameter that controls the memory allocation. Higher values require more memory to store the sketch. Must be a power of 2 from 32 to 1 billion. | no, defaults to 1000000000 |
Post aggregator (Post aggregators)
Quantile
DoublesSketch로부터 단일 분위수를 계산해요.
{
"type" : "quantilesDoublesSketchToQuantile",
"name": <output name>,
"field" : <post aggregator that refers to a DoublesSketch (fieldAccess or another post aggregator)>,
"fraction" : <fractional position in the hypothetical sorted stream, number from 0 to 1 inclusive>
}
Quantiles
DoublesSketch로부터 분위수 배열을 계산해요.
{
"type" : "quantilesDoublesSketchToQuantiles",
"name": <output name>,
"field" : <post aggregator that refers to a DoublesSketch (fieldAccess or another post aggregator)>,
"fractions" : <array of fractional positions in the hypothetical sorted stream, number from 0 to 1 inclusive>
}
Histogram
DoublesSketch로부터 히스토그램을 계산해요. 히스토그램 빈을 정의하는 분할점(split points) 배열 또는 빈 수(둘 다는 아님)를 지정할 수 있어요. m개의 고유하고 단조 증가하는 분할점 배열은 실수선을 m+1개의 연속적이고 서로소인 구간으로 나눠요. 구간의 정의는 왼쪽 분할점 포함이고 오른쪽 분할점 제외예요. 분할점 대신 빈 수가 지정되면 최소값과 최대값 사이의 구간이 주어진 수의 균등 간격 빈으로 나뉘어요.
{
"type" : "quantilesDoublesSketchToHistogram",
"name": <output name>,
"field" : <post aggregator that refers to a DoublesSketch (fieldAccess or another post aggregator)>,
"splitPoints" : <array of split points (optional)>,
"numBins" : <number of bins (optional, defaults to 10)>
}
Rank
주어진 값보다 작은 분포의 분수인, 주어진 값의 순위 근사치를 반환해요.
{
"type" : "quantilesDoublesSketchToRank",
"name": <output name>,
"field" : <post aggregator that refers to a DoublesSketch (fieldAccess or another post aggregator)>,
"value" : <value>
}
CDF
빈의 가장자리를 정의하는 분할점 배열이 주어지면 누적 분포 함수(Cumulative Distribution Function)의 근사치를 반환해요. m개의 고유하고 단조 증가하는 분할점 배열은 실수선을 m+1개의 연속적이고 서로소인 구간으로 나눠요. 구간의 정의는 왼쪽 분할점 포함이고 오른쪽 분할점 제외예요. 결과 분수 배열은 항상 1인 추가 순위 하나와 함께 각 분할점의 순위로 볼 수 있어요.
{
"type" : "quantilesDoublesSketchToCDF",
"name": <output name>,
"field" : <post aggregator that refers to a DoublesSketch (fieldAccess or another post aggregator)>,
"splitPoints" : <array of split points>
}
Sketch Summary
디버깅에 사용할 수 있는 sketch의 요약을 반환해요. toString() 메서드를 호출한 결과예요.
{
"type" : "quantilesDoublesSketchToString",
"name": <output name>,
"field" : <post aggregator that refers to a DoublesSketch (fieldAccess or another post aggregator)>
}