diff options
author | Daniel Langesten <daniel.langest@gmail.com> | 2015-03-17 11:48:08 +0100 |
---|---|---|
committer | Daniel Langesten <daniel.langest@gmail.com> | 2015-03-17 11:48:08 +0100 |
commit | 22ee0829d5ce9508d74d20abae3e06583e3d1820 (patch) | |
tree | 21479afe9c52865e1016716d8c368b28ce88bc28 /main.go | |
parent | 2126152fc9408db4b7063cb3d75506c6b5af0921 (diff) |
added check so we know if we can add differential privacy to the cleaned data.
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -34,23 +34,27 @@ func main() { } */ starttime := time.Now() - err = cleanData(conf, DATABASE_USER, DATABASE_PASS, DATABASE_CONNECTION, DATABASE_NAME) + numOfRowsNotCleaned, err := cleanData(conf, DATABASE_USER, DATABASE_PASS, DATABASE_CONNECTION, DATABASE_NAME) if err != nil { log.Println(err) } - db, err := sql.Open("mysql", DATABASE_USER+":"+DATABASE_PASS+"@"+DATABASE_CONNECTION+"/"+DATABASE_NAME) - if err != nil { - log.Println("Failed to connect to db") - return - } - defer db.Close() - ival, err := conf.getInterval() - if err != nil { - log.Println("erronous interval in conf prevents the privatization of data") - return + // If either all rows are processed or if there is no limit for the processing + // we can safely add noise to the cleaned data + if numOfRowsNotCleaned == 0 || conf.Limit == 0 { + db, err := sql.Open("mysql", DATABASE_USER+":"+DATABASE_PASS+"@"+DATABASE_CONNECTION+"/"+DATABASE_NAME) + if err != nil { + log.Println("Failed to connect to db") + return + } + defer db.Close() + ival, err := conf.getInterval() + if err != nil { + log.Println("erronous interval in conf prevents the privatization of data") + return + } + privatizeCleaned(db, starttime.Add(-2*ival), conf) } - privatizeCleaned(db, starttime.Add(-2*ival), conf) } //Starts a process that reads from stdin and |