Difference between revisions of "AMI Realtime Database"

From 3forge Documentation
Jump to navigation Jump to search
Tag: visualeditor-switched
Line 51: Line 51:
 
<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: blue;">col1</span> <span style="font-family: courier new; color: blue;"><u>public_column_type</u> ''['', col2 <u>public_column_type</u> ...'']''<span style="font-family: courier new; color: black;">)</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: blue;">col1</span> <span style="font-family: courier new; color: blue;"><u>public_column_type</u> ''['', col2 <u>public_column_type</u> ...'']''<span style="font-family: courier new; color: black;">)</span>
  
''[''<span style="font-family: courier new; color: red;">USE </span>'' [''<span style="font-family: courier new; color: red;">PersistEngine</span>''="[''<span style="font-family: courier new; color: red;">FAST</span>''|''<span style="font-family: courier new; color: red;">TEXT</span>''|custom]"]''
+
''[''<span style="font-family: courier new; color: red;">USE </span>'' [''<span style="font-family: courier new; color: red;">PersistEngine</span>''="[''<span style="font-family: courier new; color: red;">FAST</span>''|''<span style="font-family: courier new; color: red;">TEXT</span>''|<span style="font-family: courier new; color: grey;">custom</span>]"]''
  
''[''<span style="font-family: courier new; color: red;">PersistOptions</span>''="custom_options"]''
+
''[''<span style="font-family: courier new; color: red;">PersistOptions</span>''=<span style="font-family: courier new; color: grey;">"custom_options"</span>]''
  
 
''[''<span style="font-family: courier new; color: red;">Broadcast</span>''="[''<span style="font-family: courier new; color: red;">true</span>''|''<span style="font-family: courier new; color: red;">false</span>'']"]''
 
''[''<span style="font-family: courier new; color: red;">Broadcast</span>''="[''<span style="font-family: courier new; color: red;">true</span>''|''<span style="font-family: courier new; color: red;">false</span>'']"]''
  
''[''<span style="font-family: courier new; color: red;">RefreshPeriodMs</span>''="duration_millis"]''
+
''[''<span style="font-family: courier new; color: red;">RefreshPeriodMs</span>''=<span style="font-family: courier new; color: grey;">"duration_millis"</span>]''
  
 
''[''<span style="font-family: courier new; color: red;">OnUndefColumn</span>''="''<span style="font-family: courier new; color: red;">REJECT</span>''|''<span style="font-family: courier new; color: red;">IGNORE</span>''|''<span style="font-family: courier new; color: red;">ADD</span>''"]''
 
''[''<span style="font-family: courier new; color: red;">OnUndefColumn</span>''="''<span style="font-family: courier new; color: red;">REJECT</span>''|''<span style="font-family: courier new; color: red;">IGNORE</span>''|''<span style="font-family: courier new; color: red;">ADD</span>''"]''

Revision as of 16:18, 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:

  1. 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
  2. Data is fed through logical components which can aggregate, etc.
  3. 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
  • 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

Realtime Indexes

Realtime Triggers

Realtime Timers

Realtime Procedures

Realtime Tools

Capacity Planning