HDFql Reference Manual v2.6.0

6.2.4FROM TO

Syntax

FROM {from_value | {, subfrom_value} | {from_value, subfrom_value}} TO {to_value | {, subto_value} | {to_value, subto_value}}

Description

Retain a result set from from_value to to_value. In other words, all elements before position from_value and after position to_value are discarded from the result set. The first element of the result set is at position zero, while the last element is located at the position returned by hdfql_cursor_get_count - 1. 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 retained by specifying subfrom_value and/or subto_value.

Parameter(s)

from_value – optional integer that specifies the starting position from which to retain elements of a result set. If negative, the FROM option will retain elements of a result set starting from its end.

subfrom_value – optional integer that specifies the starting position from which to retain elements of a result set. If negative, the FROM option will retain elements of a result set starting from its end. Of note, this parameter is only applicable to a result set of one of the aforementioned data types and is ignored otherwise.

to_value – optional integer that specifies the ending position up to which to retain elements of a result set. If negative, the TO option will retain elements of a result set starting from its end.

subto_value – optional integer that specifies the ending position up to which to retain elements of a result set. If negative, the TO option will retain elements of a result set starting from its end. 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 retained according to the specified positions.

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 first, second and third dimensions (should return 5, 8, 4)
SHOW DIMENSION my_dataset0 FROM 0 TO 2

# show (i.e. get) dimensions of dataset "my_dataset0" and populate cursor in use with the second and third dimensions (should return 8, 4)
SHOW DIMENSION my_dataset0 FROM 1 TO 2

# show (i.e. get) dimensions of dataset "my_dataset0" and populate cursor in use with the second, third, and fourth dimensions (should return 8, 4, 7)
SHOW DIMENSION my_dataset0 FROM -3 TO -1

# show (i.e. get) dimensions of dataset "my_dataset0" and populate cursor in use with the second and third dimensions (should return 8, 4)
SHOW DIMENSION my_dataset0 FROM 1 TO -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 second position (should return 18)
SELECT FROM my_dataset1 FROM 1 TO 1

# select (i.e. read) data from dataset "my_dataset1" and populate cursor in use with values of the second and third positions (should return 18, 20, 22, 24, 26)
SELECT FROM my_dataset1 FROM -2 TO -1

# select (i.e. read) data from dataset "my_dataset1" and populate cursor in use with the second and third values of all positions (should return 14, 16, 22, 24)
SELECT FROM my_dataset1 FROM , 1 TO , 2

# select (i.e. read) data from dataset "my_dataset1" and populate cursor in use with second bottommost and bottommost values of the first position (should return 14, 16)
SELECT FROM my_dataset1 FROM 0, -2 TO 0, -1