Difference between revisions of "AMI Realtime Database"
Tag: visualeditor-switched |
(→Syntax) |
||
Line 76: | Line 76: | ||
=== Syntax === | === Syntax === | ||
− | <span style="font-family: courier new; color: red;">CREATE PUBLIC TABLE [IF NOT EXISTS]</span> <span style="font-family: courier new; color: blue;">tblname</span> <span style="font-family: courier new; color: grey;">[(</span><span style="font-family: courier new; color: blue;">col1 public_column_type</span> | + | <span style="font-family: courier new; color: red;">CREATE PUBLIC TABLE [IF NOT EXISTS]</span> <span style="font-family: courier new; color: blue;">tblname</span> <span style="font-family: courier new; color: grey;">[(</span><span style="font-family: courier new; color: blue;">col1 public_column_type</span> <span style="font-family: courier new; color: grey;">[,</span> <span style="font-family: courier new; color: blue;">col2 public_column_type</span> <span style="font-family: courier new; color: grey;">...]</span><span style="font-family: courier new; color: red;">)</span><span style="font-family: courier new; color: grey;">]</span> <span style="font-family: courier new; color: grey;">[</span><span style="font-family: courier new; color: red;">USE</span> <span style="font-family: courier new; color: blue;">...</span> <span style="font-family: courier new; color: grey;">]</span> <span style="font-family: courier new; color: red;">AS</span> <span style="font-family: courier new; color: purple;">select_clause</span> |
=Realtime Indexes= | =Realtime Indexes= |
Revision as of 16:46, 9 March 2021
Goals
The 3Forge Realtime database builds on all of the features available in the AMI SQL language. The real-time datamodeling
- High Speed - 100k+ inserts per second, with 1 billion+ rows
- Persistent - Tables can be configured for long-term persistence
- Data Virtualization - Access external sources seamlessly
- Realtime Streaming - Chaining streams of updates into aggregations and other projections
- Source Synchronizing - Synchronizing in-memory tables based on external datasources
- Extendable - Create custom triggers, procedures, etc.
Broadly speaking, the logic steps involved in data-visualization are:
- Data is "streamed" into the AMI real-time database through a combination of methods
- High Speed Messaging
- JDBC
- Synchronizing from External Datasources
- User updates, from the front end visualization layer
- Data is fed through logical components which can aggregate, etc.
- Visualizations are built on the real-time tables and streams.
About Realtime (PUBLIC) tables
For the AMI Center, by default tables that are created are only visible to the current session and will be cleaned up when the connection is terminated. When a table is created with the PUBLIC directive (ex CREATE PUBLIC TABLE ...) the table will now be accessible to all sessions (external connections, triggers, etc) and front ends for real-time viewing. Public tables will continue to exist until they are explicitly dropped. Please see the reserved columns on public tables section for details on specialized columns that can be added.
Realtime Tables
create_public_table_clause
Overview
This command is used to create a new, empty (no rows) public table with a specified set of columns (names, types, no-null restriction). If another public table already exists with the tblname, the create table will fail.
At least one column must be specified, and each column must have a unique name. Columns with the nonull constraint cannot hold a null value. Updates and inserts in violation of the rule will fail.
The Following Use Options can be applied to a table:
- PersistEngine -
- "FAST": The table will be persisted to disk using a fast, binary protocol. Additional options include:
- "persist_dir" = "/path/to/directory/for/storing/file" - this is the directory where the .fast binary file will be saved/loaded from
- "persist_compact_percent" = ".95" - a number between 0 and 1 which says how much of the file should contain updates & deletes before it's compacted. Because the FAST table uses a journaling strategy, updates and deletes will get appended and can create large files. Setting a value of .95 would indicate that if the file becomes 95% updates and deletes then the file should be rebuilt
- "TEXT": The table will be persisted to disk using a slow, but easy to read text file
- "persist_dir" = "/path/to/directory/for/storing/file" - this is the directory where the .txt text file will be saved/loaded from
- "FAST": The table will be persisted to disk using a fast, binary protocol. Additional options include:
- PersistEngine="Custom": A custom persist engine will be used (see AMI plugins documentation). Note, that PersistOptions="..." is available to pass options to the custom plugin
- Broadcast="true": Front end visualizations & external listeners will be notified as data is updated in the table
- RefreshPeriodMs="durration_millis": The period that the table will conflate and broadcast changes to front end at. For example, if a cells' value changes 10 times in one second and the refresh period is 500ms, then only ~2 updates will be broadcast out (the other 8 will be conflated)
- OnUndefColumn - Behaviour to take when a realtime Object record contains an undefined column
- "REJECT" - The record will be rejected. This is the default
- "IGNORE" - The record will be inserted, but the undefined values will be ignored
- "ADD" - The table will automatically have the column added
- InitialCapacity="number_of_rows" - the number of rows to allocate memory for when the table is created. Must be at least 1. The default initial capacity is 1,000 rows
Syntax
CREATE PUBLIC TABLE [IF NOT EXISTS] tblname (col1 public_column_type [, col2 public_column_type ...])
[USE [PersistEngine="[FAST|TEXT|custom]"]
[PersistOptions="custom_options"]
[Broadcast="[true|false]"]
[RefreshPeriodMs="duration_millis"]
[OnUndefColumn="REJECT|IGNORE|ADD"]
tblname - string name of the table to create
colN - string name of Nth column to create
Examples
CREATE PUBLIC TABLE countries (country String NoNull, language String, GDP Double) USE PersistEngine="TEXT" Broadcast="false" InitialCapacity="100"
create_public_table_as_clause
Overview
This command is used to create a new table which has the same schema definition as the result set of a select_clause. If another table already exists with the tblname, the create table will fail.
All rows from the select_clause's result set will be inserted into the table. For valid USE options, see create_public_table_clause Options.
Syntax
CREATE PUBLIC TABLE [IF NOT EXISTS] tblname [(col1 public_column_type [, col2 public_column_type ...])] [USE ... ] AS select_clause