OSQL Reference
This is a reference manual for OSQL. For an easy introduction to OSQL you are recommended to run the SA Engine basics tutorial first.
Objects, types and functions
Everything in OSQL is represented as objects managed by the system, both system and user-defined objects. There are three main kinds of representations of objects: literals, collections, and surrogates.
Examples of literals are numbers and strings. They are self-contained atomic objects which are automatically removed by the system when no longer used.
Examples of collections are bags (sets that may contain duplicates), vectors, tensors, records (JSON objects), and streams. They contain other objects as elements. Collections are automatically removed by the system when no longer needed.
Surrogates are objects that are explicitly created and deleted by the user and stored in the local main-memory database inside SA Engine. They are identified by explicit object identifiers (OIDs). Examples of surrogates are objects representing real-world entities such as sensors, system objects such as functions, or SA Engine peers.
Objects are classified by a hierachy of types, each having an
associted name called type signature, such as Integer, String,
Array, Array of I8, Vector of Integer, or Stream.
Functions define the semantics (meaning) of objects. They
represent properties of objects, computations over objects and
relationships between objects. They are basic primitives in queries
and computational models. Functions are objects too and are instances
of the system type Function. Each function has an associated name
called signature, such as sin(Real x)->Real, sign(Number
x)->Integer, array(Charstring fmt,Vector data)->Array, or
simstream(Real pace)->Stream of Real.
Properties of artifacts, i.e. their meta-data model, are defined by creating functions, types and objects describing the artifacts known by an SA Engine peer. Artifacts can be, e.g., machine parts, its manufacturer, mounted sensors, what they are measuring, etc.
Statements, expressions and queries
The SA Engine REPL (Read-Eval-Print-Loop) reads OSQL statements from standard input. The value from the evaluation of each statement is then immediately printed on standard output.
The simplest form of statements are expressions, which are formulas
expressed with the OSQL syntax, e.g. 1+sin(3). Complex expressions
can be built up in terms of other expression. Expressions are basic
building blocks in all kinds of OSQL statements.
Expressions are the simplest form of OSQL queries. Complex queries can be formed by select expressions.
In addition to expressions there are OSQL statements that instruct SA Engine to perform certain tasks like updating or saving the local database.
The user may enter different kinds of OSQL statements to an interactive OSQL interface such as SA Studio or a Unix/Windows shell in order to instruct the system to do operations such as evaluating expressions, making queries, accessing server, giving instructions to SA Engine, or using the built-in database.
Organization
This reference manual is organized as follows:
The basic primitives of OSQL are desribed in basic constructs.
There is a main-memory database inside each SA Engine peer. It is used for storing models and local meta-data about data and streams managed by the peer. It can be populated, queried and updated using standard SQL statements as described in SQL Tables and Queries.
A central concept in SA Engine is the extensive use of functions in models and queries. There are several kinds of user-defined functions supported by the system as described in Functions.
Models analyzing numerical data such as sensor readings are often defined in terms of multi-dimensional arrays or tensors. The definition and querying of multi-dimensional arrays is described in Arrays and tensors.
General queries and computations over the local database are presented in Queries.
SA Engine provides the ability to specify queries and computations over ordered sequences of objects called vectors, as described in Vectors.
How to define queries and models over data continuoisly streaming through SA is described in Streams.
Types describes how to create user-defined types.
Objects describes how to create objects of user-defined types.
- Updates describes how to update user-defined objects.
