当前位置: 首页 > news >正文

做pc端网站机构短网址赚钱平台

做pc端网站机构,短网址赚钱平台,广西桂林旅游必去十大景点,wordpress怎么修改固定链接按照指定的表达式对输入文档进行分类后放入指定数字的桶中&#xff0c;跟$bucket不太一样&#xff0c;$bucketAuto可以指定分组的数量&#xff08;颗粒度&#xff09;&#xff0c;$bucketAuto会根据groupBy的值和颗粒度自动生成桶的边界。 语法 {$bucketAuto: {groupBy: <…

按照指定的表达式对输入文档进行分类后放入指定数字的桶中,跟$bucket不太一样,$bucketAuto可以指定分组的数量(颗粒度),$bucketAuto会根据groupBy的值和颗粒度自动生成桶的边界。

语法

{$bucketAuto: {groupBy: <表达式>,buckets: <数字>,output: {<输出1>: { <$accumulator 表达式> },...}granularity: <字符串>}
}

groupBy

表达式,对文档进行分组的表达式。若指定字段路径,需要在字段名前加上美元符号$并用引号引起来,如:$field_name

buckets

整数,32位的正整数,指定桶的数量也就是输入文档分组的数量。

output

文档,可选,指定了输出文档中除_id字段外要包含的其他字段,必须要使用汇总(累加器)表达式:

<输出字段1>: { <accumulator>: <表达式1> },
...

如果指定了输出字段,则count字段不会自动添加,需要的话要手动添加。如果不指定输出字段则默认添加一个count字段。

output: {<输出字段1>: { <accumulator>: <expres表达式1sion1> },...count: { $sum: 1 }
}

每个桶文档包含:

  • 一个桶边界下限的_id
    • _id.min字段指定了桶边界的下限(含)。
    • _id.max字段指定了桶边界的上限(不含)。除系列中的最后一个桶外,该界限对所有桶都是排他性的,因为在最后一个桶中,该界限是包含的。
  • count字段,包含文件桶中的文件数量。如果未指定输出文档,则默认包含count字段。

granularity

可选,字符串,指定了一个字符串,用于指定首选数列,以确保计算的边界边缘以首选的整数或其10的幂次结束。只有当所有groupBy值都是数值且都不是NaN时才有效。

支持的颗粒度:“R5”,“R10”,“R20”,“R40”,“R80”,“1-2-5”,“E6”,“E12”,“E24”,“E48”,“E96”,“E192”,“POWERSOF2”。

说明

如果出现以下情况,桶数量可能少于指定数量:

  • 输入文件的数量少于指定的文件桶数量。
  • groupBy表达式的唯一值数量少于指定的存储桶数量。
  • 粒度的间隔数少于桶数。
  • 粒度不够精细,无法将文档均匀分布到指定数量的桶中。

groupBy字段的粒度或唯一值的数量决定了文档是否能均匀分布到不同的桶。如果粒度不够,$bucketAuto阶段可能无法将结果均匀地分配到各个桶。

粒度

$bucketAuto接受一个可选的粒度参数,确保所有数据桶的边界都遵循指定的首选数列。使用首选数列可以更好地控制分组表达式中数值范围内的数据桶边界。当groupBy表达式的范围以指数形式扩展时,还可以使用首选数列帮助对数和均匀地设置数据桶边界。

雷纳数列

雷纳数列是通过取105次方根、10次方根、20次方根、40次方根或80次方根,然后将相当于1.0到 10.0(R80 为 10.3)之间数值的根的各种幂包含在内而得出的一组数字。

将粒度设置为 R5、R10、R20、R40 或 R80,可将数据桶边界限制为系列中的值。当 groupBy 值超出 1.0 至 10.0(R80 为 10.3)范围时,系列值将乘以 10 的幂。

R5 数列以 10 的五次方根 1.58 为基础,包括该根的各种幂次(四舍五入),直至 10。R5 数列的推导过程如下:

例如:

  • 10 0/5 = 1
  • 10 1/5 = 1.584 ~ 1.6
  • 10 2/5 = 2.511 ~ 2.5
  • 10 3/5 = 3.981 ~ 4.0
  • 10 4/5 = 6.309 ~ 6.3
  • 10 5/5 = 10

同样的方法也适用于其他雷纳系列,以提供更精细的粒度,即 1.0 和 10.0 之间的更多间隔(R80 为 10.3)。

E 序列

E 数字系列与雷纳数列类似,它们以特定的相对误差将 1.0 到 10.0 的区间细分为10的6、12、24、48、96或192的次方根。

将粒度设置为 E6、E12、E24、E48、E96 或 E192,可将桶边界限制为序列中的值。当 groupBy 值超出 1.0 到 10.0 的范围时,系列值将乘以 10 的幂。

1-2-5 序列

1-2-5 数列类似于三值数列雷纳数列。

将粒度设为 1-2-5,可将桶边界限制为 10 的三次根的各种幂,四舍五入到一位有效数字。

例如,以下数值属于 1-2-5 系列:0.1、0.2、0.5、1、2、5、10、20、50、100、200、500、1000 等…

2的次幂序列

将粒度设置为 POWERSOF2,限制桶边界为2的次幂

以下数字遵循2的幂序列:

  • 2^0 = 1
  • 2^1 = 2
  • 2^2 = 4
  • 2^3 = 8
  • 2^4 = 16
  • 2^5 = 32

一种常见的实现方式是,各种计算机组件(如内存)通常都遵守POWERSOF2的首选数字集:1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, …

不同粒度的比较

下面的操作演示了指定不同的粒度值如何影响$bucketAuto确定桶边界的方式。集合的_id从 0 到 99:

{ _id: 0 }
{ _id: 1 }
...
{ _id: 99 }

不同的粒度值会被代入到下面的操作中:

db.things.aggregate( [{$bucketAuto: {groupBy: "$_id",buckets: 5,granularity: <granularity>}}
] )

下表中的结果显示了不同的粒度值如何产生不同的桶边界:

粒度结果说明
无粒度{ “_id” : { “min” : 0, “max” : 20 }, “count” : 20 }{ “_id” : { “min” : 20, “max” : 40 }, “count” : 20 }{ “_id” : { “min” : 40, “max” : 60 }, “count” : 20 }{ “_id” : { “min” : 60, “max” : 80 }, “count” : 20 }{ “_id” : { “min” : 80, “max” : 99 }, “count” : 20 }
R20{ “_id” : { “min” : 0, “max” : 20 }, “count” : 20 }{ “_id” : { “min” : 20, “max” : 40 }, “count” : 20 }{ “_id” : { “min” : 40, “max” : 63 }, “count” : 23 }{ “_id” : { “min” : 63, “max” : 90 }, “count” : 27 }{ “_id” : { “min” : 90, “max” : 100 }, “count” : 10 }
E24{ “_id” : { “min” : 0, “max” : 20 }, “count” : 20 }{ “_id” : { “min” : 20, “max” : 43 }, “count” : 23 }{ “_id” : { “min” : 43, “max” : 68 }, “count” : 25 }{ “_id” : { “min” : 68, “max” : 91 }, “count” : 23 }{ “_id” : { “min” : 91, “max” : 100 }, “count” : 9 }
1-2-5{ “_id” : { “min” : 0, “max” : 20 }, “count” : 20 }{ “_id” : { “min” : 20, “max” : 50 }, “count” : 30 }{ “_id” : { “min” : 50, “max” : 100 }, “count” : 50 }指定的桶数超过系列中的间隔数。
POWERSOF2{ “_id” : { “min” : 0, “max” : 32 }, “count” : 32 }{ “_id” : { “min” : 32, “max” : 64 }, “count” : 32 }{ “_id” : { “min” : 64, “max” : 128 }, “count” : 36 }指定的桶数超过系列中的间隔数。

举例

下面的文档是收藏艺术品的集合:

{ "_id" : 1, "title" : "The Pillars of Society", "artist" : "Grosz", "year" : 1926,"price" : NumberDecimal("199.99"),"dimensions" : { "height" : 39, "width" : 21, "units" : "in" } }
{ "_id" : 2, "title" : "Melancholy III", "artist" : "Munch", "year" : 1902,"price" : NumberDecimal("280.00"),"dimensions" : { "height" : 49, "width" : 32, "units" : "in" } }
{ "_id" : 3, "title" : "Dancer", "artist" : "Miro", "year" : 1925,"price" : NumberDecimal("76.04"),"dimensions" : { "height" : 25, "width" : 20, "units" : "in" } }
{ "_id" : 4, "title" : "The Great Wave off Kanagawa", "artist" : "Hokusai","price" : NumberDecimal("167.30"),"dimensions" : { "height" : 24, "width" : 36, "units" : "in" } }
{ "_id" : 5, "title" : "The Persistence of Memory", "artist" : "Dali", "year" : 1931,"price" : NumberDecimal("483.00"),"dimensions" : { "height" : 20, "width" : 24, "units" : "in" } }
{ "_id" : 6, "title" : "Composition VII", "artist" : "Kandinsky", "year" : 1913,"price" : NumberDecimal("385.00"),"dimensions" : { "height" : 30, "width" : 46, "units" : "in" } }
{ "_id" : 7, "title" : "The Scream", "artist" : "Munch","price" : NumberDecimal("159.00"),"dimensions" : { "height" : 24, "width" : 18, "units" : "in" } }
{ "_id" : 8, "title" : "Blue Flower", "artist" : "O'Keefe", "year" : 1918,"price" : NumberDecimal("118.42"),"dimensions" : { "height" : 24, "width" : 20, "units" : "in" } }

单面聚合

在下面的操作中,输入文档将根据price字段中的值分成四组:

db.artwork.aggregate( [{$bucketAuto: {groupBy: "$price",buckets: 4}}
] )

该操作会返回以下文件:

{"_id" : {"min" : NumberDecimal("76.04"),"max" : NumberDecimal("159.00")},"count" : 2
}
{"_id" : {"min" : NumberDecimal("159.00"),"max" : NumberDecimal("199.99")},"count" : 2
}
{"_id" : {"min" : NumberDecimal("199.99"),"max" : NumberDecimal("385.00")},"count" : 2
}
{"_id" : {"min" : NumberDecimal("385.00"),"max" : NumberDecimal("483.00")},"count" : 2
}

多面聚合

…。

可在$facet阶段内使用$bucketAuto,对输入文档artwork进行多个聚合管道处理。

下面的聚合管道根据priceyearareaartwork 中的文档分组:

db.artwork.aggregate( [{$facet: {"price": [{$bucketAuto: {groupBy: "$price",buckets: 4}}],"year": [{$bucketAuto: {groupBy: "$year",buckets: 3,output: {"count": { $sum: 1 },"years": { $push: "$year" }}}}],"area": [{$bucketAuto: {groupBy: {$multiply: [ "$dimensions.height", "$dimensions.width" ]},buckets: 4,output: {"count": { $sum: 1 },"titles": { $push: "$title" }}}}]}}
] )

操作返回以下内容:

{"area" : [{"_id" : { "min" : 432, "max" : 500 },"count" : 3,"titles" : ["The Scream","The Persistence of Memory","Blue Flower"]},{"_id" : { "min" : 500, "max" : 864 },"count" : 2,"titles" : ["Dancer","The Pillars of Society"]},{"_id" : { "min" : 864, "max" : 1568 },"count" : 2,"titles" : ["The Great Wave off Kanagawa","Composition VII"]},{"_id" : { "min" : 1568, "max" : 1568 },"count" : 1,"titles" : ["Melancholy III"]}],"price" : [{"_id" : { "min" : NumberDecimal("76.04"), "max" : NumberDecimal("159.00") },"count" : 2},{"_id" : { "min" : NumberDecimal("159.00"), "max" : NumberDecimal("199.99") },"count" : 2},{"_id" : { "min" : NumberDecimal("199.99"), "max" : NumberDecimal("385.00") },"count" : 2 },{"_id" : { "min" : NumberDecimal("385.00"), "max" : NumberDecimal("483.00") },"count" : 2}],"year" : [{ "_id" : { "min" : null, "max" : 1913 }, "count" : 3, "years" : [ 1902 ] },{ "_id" : { "min" : 1913, "max" : 1926 }, "count" : 3, "years" : [ 1913, 1918, 1925 ] },{ "_id" : { "min" : 1926, "max" : 1931 }, "count" : 2, "years" : [ 1926, 1931 ] }]
}
http://www.yayakq.cn/news/114480/

相关文章:

  • 网站策划图建站流程新手搭建网站第一步
  • 淘宝网站建设的目标是什么网站都有哪些
  • 做网站要霸屏吗做网站之前要先购买服务器吗
  • 地方生活门户网站名称手机网站主页推荐
  • 手机在线制作网站怎么搭建网站视频教程
  • 做网站课程报告标志设计分析
  • 免费网站模板之家建设网站需要些什么手续
  • 做网站能赚钱吗 知乎页面跳转是什么意思
  • 兰州启点网站建设网页服务器一年多少钱
  • 建站公司选址dede企业网站模板下载
  • 帮别人做网站犯法吗网站建设用什么软件
  • 做网站tt0546深圳公司贷款
  • 织梦做的网站如何修改sem代运营推广公司
  • 诸暨东莞网站建设公司wordpress 关闭邮件
  • 深圳杰恩创意设计有限公司网站网站建设需要公司
  • 做网站宽度和长度布局深圳seo公司助力网络营销飞跃
  • 制作企业网站的基本步骤店面设计软件
  • 网站建设一般花多少费用wordpress注册时添密码
  • 全屏网站模板网站页面怎么设计
  • wordpress 图片自动分页百度seo和sem的区别
  • 别人用我的身份信息建设网站郑州网站建设推销
  • 摄影师常用的网站外贸网站友情链接
  • 没有网站可以做搜索引擎营销吗做苗木比较好的网站
  • 哈尔滨门户网站建站ui设计网站设计与网页制作视频教程
  • 手机建网站优帮云wordpress设置文章标题
  • 网站建设空心正方形wordpress主页设置
  • 跟做竞价的网站友情链接有用吗wap网站程序
  • 房产信息网站系统广州建筑公司招聘
  • 内蒙古建设厅安全资料网站天津网络优化招聘
  • 努比亚网站开发文档注册安全工程师报考官网