Email: support@essaywriterpros.com
Call Us: US - +1 845 478 5244 | UK - +44 20 7193 7850 | AUS - +61 2 8005 4826

Functional Dependency and Attribute Closure

TopN

Spec:

TopN(<FIELD>, [ROW_CALL], [n=UINT],
     [attrName=<ATTR_NAME>, attrValues=<[]ATTR_VALUE>])

Description:

Return the id and count of the top n rows (by count of bits) in the field. The attrName and attrValues arguments work together to only return rows which have the attribute specified by attrName with one of the values specified in attrValues.

Result Type: array of key/count objects

Caveats:

  • Performing a TopN() query on a field with cache type ranked will return the top rows sorted by count in descending order.
  • Fields with cache type lru will maintain an LRU (Least Recently Used replacement policy) cache, thus a TopN query on this type of field will return rows sorted in order of most recently set bit.
  • The field’s cache size determines the number of sorted rows to maintain in the cache for purposes of TopN queries. There is a tradeoff between performance and accuracy; increasing the cache size will improve accuracy of results at the cost of performance.
  • Once full, the cache will truncate the set of rows according to the field option CacheSize. Rows that straddle the limit and have the same count will be truncated in no particular order.
  • The TopN query’s attribute filter is applied to the existing sorted cache of rows. Rows that fall outside of the sorted cache range, even if they would normally pass the filter, are ignored.

See field creation for more information about the cache.

Examples:

Basic TopN query:

TopN(stargazer)
{"results":[[{"id":1240,"count":102},{"id":4734,"count":100},{"id":12709,"count":93},...]]}
  • id is a row ID (user ID)
  • count is a count of columns (repositories)
  • Results are the number of bits set in the corresponding row (repositories that each user starred) in descending order for all rows (users) in the stargazer field. For example user 1240 starred 102 repositories, user 4734 starred 100 repositories, user 12709 starred 93 repository.