Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The operator can save the learned values info a database. The learned information is saved, not the tuples which learned the operator. When the query starts, the learned information is read from the database and written into the operator. This only happens once. The backup happens every time the operator updates the values. The PQL code belows shows, how to use this option.

Code Block
linenumberstrue
#PARSER PQL
#DEFINE BACKUPSCHEMA [['sum1', 'Double'],['sum2', 'Double'],['sumWindowSqr', 'Double'],['sumWindow', 'Double'],['m2', 'Double'],['mean', 'Double'],['backupId', 'String'],['k', 'Double'],['standardDeviation', 'Double'],['n', 'Double'],['group', 'Double'],['backupId', 'String']]
#ADDQUERY
/// Read backup data from the database
backupMongo = MONGODBSOURCE({
                  database = 'odysseus',
                  port = 27017,
                  host = 'localhost',
                  collectionname = 'condition'
                }
              )
/// Convert backup data to tuples
backupTuple = KEYVALUETOTUPLE({
            schema=${BACKUPSCHEMA},
            TYPE = 'Backup',
            KEEPINPUT = 'false'
          },
          backupMongo
        )
/// Run DeviationLearn and use backup data, if it exists ("Recovery")
deviationLearner = DEVIATIONLEARN({
                        trainingmode = 'ONLINE',
                        nameofparameter = 'vibration',
                        uniquebackupid = 'dev1'                      
                      },
                      System.fridgeVibration,
                      backupTuple
                    )
/// Convert backup data from port 2 to a key value object
keyValueOp = TUPLETOKEYVALUE({
                  type='KEYVALUEOBJECT'                            
                },
                2:deviationLearner
              )
/// Save the backup data to the database
mongoSink = MONGODBSINK({
                database = 'odysseus',
                port = 27017,
                host = 'localhost',
                collectionname = 'condition',
                batchsize = 1,
                deletebeforeinsert = 'true',
                deleteequalattribute = 'backupId'              
              },
              keyValueOp
            )