HDFql Reference Manual v2.6.0

6.2.2TOP

Syntax

TOP {top_value | {, subtop_value} | {top_value, subtop_value}}

Description

Truncate a result set after position top_value from the top. In other words, all elements after position top_value are discarded from the result set. Additionally, if the result set is of data type HDFQL_CHAR, HDFQL_VARTINYINT, HDFQL_UNSIGNED_VARTINYINT, HDFQL_VARSMALLINT, HDFQL_UNSIGNED_VARSMALLINT, HDFQL_VARINT, HDFQL_UNSIGNED_VARINT, HDFQL_VARBIGINT, HDFQL_UNSIGNED_VARBIGINT, HDFQL_VARFLOAT, HDFQL_VARDOUBLE, or HDFQL_OPAQUE, the result subset can be truncated from the top by specifying subtop_value.

Parameter(s)

top_value – optional integer that specifies the position of the truncation of a result set from the top. If negative, the TOP option behaves as the BOTTOM option with a positive top_value.

subtop_value – optional integer that specifies the position of the truncation of a result set from the top. If negative, the TOP option behaves as the BOTTOM option with a positive subtop_value. Of note, this parameter is only applicable to a result set of one of the aforementioned data types and is ignored otherwise.

Return

The result set and/or subset is truncated from the top according to the specified position.

Example(s)

# create an HDF5 dataset named "my_dataset0" of data type float of four dimensions (size 5x8x4x7)
CREATE DATASET my_dataset0 AS FLOAT(5, 8, 4, 7)

# show (i.e. get) dimensions of dataset "my_dataset0" and populate cursor in use with these (should return 5, 8, 4, 7)
SHOW DIMENSION my_dataset0

# show (i.e. get) dimensions of dataset "my_dataset0" and populate cursor in use with the topmost (i.e. first) dimension (should return 5)
SHOW DIMENSION my_dataset0 TOP 1

# show (i.e. get) dimensions of dataset "my_dataset0" and populate cursor in use with the two topmost dimensions (should return 5, 8)
SHOW DIMENSION my_dataset0 TOP 2

# show (i.e. get) dimensions of dataset "my_dataset0" and populate cursor in use with the two bottommost dimensions (should return 4, 7)
SHOW DIMENSION my_dataset0 TOP -2

# create an HDF5 dataset named "my_dataset1" of data type variable-length int of one dimension (size 3) with initial values of 12, 14, and 16 for the first position, 18 for the second position, and 20, 22, 24, and 26 for the third position
CREATE DATASET my_dataset1 AS VARINT(3) VALUES((12, 14, 16), (18), (20, 22, 24, 26))

# select (i.e. read) data from dataset "my_dataset1" and populate cursor in use with it (should return 12, 14, 16, 18, 20, 22, 24, 26)
SELECT FROM my_dataset1

# select (i.e. read) data from dataset "my_dataset1" and populate cursor in use with values of the topmost (i.e. first) position (should return 12, 14, 16)
SELECT FROM my_dataset1 TOP 1

# select (i.e. read) data from dataset "my_dataset1" and populate cursor in use with values of the two topmost positions (should return 12, 14, 18, 20, 22)
SELECT FROM my_dataset1 TOP , 2

# select (i.e. read) data from dataset "my_dataset1" and populate cursor in use with the topmost value of the two bottommost positions (should return 18, 20)
SELECT FROM my_dataset1 TOP -2, 1