上图是官网的介绍,翻译后的意思是此模块提供Apache Druid聚合器为不同的计数基于HLL sketch来自datasketches数据库。摄入的时候这个聚合器创建HLL sketch对象存储在Druid的segments中。在查询的时候sketches被读取并且被合并到一起。最后默认情况下,你可以收到提交给sketch的不同值的估计值。此外,还可以使用post聚合器在同一行中生成sketch列的联合。可以对任何标识符的列使用HLL sketch聚合器。它将返回列的估计基数。
要是想要使用此聚合器,在配置文件中必须要包含:
druid.extensions.loadList=["druid-datasketches"]
聚合器示例:
{
"type" : "HLLSketchBuild",
"name" : <output name>,
"fieldName" : <metric name>,
"lgK" : <size and accuracy parameter>,
"tgtHllType" : <target HLL type>,
"round": <false | true>
}
{
"type" : "HLLSketchMerge",
"name" : <output name>,
"fieldName" : <metric name>,
"lgK" : <size and accuracy parameter>,
"tgtHllType" : <target HLL type>,
"round": <false | true>
}
参数的类型及对应的含义:
post的聚合器:
估计:返回不重复计数估计值的两倍
{
"type" : "HLLSketchEstimate",
"name": <output name>,
"field" : <post aggregator that returns an HLL Sketch>,
"round" : <if true, round the estimate. Default is false>
}
有界的估计:返回HLL sketch中不同的估算数和误差范围结果将是一个包含三个双精度值的数组:估计值、下界和上界。边界以给定的标准差数提供(可选默认是1)。该值必须是1、2或3的整数值,对应约68.3%、95.4%和99.7%的置信区间。
{
"type" : "HLLSketchEstimateWithBounds",
"name": <output name>,
"field" : <post aggregator that returns an HLL Sketch>,
"numStdDev" : <number of standard deviations: 1 (default), 2 or 3>
}
联合:
{
"type" : "HLLSketchUnion",
"name": <output name>,
"fields" : <array of post aggregators that return HLL sketches>,
"lgK": <log2 of K for the target sketch>,
"tgtHllType" : <target HLL type>
}
sketch to string:
{
"type" : "HLLSketchToString",
"name": <output name>,
"field" : <post aggregator that returns an HLL Sketch>
}