6.2.1ORDER
Syntax
ORDER {{ASC | DESC | REV} | {, {ASC | DESC | REV}} | {{ASC | DESC | REV}, {ASC | DESC | REV}}}
Description
Order (i.e. sort) a result set in an ascending, descending, or reverse way by specifying either the keyword ASC, DESC, or REV, respectively. When in an ascending or descending order, HDFql automatically uses a certain number of (CPU) threads (that may have been set through the operation SET THREAD) to speed up task completion33. 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 ordered (i.e. sorted) in an ascending, descending, or reverse way by specifying a comma (,) and either the keyword ASC, DESC, or REV, respectively. Of note, when the result set is of data type HDFQL_COMPOUND, ordering is ignored (i.e. has no effect).
Parameter(s)
None
Return
The result set and/or subset is ordered (i.e. sorted) in an ascending, descending, or reverse way depending on whether the keyword ASC, DESC, or REV is specified, respectively.
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 these in ascending order (should return 4, 5, 7, 8)
SHOW DIMENSION my_dataset0 ORDER ASC
# show (i.e. get) dimensions of dataset "my_dataset0" and populate cursor in use with these in descending order (should return 8, 7, 5, 4)
SHOW DIMENSION my_dataset0 ORDER DESC
# show (i.e. get) dimensions of dataset "my_dataset0" and populate cursor in use with these in reversed order (should return 7, 4, 8, 5)
SHOW DIMENSION my_dataset0 ORDER REV# create an HDF5 dataset named "my_dataset1" of data type double of two dimensions (size 3x2)
CREATE DATASET my_dataset1 AS DOUBLE(3, 2)
# insert (i.e. write) values into dataset "my_dataset1"
INSERT INTO my_dataset1 VALUES((3.2, 1.3), (0, 0.2), (9.1, 6.5))
# select (i.e. read) data from dataset "my_dataset1" and populate cursor in use with it (should return 3.2, 1.3, 0, 0.2, 9.1, 6.5)
SELECT FROM my_dataset1
# select (i.e. read) data from dataset "my_dataset1" and populate cursor in use with it in ascending order (should return 0, 0.2, 1.3, 3.2, 6.5, 9.1)
SELECT FROM my_dataset1 ORDER ASC
# select (i.e. read) data from dataset "my_dataset1" and populate cursor in use with it in descending order (should return 9.1, 6.5, 3.2, 1.3, 0.2, 0)
SELECT FROM my_dataset1 ORDER DESC
# select (i.e. read) data from dataset "my_dataset1" and populate cursor in use with it in reversed order (should return 6.5, 9.1, 0.2, 0, 1.3, 3.2)
SELECT FROM my_dataset1 ORDER REV
# create an HDF5 dataset named "my_dataset2" of data type variable-length double of one dimension (size 3)
CREATE DATASET my_dataset2 AS VARDOUBLE(3)
# insert (i.e. write) values into dataset "my_dataset2"
INSERT INTO my_dataset2 VALUES((3.2, 1.3), (0, 0.2), (9.1, 7.4, 6.5))
# select (i.e. read) data from dataset "my_dataset2" and populate cursor in use with it (should return 3.2, 1.3, 0, 0.2, 9.1, 7.4, 6.5)
SELECT FROM my_dataset2
# select (i.e. read) data from dataset "my_dataset2" and populate cursor in use with it in ascending order on the result subset only (should return 1.3, 3.2, 0, 0.2, 6.5, 7.4, 9.1)
SELECT FROM my_dataset2 ORDER , ASC
# select (i.e. read) data from dataset "my_dataset2" and populate cursor in use with it in descending order on the result subset only (should return 3.2, 1.3, 0.2, 0, 9.1, 7.4, 6.5)
SELECT FROM my_dataset2 ORDER , DESC
# select (i.e. read) data from dataset "my_dataset2" and populate cursor in use with it in reversed order on the result set only (should return 9.1, 7.4, 6.5, 0, 0.2, 3.2, 1.3)
SELECT FROM my_dataset2 ORDER REV
# select (i.e. read) data from dataset "my_dataset2" and populate cursor in use with it in reversed order on the result subset only (should return 1.3, 3.2, 0.2, 0, 6.5, 7.4, 9.1)
SELECT FROM my_dataset2 ORDER , REV
# select (i.e. read) data from dataset "my_dataset2" and populate cursor in use with it in reversed order on both the result set and result subset (should return 6.5, 7.4, 9.1, 0.2, 0, 1.3, 3.2)
SELECT FROM my_dataset2 ORDER REV, REVNotes
- Through a parallelized Quicksort algorithm. ↩