Skip to content

Instantly share code, notes, and snippets.

@sanikolaev
Last active April 12, 2021 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanikolaev/c9257714b0850c2989def31363420410 to your computer and use it in GitHub Desktop.
Save sanikolaev/c9257714b0850c2989def31363420410 to your computer and use it in GitHub Desktop.
manticore main+delta example
MySQL:
mysql> desc data;
+---------+------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------+------+-----+-------------------+-----------------------------+
| id | bigint(20) | NO | PRI | 0 | |
| body | text | YES | | NULL | |
| updated | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+---------+------------+------+-----+-------------------+-----------------------------+
3 rows in set (0.00 sec)
mysql> desc helper;
+----------+--------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+-------------------+-----------------------------+
| chunk_id | varchar(255) | NO | PRI | | |
| built | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+----------+--------------+------+-----+-------------------+-----------------------------+
2 rows in set (0.00 sec)
Config:
source main
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass =
sql_db = test
sql_query_pre = replace into helper set chunk_id = 'main_tmp', built = now()
sql_query = select id, body, unix_timestamp(updated) updated from data where updated >= from_unixtime($start) and updated <= from_unixtime($end)
sql_query_range = select (select unix_timestamp(min(updated)) from data) min, (select unix_timestamp(built) - 1 from helper where chunk_id = 'main_tmp') max
sql_query_post_index = replace into helper set chunk_id = 'main', built = (select built from helper t where chunk_id = 'main_tmp')
sql_range_step = 100
sql_field_string = body
sql_attr_timestamp = updated
}
source delta : main
{
sql_query_pre = replace into helper set chunk_id = 'delta_tmp', built = now()
sql_query_range = select (select unix_timestamp(built) from helper where chunk_id = 'main') min, (select unix_timestamp(built) from helper where chunk_id = 'delta_tmp') max
sql_query_killlist = select id from data where updated >= (select built from helper where chunk_id = 'main') and updated <= (select built from helper where chunk_id = 'delta_tmp')
sql_query_post_index = replace into helper set chunk_id = 'delta', built = (select built from helper t where chunk_id = 'delta_tmp')
}
index idx
{
type = distributed
local = idx_main
local = idx_delta
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment