Skip to contents

An abstract class that holds an entire surveillance system.

Methods


Method new()

Usage

SurveillanceSystem_v9$new(implementation_version = "unspecified")

Arguments

implementation_version

A string that the user may choose to use to track performance metrics (runtime and RAM usage)


Method add_table()

Add a table

Usage

SurveillanceSystem_v9$add_table(
  name_access,
  name_grouping = NULL,
  name_variant = NULL,
  field_types,
  keys,
  indexes = NULL,
  validator_field_types = csdb::validator_field_types_blank,
  validator_field_contents = csdb::validator_field_contents_blank
)

Arguments

name_access

First part of table name, corresponding to the database where it will be stored.

name_grouping

Second part of table name, corresponding to some sort of grouping.

name_variant

Final part of table name, corresponding to a distinguishing variant.

field_types

Named character vector, where the names are the column names, and the values are the column types. Valid types are BOOLEAN, CHARACTER, INTEGER, DOUBLE, DATE, DATETIME

keys

Character vector, containing the column names that uniquely identify a row of data.

indexes

Named list, containing indexes.

validator_field_types

Function corresponding to a validator for the field types.

validator_field_contents

Function corresponding to a validator for the field contents.

Examples

\dontrun{
global$ss$add_table(
  name_access = c("anon"),
  name_grouping = "example_weather",
  name_variant = "data",
  field_types =  c(
    "granularity_time" = "TEXT",
    "granularity_geo" = "TEXT",
    "country_iso3" = "TEXT",
    "location_code" = "TEXT",
    "border" = "INTEGER",
    "age" = "TEXT",
    "sex" = "TEXT",

    "isoyear" = "INTEGER",
    "isoweek" = "INTEGER",
    "isoyearweek" = "TEXT",
    "season" = "TEXT",
    "seasonweek" = "DOUBLE",

    "calyear" = "INTEGER",
    "calmonth" = "INTEGER",
    "calyearmonth" = "TEXT",

    "date" = "DATE",

    "temp_max" = "DOUBLE",
    "temp_min" = "DOUBLE",
    "precip" = "DOUBLE"
  ),
  keys = c(
    "granularity_time",
    "location_code",
    "date",
    "age",
    "sex"
  ),
  validator_field_types = csdb::validator_field_types_csfmt_rts_data_v1,
  validator_field_contents = csdb::validator_field_contents_csfmt_rts_data_v1
)
}


Method add_partitionedtable()

Usage

SurveillanceSystem_v9$add_partitionedtable(
  name_access,
  name_grouping = NULL,
  name_variant = NULL,
  name_partitions = "default",
  column_name_partition = "partition",
  value_generator_partition = NULL,
  field_types,
  keys,
  indexes = NULL,
  validator_field_types = csdb::validator_field_types_blank,
  validator_field_contents = csdb::validator_field_contents_blank
)


Method add_task()

add_task_from_config

Usage

SurveillanceSystem_v9$add_task(
  name_grouping = NULL,
  name_action = NULL,
  name_variant = NULL,
  cores = 1,
  permission = NULL,
  plan_analysis_fn_name = NULL,
  for_each_plan = NULL,
  for_each_analysis = NULL,
  universal_argset = NULL,
  upsert_at_end_of_each_plan = FALSE,
  insert_at_end_of_each_plan = FALSE,
  action_fn_name,
  data_selector_fn_name = NULL,
  tables = NULL
)

Arguments

name_grouping

Name of the task (grouping)

name_action

Name of the task (action)

name_variant

Name of the task (variant)

cores

Number of CPU cores

permission

A permission R6 instance

plan_analysis_fn_name

The name of a function that returns a named list list(for_each_plan = list(), for_each_analysis = NULL).

for_each_plan

A list, where each unit corresponds to one data extraction. Generally recommended to use plnr::expand_list.

for_each_analysis

A list, where each unit corresponds to one analysis within a plan (data extraction). Generally recommended to use plnr::expand_list.

universal_argset

A list, where these argsets are applied to all analyses univerally

upsert_at_end_of_each_plan

Do you want to upsert your results automatically at the end of each plan?

insert_at_end_of_each_plan

Do you want to insert your results automatically at the end of each plan?

action_fn_name

The name of the function that will be called for each analysis with arguments data, argset, schema

data_selector_fn_name

The name of a function that will be called to obtain the data for each analysis. The function must have the arguments argset, schema and must return a named list.

tables

A named list that maps sc9::config$schemas for use in action_fn_name and data_selector_fn_name


Method get_task()

Usage

SurveillanceSystem_v9$get_task(task_name)


Method run_task()

Usage

SurveillanceSystem_v9$run_task(task_name)


Method shortcut_get_tables()

Usage

SurveillanceSystem_v9$shortcut_get_tables(task_name)


Method shortcut_get_argset()

Usage

SurveillanceSystem_v9$shortcut_get_argset(
  task_name,
  index_plan = 1,
  index_analysis = 1
)


Method shortcut_get_data()

Usage

SurveillanceSystem_v9$shortcut_get_data(task_name, index_plan = 1)


Method shortcut_get_plans_argsets_as_dt()

Usage

SurveillanceSystem_v9$shortcut_get_plans_argsets_as_dt(task_name)


Method shortcut_get_num_analyses()

Usage

SurveillanceSystem_v9$shortcut_get_num_analyses(task_name)


Method clone()

The objects of this class are cloneable with this method.

Usage

SurveillanceSystem_v9$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `SurveillanceSystem_v9$add_table`
## ------------------------------------------------

if (FALSE) {
global$ss$add_table(
  name_access = c("anon"),
  name_grouping = "example_weather",
  name_variant = "data",
  field_types =  c(
    "granularity_time" = "TEXT",
    "granularity_geo" = "TEXT",
    "country_iso3" = "TEXT",
    "location_code" = "TEXT",
    "border" = "INTEGER",
    "age" = "TEXT",
    "sex" = "TEXT",

    "isoyear" = "INTEGER",
    "isoweek" = "INTEGER",
    "isoyearweek" = "TEXT",
    "season" = "TEXT",
    "seasonweek" = "DOUBLE",

    "calyear" = "INTEGER",
    "calmonth" = "INTEGER",
    "calyearmonth" = "TEXT",

    "date" = "DATE",

    "temp_max" = "DOUBLE",
    "temp_min" = "DOUBLE",
    "precip" = "DOUBLE"
  ),
  keys = c(
    "granularity_time",
    "location_code",
    "date",
    "age",
    "sex"
  ),
  validator_field_types = csdb::validator_field_types_csfmt_rts_data_v1,
  validator_field_contents = csdb::validator_field_contents_csfmt_rts_data_v1
)
}