summaryrefslogtreecommitdiff
path: root/sqlQueries.go
diff options
context:
space:
mode:
authorDaniel Langesten <daniel.langest@gmail.com>2015-03-17 11:48:08 +0100
committerDaniel Langesten <daniel.langest@gmail.com>2015-03-17 11:48:08 +0100
commit22ee0829d5ce9508d74d20abae3e06583e3d1820 (patch)
tree21479afe9c52865e1016716d8c368b28ce88bc28 /sqlQueries.go
parent2126152fc9408db4b7063cb3d75506c6b5af0921 (diff)
added check so we know if we can add differential privacy to the cleaned data.
Diffstat (limited to 'sqlQueries.go')
-rw-r--r--sqlQueries.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/sqlQueries.go b/sqlQueries.go
index 65b0a7a..b814d2e 100644
--- a/sqlQueries.go
+++ b/sqlQueries.go
@@ -179,11 +179,7 @@ func removeASNIP(db *sql.DB, asn int, ipBlock string) error {
// Adds differential privacy to all entries in the
// database that is older than t and haven't had
// differential privacy added to them yet.
-// If epsilon == 0 in conf. Then nothing is done.
func privatizeCleaned(db *sql.DB, t time.Time, conf Config) (err error) {
- if conf.Epsilon == 0 {
- return
- }
query, err := db.Prepare("SELECT ipb_src,ipb_dst,as_src,as_dst,port_src,port_dst,volume,time,occurences FROM clean_data WHERE time < ? FOR UPDATE")
if err != nil {
log.Println("Failed to prepare query")
@@ -220,3 +216,18 @@ func privatizeCleaned(db *sql.DB, t time.Time, conf Config) (err error) {
}
return
}
+
+func availableRows(tx *sql.Tx, limit time.Time) (numRows int, err error) {
+ stmt, err := tx.Prepare("SELECT COUNT(*) FROM acct WHERE stamp_inserted < ? ")
+ if err != nil {
+ log.Println("Could not prepare statement")
+ return
+ }
+ row := stmt.QueryRow(limit)
+
+ err = row.Scan(&numRows)
+ if err != nil {
+ log.Println("Failed to scan result")
+ }
+ return
+}