@@ -17,20 +17,20 @@ import (
1717)
1818
1919//=====================================================================================
20- // Annotation Parser
20+ // Annotation2 Parser
2121//=====================================================================================
2222
23- // AnnotationParser parses the annotation datatype from the uuid-annotator.
24- type AnnotationParser struct {
23+ // Annotation2Parser parses the annotation datatype from the uuid-annotator.
24+ type Annotation2Parser struct {
2525 * row.Base
2626 table string
2727 suffix string
2828}
2929
30- // NewAnnotationParser creates a new parser for annotation data.
31- func NewAnnotationParser (sink row.Sink , label , suffix string ) etl.Parser {
32- bufSize := etl .ANNOTATION .BQBufferSize ()
33- return & AnnotationParser {
30+ // NewAnnotation2Parser creates a new parser for annotation data.
31+ func NewAnnotation2Parser (sink row.Sink , label , suffix string ) etl.Parser {
32+ bufSize := etl .ANNOTATION2 .BQBufferSize ()
33+ return & Annotation2Parser {
3434 Base : row .NewBase (label , sink , bufSize ),
3535 table : label ,
3636 suffix : suffix ,
@@ -40,7 +40,7 @@ func NewAnnotationParser(sink row.Sink, label, suffix string) etl.Parser {
4040// TaskError returns non-nil if the task had enough failures to justify
4141// recording the entire task as in error. For now, this is any failure
4242// rate exceeding 10%.
43- func (ap * AnnotationParser ) TaskError () error {
43+ func (ap * Annotation2Parser ) TaskError () error {
4444 stats := ap .GetStats ()
4545 if stats .Total () < 10 * stats .Failed {
4646 log .Printf ("Warning: high row commit errors (more than 10%%): %d failed of %d accepted\n " ,
@@ -51,20 +51,20 @@ func (ap *AnnotationParser) TaskError() error {
5151}
5252
5353// IsParsable returns the canonical test type and whether to parse data.
54- func (ap * AnnotationParser ) IsParsable (testName string , data []byte ) (string , bool ) {
54+ func (ap * Annotation2Parser ) IsParsable (testName string , data []byte ) (string , bool ) {
5555 // Files look like: "<UUID>.json"
5656 if strings .HasSuffix (testName , "json" ) {
57- return "annotation " , true
57+ return "annotation2 " , true
5858 }
5959 return "unknown" , false
6060}
6161
62- // ParseAndInsert decodes the data.Annotation JSON and inserts it into BQ.
63- func (ap * AnnotationParser ) ParseAndInsert (meta map [string ]bigquery.Value , testName string , test []byte ) error {
64- metrics .WorkerState .WithLabelValues (ap .TableName (), "annotation " ).Inc ()
65- defer metrics .WorkerState .WithLabelValues (ap .TableName (), "annotation " ).Dec ()
62+ // ParseAndInsert decodes the data.Annotation2 JSON and inserts it into BQ.
63+ func (ap * Annotation2Parser ) ParseAndInsert (meta map [string ]bigquery.Value , testName string , test []byte ) error {
64+ metrics .WorkerState .WithLabelValues (ap .TableName (), "annotation2 " ).Inc ()
65+ defer metrics .WorkerState .WithLabelValues (ap .TableName (), "annotation2 " ).Dec ()
6666
67- row := schema.AnnotationRow {
67+ row := schema.Annotation2Row {
6868 Parser : schema.ParseInfo {
6969 Version : Version (),
7070 Time : time .Now (),
@@ -79,7 +79,7 @@ func (ap *AnnotationParser) ParseAndInsert(meta map[string]bigquery.Value, testN
7979 err := json .Unmarshal (test , & raw )
8080 if err != nil {
8181 log .Println (err )
82- metrics .TestTotal .WithLabelValues (ap .TableName (), "annotation " , "decode-location-error" ).Inc ()
82+ metrics .TestTotal .WithLabelValues (ap .TableName (), "annotation2 " , "decode-location-error" ).Inc ()
8383 return err
8484 }
8585
@@ -116,41 +116,41 @@ func (ap *AnnotationParser) ParseAndInsert(meta map[string]bigquery.Value, testN
116116 }
117117
118118 // Count successful inserts.
119- metrics .TestTotal .WithLabelValues (ap .TableName (), "annotation " , "ok" ).Inc ()
119+ metrics .TestTotal .WithLabelValues (ap .TableName (), "annotation2 " , "ok" ).Inc ()
120120 return nil
121121}
122122
123123// NB: These functions are also required to complete the etl.Parser interface.
124124// For Annotation, we just forward the calls to the Inserter.
125125
126- func (ap * AnnotationParser ) Flush () error {
126+ func (ap * Annotation2Parser ) Flush () error {
127127 return ap .Base .Flush ()
128128}
129129
130- func (ap * AnnotationParser ) TableName () string {
130+ func (ap * Annotation2Parser ) TableName () string {
131131 return ap .table
132132}
133133
134- func (ap * AnnotationParser ) FullTableName () string {
134+ func (ap * Annotation2Parser ) FullTableName () string {
135135 return ap .table + ap .suffix
136136}
137137
138138// RowsInBuffer returns the count of rows currently in the buffer.
139- func (ap * AnnotationParser ) RowsInBuffer () int {
139+ func (ap * Annotation2Parser ) RowsInBuffer () int {
140140 return ap .GetStats ().Pending
141141}
142142
143143// Committed returns the count of rows successfully committed to BQ.
144- func (ap * AnnotationParser ) Committed () int {
144+ func (ap * Annotation2Parser ) Committed () int {
145145 return ap .GetStats ().Committed
146146}
147147
148148// Accepted returns the count of all rows received through InsertRow(s)
149- func (ap * AnnotationParser ) Accepted () int {
149+ func (ap * Annotation2Parser ) Accepted () int {
150150 return ap .GetStats ().Total ()
151151}
152152
153153// Failed returns the count of all rows that could not be committed.
154- func (ap * AnnotationParser ) Failed () int {
154+ func (ap * Annotation2Parser ) Failed () int {
155155 return ap .GetStats ().Failed
156156}
0 commit comments