0

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. But when I run it, I see the default order as descending. I am using BigInsights version 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
]
Aviram Segal
  • 10,962
  • 3
  • 39
  • 52
Sumod
  • 3,806
  • 9
  • 50
  • 69

1 Answers1

0

Top does not impose any ordering on the input array. It translates to a 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. Top just translates to slice(), it does not look at the values. 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. Had you asked for:

jaql> nums -> top 3;

it would have returned: [ 2, 1, 3 ]