func (p *PCAPParser) Accepted() int {
	return p.GetStats().Total()
}
Accepted returns the count of all rows received through InsertRow(s).
package parser
import (
	"path/filepath"
	"strings"
	"time"
	"cloud.google.com/go/bigquery"
	"cloud.google.com/go/civil"
	v2as "github.com/m-lab/annotation-service/api/v2"
	"github.com/m-lab/etl/etl"
	"github.com/m-lab/etl/metrics"
	"github.com/m-lab/etl/row"
	"github.com/m-lab/etl/schema"
)
const pcapSuffix = ".pcap.gz"
type PCAPParser struct {
	*row.Base
	table  string
	suffix string
}
func NewPCAPParser(sink row.Sink, table, suffix string, ann v2as.Annotator) etl.Parser {
	bufSize := etl.PCAP.BQBufferSize()
	if ann == nil {
		ann = v2as.GetAnnotator(etl.BatchAnnotatorURL)
	}
	return &PCAPParser{
		Base:   row.NewBase(table, sink, bufSize, ann),
		table:  table,
		suffix: suffix,
	}
}
func (p *PCAPParser) IsParsable(testName string, data []byte) (string, bool) {
	if strings.HasSuffix(testName, pcapSuffix) {
		return "pcap", true
	}
	return "", false
}
func (p *PCAPParser) ParseAndInsert(fileMetadata map[string]bigquery.Value, testName string, rawContent []byte) error {
	metrics.WorkerState.WithLabelValues(p.TableName(), "pcap").Inc()
	defer metrics.WorkerState.WithLabelValues(p.TableName(), "pcap").Dec()
	row := schema.PCAPRow{
		Parser: schema.ParseInfo{
			Version:    Version(),
			Time:       time.Now(),
			ArchiveURL: fileMetadata["filename"].(string),
			Filename:   testName,
			GitCommit:  GitCommit(),
		},
	}
	row.Date = fileMetadata["date"].(civil.Date)
	row.ID = p.GetUUID(testName)
	if err := p.Put(&row); err != nil {
		return err
	}
	metrics.TestCount.WithLabelValues(p.TableName(), "pcap", "ok").Inc()
	return nil
}
func (p *PCAPParser) GetUUID(filename string) string {
	id := filepath.Base(filename)
	return strings.TrimSuffix(id, pcapSuffix)
}
func (p *PCAPParser) Flush() error {
	return p.Base.Flush()
}
func (p *PCAPParser) TableName() string {
	return p.table
}
func (p *PCAPParser) FullTableName() string {
	return p.table + p.suffix
}
func (p *PCAPParser) RowsInBuffer() int {
	return p.GetStats().Pending
}
func (p *PCAPParser) Committed() int {
	return p.GetStats().Committed
}