uCosminexus Stream Data Platform - Application Framework Description
CQL statements that are used to define streams and queries are called definition CQL. There are two types of definition CQL.
The following subsections explain how to specify each of these clauses.
To define a stream, you use the definition CQL REGISTER STREAM clause.
In the REGISTER STREAM clause, you specify the stream name (the name of the input stream) and the schema specification character string (the content of the stream data that identifies it as the input stream). The following shows the format for specifying a REGISTER STREAM clause:
REGISTER STREAM stream-name (schema-specification-character-string); |
For example, the following shows a CQL statement that defines a stream for a temperature analysis system:
REGISTER STREAM temperature_stream (observation_time TIME, id INTEGER, temperature INTEGER); |
For the stream name, temperature_stream is specified. The parameters observation_time (observation time), id (observation site ID), and temperature (measured temperature) are specified using the TIME, INTEGER, and INTEGER data types, respectively.
To define a query, you use the definition CQL REGISTER QUERY clause. In the REGISTER QUERY clause, you specify the name of the query, a stream clause, a SELECT clause, a FROM clause, and a WHERE clause, in that order. For the query name, you specify the name of the stream that is to be output after the stream data has been processed by the query (output stream).
The following table shows what the stream clause, SELECT clause, FROM clause, and WHERE clause, which make up the CQL REGISTER QUERY clause, do.
Table 2-1 Correspondence between query actions and clauses in a CQL statement
| Clause in a CQL statement | Query action |
|---|---|
| Stream clause | Specifies a stream operation action. |
| SELECT and WHERE clauses | Specifies a relation operation action. |
| FROM clause | Specifies a window operation action. |
The format for specifying a REGISTER QUERY clause is shown below:
REGISTER QUERY query-name stream-clause ( SELECT-clause FROM-clause WHERE-clause); |
The following paragraphs explain the clauses in the REGISTER QUERY clause.
For example, a query following the code for the temperature analysis system described above in (1) Defining a stream (REGISTER STREAM clause) is shown below.
REGISTER STREAM temperature_stream (observation_time TIME, id INTEGER, temperature INTEGER); REGISTER QUERY sensor_filter ISTREAM ( SELECT id, temperature FROM temperature_stream[ROWS 3] WHERE id = 1); |
The following paragraphs explain the items specified in the above REGISTER QUERY clause.
You can also specify other clauses in the REGISTER QUERY clause that are not described here. For details on these other clauses, see the uCosminexus Stream Data Platform - Application Framework Application Development Guide.
All Rights Reserved. Copyright (C) 2011, Hitachi, Ltd.