[json outputter] Remove error estimates from the json registry output.
Change-Id: I00de0dc8d1aa5e543095b6f78a1acde0c85c7cd7
Reviewed-on: https://fuchsia-review.googlesource.com/c/cobalt/+/929214
Fuchsia-Auto-Submit: Alexandre Zani <azani@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Reviewed-by: Cameron Dale <camrdale@google.com>
diff --git a/src/bin/config_parser/src/source_generator/json.go b/src/bin/config_parser/src/source_generator/json.go
index 22019dd..f51c975 100644
--- a/src/bin/config_parser/src/source_generator/json.go
+++ b/src/bin/config_parser/src/source_generator/json.go
@@ -11,9 +11,7 @@
"privacy"
)
-type jsonOutputter struct {
- errorCalculator *privacy.ErrorCalculator
-}
+type jsonOutputter struct{}
// JSON export structure
// go tags set the field name when exported to JSON data.
@@ -48,27 +46,19 @@
Reports []jsonReport `json:"reports"`
}
-type jsonError map[string]jsonErrorEstimate
-
type jsonReport struct {
- Name string `json:"name"`
- Id uint32 `json:"id"`
- ReportType string `json:"report_type"`
- ReportTypeId int32 `json:"report_type_id"`
- PrivacyLevel string `json:"privacy_level"`
- ErrorEstimates jsonError `json:"error_estimates"`
- EventVectorBufferMax uint64 `json:"event_vector_buffer_max"`
- StringBufferMax uint32 `json:"string_buffer_max"`
- SystemProfileField []string `json:"system_profile_field"`
- LocalAggregationPeriod int32 `json:"local_aggregation_period"`
- LocalAggregationProcedure string `json:"local_aggregation_procedure"`
- LocalAggregationProcedurePercentileN uint32 `json:"local_aggregation_procedure_percentile_n"`
- ExperimentId []int64 `json:"experiment_id"`
-}
-
-type jsonErrorEstimate struct {
- Epsilon float64 `json:"epsilon"`
- Estimates map[uint64]float64 `json:"estimates"`
+ Name string `json:"name"`
+ Id uint32 `json:"id"`
+ ReportType string `json:"report_type"`
+ ReportTypeId int32 `json:"report_type_id"`
+ PrivacyLevel string `json:"privacy_level"`
+ EventVectorBufferMax uint64 `json:"event_vector_buffer_max"`
+ StringBufferMax uint32 `json:"string_buffer_max"`
+ SystemProfileField []string `json:"system_profile_field"`
+ LocalAggregationPeriod int32 `json:"local_aggregation_period"`
+ LocalAggregationProcedure string `json:"local_aggregation_procedure"`
+ LocalAggregationProcedurePercentileN uint32 `json:"local_aggregation_procedure_percentile_n"`
+ ExperimentId []int64 `json:"experiment_id"`
}
// Generates a list of evenly distributed integer values
@@ -82,48 +72,6 @@
return elements
}
-func (jo *jsonOutputter) makeErrorEstimates(report *config.ReportDefinition, metric *config.MetricDefinition, populations []uint64) (estimate jsonError) {
- if jo.errorCalculator == nil {
- // Error calculator not provided; error estimation skipped.
- return nil
- }
-
- var estimates = jsonError{}
- for l, n := range config.ReportDefinition_PrivacyLevel_name {
- if n == "PRIVACY_LEVEL_UNKNOWN" || n == "NO_ADDED_PRIVACY" {
- continue
- }
- level := config.ReportDefinition_PrivacyLevel(l)
- epsilon := jo.errorCalculator.ParamsCalc.Constants.EpsilonForPrivacyLevel[level]
-
- var err error
- values := make(map[uint64]float64, len(populations))
- for _, population := range populations {
- // TODO(b/228513924): Support minDenominatorEstimates. Currently any report type requiring
- // a denominator estimate will return an error and not be included.
- var errorValue float64
- errorValue, err = jo.errorCalculator.Estimate(metric, report, epsilon, population, 0)
- if err != nil {
- break
- }
- values[population] = errorValue
- }
- if err != nil {
- // Error estimates must compute successfully for every population value otherwise the
- // estimates for this epsilon are not included.
- continue
- }
- estimates[level.String()] = jsonErrorEstimate{
- Epsilon: epsilon,
- Estimates: values,
- }
- }
- if len(estimates) == 0 {
- return nil
- }
- return estimates
-}
-
// JSON struct constructors
func (jo *jsonOutputter) makeJSONReport(report *config.ReportDefinition, metric *config.MetricDefinition) jsonReport {
if report == nil {
@@ -135,16 +83,12 @@
systemProfileField = append(systemProfileField, f.String())
}
- populations := linspace(10000, 10000000, 50)
- estimates := jo.makeErrorEstimates(report, metric, populations)
-
return jsonReport{
Name: report.GetReportName(),
Id: report.GetId(),
ReportType: report.GetReportType().String(),
ReportTypeId: int32(report.GetReportType()),
PrivacyLevel: report.GetPrivacyLevel().String(),
- ErrorEstimates: estimates,
EventVectorBufferMax: report.GetEventVectorBufferMax(),
StringBufferMax: report.GetStringBufferMax(),
SystemProfileField: systemProfileField,
@@ -261,9 +205,8 @@
}
// Returns an output formatter for JSON
-//
-// privacyParamsPath is the string path of the privacy params file to be used for error estimation.
-func JSONOutputFactory(errorCalculator *privacy.ErrorCalculator) OutputFormatter {
- jo := jsonOutputter{errorCalculator}
+// privacy.ErrorCalculator supports old code that still passes this parameter.
+func JSONOutputFactory(_ ...*privacy.ErrorCalculator) OutputFormatter {
+ jo := jsonOutputter{}
return jo.JSONOutput
}
diff --git a/src/bin/config_parser/src/source_generator/json_test.go b/src/bin/config_parser/src/source_generator/json_test.go
index 8d23dd5..ee476aa 100644
--- a/src/bin/config_parser/src/source_generator/json_test.go
+++ b/src/bin/config_parser/src/source_generator/json_test.go
@@ -8,7 +8,6 @@
import (
"config"
- "privacy"
"reflect"
"testing"
)
@@ -29,12 +28,7 @@
}
func constructTestJsonOutputter(t *testing.T) jsonOutputter {
- paramsCalc, err := privacy.NewPrivacyEncodingParamsCalculatorForTesting(testParamRecords)
- if err != nil {
- t.Errorf("Failed to create error calculator.")
- }
- errorCalc := privacy.NewErrorCalculator(*paramsCalc)
- return jsonOutputter{errorCalc}
+ return jsonOutputter{}
}
func TestConstructorsHandleNil(t *testing.T) {
@@ -61,25 +55,6 @@
}
}
-func TestMakeErrorEstimates(t *testing.T) {
- jo := constructTestJsonOutputter(t)
- r := config.ReportDefinition{
- ReportType: config.ReportDefinition_UNIQUE_DEVICE_COUNTS,
- PrivacyLevel: config.ReportDefinition_LOW_PRIVACY,
- LocalAggregationProcedure: config.ReportDefinition_SELECT_FIRST,
- }
- m := config.MetricDefinition{
- MetricType: config.MetricDefinition_OCCURRENCE,
- }
-
- want := jsonError(nil)
-
- got := jo.makeErrorEstimates(&r, &m, []uint64{10000, 100000, 1000000})
- if reflect.DeepEqual(want, got) == false {
- t.Errorf("makeJSONReport(%v)\n\n GOT: %v\nWANT: %v", r, got, want)
- }
-}
-
func TestMakeJSONReport(t *testing.T) {
jo := constructTestJsonOutputter(t)
name := "test_name"
@@ -115,7 +90,6 @@
ReportType: "FLEETWIDE_OCCURRENCE_COUNTS",
ReportTypeId: int32(config.ReportDefinition_FLEETWIDE_OCCURRENCE_COUNTS),
PrivacyLevel: "LOW_PRIVACY",
- ErrorEstimates: nil,
EventVectorBufferMax: eventVectorBufferMax,
StringBufferMax: stringBufferMax,
SystemProfileField: []string{"OS", "ARCH"},
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test.go b/src/bin/config_parser/src/source_generator/source_generator_test.go
index 7b2ef48..f87422d 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test.go
+++ b/src/bin/config_parser/src/source_generator/source_generator_test.go
@@ -207,7 +207,7 @@
{"golden_with_name_maps_filtered.cb.h", CppOutputFactory("config", []string{}, newOptionsWithNameMaps("300"))},
- {"golden.cb.json", JSONOutputFactory(nil)},
+ {"golden.cb.json", JSONOutputFactory()},
}
func TestPrintConfig(t *testing.T) {
diff --git a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.json b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.json
index 0c91f57..a939997 100644
--- a/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.json
+++ b/src/bin/config_parser/src/source_generator/source_generator_test_files/golden.cb.json
@@ -27,7 +27,6 @@
"report_type": "FLEETWIDE_OCCURRENCE_COUNTS",
"report_type_id": 11,
"privacy_level": "PRIVACY_LEVEL_UNKNOWN",
- "error_estimates": null,
"event_vector_buffer_max": 0,
"string_buffer_max": 0,
"system_profile_field": null,
@@ -45,7 +44,6 @@
"report_type": "HOURLY_VALUE_NUMERIC_STATS",
"report_type_id": 18,
"privacy_level": "PRIVACY_LEVEL_UNKNOWN",
- "error_estimates": null,
"event_vector_buffer_max": 0,
"string_buffer_max": 0,
"system_profile_field": null,
@@ -78,7 +76,6 @@
"report_type": "FLEETWIDE_OCCURRENCE_COUNTS",
"report_type_id": 11,
"privacy_level": "PRIVACY_LEVEL_UNKNOWN",
- "error_estimates": null,
"event_vector_buffer_max": 0,
"string_buffer_max": 0,
"system_profile_field": null,
@@ -115,7 +112,6 @@
"report_type": "FLEETWIDE_OCCURRENCE_COUNTS",
"report_type_id": 11,
"privacy_level": "LOW_PRIVACY",
- "error_estimates": null,
"event_vector_buffer_max": 0,
"string_buffer_max": 0,
"system_profile_field": null,
@@ -157,7 +153,6 @@
"report_type": "REPORT_TYPE_UNSET",
"report_type_id": 0,
"privacy_level": "PRIVACY_LEVEL_UNKNOWN",
- "error_estimates": null,
"event_vector_buffer_max": 0,
"string_buffer_max": 0,
"system_profile_field": null,
diff --git a/src/bin/config_parser/src/source_generator/source_outputter.go b/src/bin/config_parser/src/source_generator/source_outputter.go
index dd8f2fd..8da8866 100644
--- a/src/bin/config_parser/src/source_generator/source_outputter.go
+++ b/src/bin/config_parser/src/source_generator/source_outputter.go
@@ -465,7 +465,7 @@
case "java":
return JavaOutputFactory(varName, namespaceList, options, outFilename), nil
case "json":
- return JSONOutputFactory(errorCalculator), nil
+ return JSONOutputFactory(), nil
case "rust":
return RustOutputFactory(varName, namespaceList, options), nil
default: