简体   繁体   English

Jaql-顶级操作员默认顺序

[英]Jaql - top operator default order

Per IBM documentation at - http://publib.boulder.ibm.com/infocenter/bigins/v1r1/index.jsp?topic=%2Fcom.ibm.swg.im.infosphere.biginsights.doc%2Fdoc%2Fc0057749.html the default order of Jaql's top operator is ascending. 根据IBM文档-http://publib.boulder.ibm.com/infocenter/bigins/v1r1/index.jsp?topic=%2Fcom.ibm.swg.im.infosphere.biginsights.doc%2Fdoc%2Fc0057749.html Jaql的top运算符的默认顺序是升序。 But when I run it, I see the default order as descending. 但是当我运行它时,我看到默认顺序为降序。 I am using BigInsights version 1.4. 我正在使用BigInsights 1.4版。 I was wondering if anyone knows whether this is a documentation issue or some other reason behind this seeming discrepancy - 我想知道是否有人知道这是文档问题还是这种看似差异背后的某些其他原因-

jaql> nums = [2,1,3];

jaql> nums -> top 2;
[
  2,
  1
]

Top does not impose any ordering on the input array. Top不会对输入数组施加任何排序。 It translates to a slice(array, 0, n); 它转换为一个slice(array,0,n); function call. 函数调用。 It takes the first n elements, unless you run it MR mode, which you did not in this example. 除非您运行它的MR模式,否则它将使用前n个元素,而在本示例中没有这样做。 Top just translates to slice(), it does not look at the values. 顶部只是转换为slice(),它不查看值。 If you wanted to impose a deterministic order, you would have to attach a comparator. 如果要施加确定性顺序,则必须附加比较器。

In this case, because the example used [2,1,3], it appears as though it is in descending order, but Top just returned the first two values in the array. 在这种情况下,由于示例使用[2,1,3],因此看起来好像是降序排列,但是Top只是返回了数组中的前两个值。 Had you asked for: 您是否要求过:

jaql> nums -> top 3; jaql> nums->前3个;

it would have returned: [ 2, 1, 3 ] 它会返回:[2,1,3]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM