11package parser
22
3- // This file defines the Parser subtype that handles NDTResult data.
3+ // This file defines the Parser subtype that handles NDT5Result data.
44
55import (
66 "bytes"
@@ -21,30 +21,30 @@ import (
2121)
2222
2323//=====================================================================================
24- // NDTResult Parser
24+ // NDT5Result Parser
2525//=====================================================================================
2626
27- // NDTResultParser
28- type NDTResultParser struct {
27+ // NDT5ResultParser
28+ type NDT5ResultParser struct {
2929 * row.Base
3030 table string
3131 suffix string
3232}
3333
34- func NewNDTResultParser (sink row.Sink , table , suffix string , ann v2as.Annotator ) etl.Parser {
34+ func NewNDT5ResultParser (sink row.Sink , table , suffix string , ann v2as.Annotator ) etl.Parser {
3535 bufSize := etl .NDT5 .BQBufferSize ()
3636 if ann == nil {
3737 ann = v2as .GetAnnotator (annotation .BatchURL )
3838 }
3939
40- return & NDTResultParser {
40+ return & NDT5ResultParser {
4141 Base : row .NewBase ("foobar" , sink , bufSize , ann ),
4242 table : table ,
4343 suffix : suffix ,
4444 }
4545}
4646
47- func (dp * NDTResultParser ) TaskError () error {
47+ func (dp * NDT5ResultParser ) TaskError () error {
4848 stats := dp .GetStats ()
4949 if stats .Total () < 10 * stats .Failed {
5050 log .Printf ("Warning: high row insert errors (more than 10%%): %d failed of %d accepted\n " ,
@@ -55,20 +55,20 @@ func (dp *NDTResultParser) TaskError() error {
5555}
5656
5757// IsParsable returns the canonical test type and whether to parse data.
58- func (dp * NDTResultParser ) IsParsable (testName string , data []byte ) (string , bool ) {
58+ func (dp * NDT5ResultParser ) IsParsable (testName string , data []byte ) (string , bool ) {
5959 // Files look like: "<UUID>.json"
6060 if strings .HasSuffix (testName , "json" ) {
6161 return "ndt_result" , true
6262 }
6363 return "unknown" , false
6464}
6565
66- // NOTE: data.NDTResult is a JSON object that should be pushed directly into BigQuery.
66+ // NOTE: data.NDT5Result is a JSON object that should be pushed directly into BigQuery.
6767// We read the value into a struct, for compatibility with current inserter
6868// backend and to eventually rely on the schema inference in m-lab/go/bqx.CreateTable().
6969
70- // ParseAndInsert decodes the data.NDTResult JSON and inserts it into BQ.
71- func (dp * NDTResultParser ) ParseAndInsert (meta map [string ]bigquery.Value , testName string , test []byte ) error {
70+ // ParseAndInsert decodes the data.NDT5Result JSON and inserts it into BQ.
71+ func (dp * NDT5ResultParser ) ParseAndInsert (meta map [string ]bigquery.Value , testName string , test []byte ) error {
7272 // TODO: derive 'ndt5' (or 'ndt7') labels from testName.
7373 metrics .WorkerState .WithLabelValues (dp .TableName (), "ndt_result" ).Inc ()
7474 defer metrics .WorkerState .WithLabelValues (dp .TableName (), "ndt_result" ).Dec ()
@@ -85,7 +85,7 @@ func (dp *NDTResultParser) ParseAndInsert(meta map[string]bigquery.Value, testNa
8585 dec := json .NewDecoder (rdr )
8686
8787 for dec .More () {
88- stats := schema.NDTResultRow {
88+ stats := schema.NDT5ResultRow {
8989 TestID : testName ,
9090 ParseInfo : & schema.ParseInfo {
9191 TaskFileName : meta ["filename" ].(string ),
@@ -117,36 +117,36 @@ func (dp *NDTResultParser) ParseAndInsert(meta map[string]bigquery.Value, testNa
117117}
118118
119119// NB: These functions are also required to complete the etl.Parser interface.
120- // For NDTResult , we just forward the calls to the Inserter.
120+ // For NDT5Result , we just forward the calls to the Inserter.
121121
122- func (dp * NDTResultParser ) Flush () error {
122+ func (dp * NDT5ResultParser ) Flush () error {
123123 return dp .Base .Flush ()
124124}
125125
126- func (dp * NDTResultParser ) TableName () string {
126+ func (dp * NDT5ResultParser ) TableName () string {
127127 return dp .table
128128}
129129
130- func (dp * NDTResultParser ) FullTableName () string {
130+ func (dp * NDT5ResultParser ) FullTableName () string {
131131 return dp .table + dp .suffix
132132}
133133
134134// RowsInBuffer returns the count of rows currently in the buffer.
135- func (dp * NDTResultParser ) RowsInBuffer () int {
135+ func (dp * NDT5ResultParser ) RowsInBuffer () int {
136136 return dp .GetStats ().Pending
137137}
138138
139139// Committed returns the count of rows successfully committed to BQ.
140- func (dp * NDTResultParser ) Committed () int {
140+ func (dp * NDT5ResultParser ) Committed () int {
141141 return dp .GetStats ().Committed
142142}
143143
144144// Accepted returns the count of all rows received through InsertRow(s)
145- func (dp * NDTResultParser ) Accepted () int {
145+ func (dp * NDT5ResultParser ) Accepted () int {
146146 return dp .GetStats ().Total ()
147147}
148148
149149// Failed returns the count of all rows that could not be committed.
150- func (dp * NDTResultParser ) Failed () int {
150+ func (dp * NDT5ResultParser ) Failed () int {
151151 return dp .GetStats ().Failed
152152}
0 commit comments