forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
machine.go
31734 lines (29689 loc) · 506 KB
/
machine.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//line plugins/parsers/influx/machine.go.rl:1
package influx
import (
"errors"
"io"
)
type readErr struct {
Err error
}
func (e *readErr) Error() string {
return e.Err.Error()
}
var (
ErrNameParse = errors.New("expected measurement name")
ErrFieldParse = errors.New("expected field")
ErrTagParse = errors.New("expected tag")
ErrTimestampParse = errors.New("expected timestamp")
ErrParse = errors.New("parse error")
EOF = errors.New("EOF")
)
//line plugins/parsers/influx/machine.go.rl:318
//line plugins/parsers/influx/machine.go:33
const LineProtocol_start int = 269
const LineProtocol_first_final int = 269
const LineProtocol_error int = 0
const LineProtocol_en_main int = 269
const LineProtocol_en_discard_line int = 257
const LineProtocol_en_align int = 739
const LineProtocol_en_series int = 260
//line plugins/parsers/influx/machine.go.rl:321
type Handler interface {
SetMeasurement(name []byte) error
AddTag(key []byte, value []byte) error
AddInt(key []byte, value []byte) error
AddUint(key []byte, value []byte) error
AddFloat(key []byte, value []byte) error
AddString(key []byte, value []byte) error
AddBool(key []byte, value []byte) error
SetTimestamp(tm []byte) error
}
type machine struct {
data []byte
cs int
p, pe, eof int
pb int
lineno int
sol int
handler Handler
initState int
key []byte
beginMetric bool
finishMetric bool
}
func NewMachine(handler Handler) *machine {
m := &machine{
handler: handler,
initState: LineProtocol_en_align,
}
//line plugins/parsers/influx/machine.go.rl:354
//line plugins/parsers/influx/machine.go.rl:355
//line plugins/parsers/influx/machine.go.rl:356
//line plugins/parsers/influx/machine.go.rl:357
//line plugins/parsers/influx/machine.go.rl:358
//line plugins/parsers/influx/machine.go.rl:359
//line plugins/parsers/influx/machine.go:90
{
( m.cs) = LineProtocol_start
}
//line plugins/parsers/influx/machine.go.rl:360
return m
}
func NewSeriesMachine(handler Handler) *machine {
m := &machine{
handler: handler,
initState: LineProtocol_en_series,
}
//line plugins/parsers/influx/machine.go.rl:371
//line plugins/parsers/influx/machine.go.rl:372
//line plugins/parsers/influx/machine.go.rl:373
//line plugins/parsers/influx/machine.go.rl:374
//line plugins/parsers/influx/machine.go.rl:375
//line plugins/parsers/influx/machine.go:117
{
( m.cs) = LineProtocol_start
}
//line plugins/parsers/influx/machine.go.rl:376
return m
}
func (m *machine) SetData(data []byte) {
m.data = data
m.p = 0
m.pb = 0
m.lineno = 1
m.sol = 0
m.pe = len(data)
m.eof = len(data)
m.key = nil
m.beginMetric = false
m.finishMetric = false
//line plugins/parsers/influx/machine.go:140
{
( m.cs) = LineProtocol_start
}
//line plugins/parsers/influx/machine.go.rl:393
m.cs = m.initState
}
// Next parses the next metric line and returns nil if it was successfully
// processed. If the line contains a syntax error an error is returned,
// otherwise if the end of file is reached before finding a metric line then
// EOF is returned.
func (m *machine) Next() error {
if m.p == m.pe && m.pe == m.eof {
return EOF
}
m.key = nil
m.beginMetric = false
m.finishMetric = false
return m.exec()
}
func (m *machine) exec() error {
var err error
//line plugins/parsers/influx/machine.go:168
{
if ( m.p) == ( m.pe) {
goto _test_eof
}
goto _resume
_again:
switch ( m.cs) {
case 269:
goto st269
case 1:
goto st1
case 2:
goto st2
case 3:
goto st3
case 0:
goto st0
case 4:
goto st4
case 5:
goto st5
case 6:
goto st6
case 270:
goto st270
case 271:
goto st271
case 272:
goto st272
case 7:
goto st7
case 8:
goto st8
case 9:
goto st9
case 10:
goto st10
case 11:
goto st11
case 12:
goto st12
case 13:
goto st13
case 14:
goto st14
case 15:
goto st15
case 16:
goto st16
case 17:
goto st17
case 18:
goto st18
case 19:
goto st19
case 20:
goto st20
case 21:
goto st21
case 22:
goto st22
case 23:
goto st23
case 24:
goto st24
case 25:
goto st25
case 26:
goto st26
case 27:
goto st27
case 28:
goto st28
case 29:
goto st29
case 30:
goto st30
case 31:
goto st31
case 273:
goto st273
case 274:
goto st274
case 32:
goto st32
case 33:
goto st33
case 275:
goto st275
case 276:
goto st276
case 277:
goto st277
case 34:
goto st34
case 278:
goto st278
case 279:
goto st279
case 280:
goto st280
case 281:
goto st281
case 282:
goto st282
case 283:
goto st283
case 284:
goto st284
case 285:
goto st285
case 286:
goto st286
case 287:
goto st287
case 288:
goto st288
case 289:
goto st289
case 290:
goto st290
case 291:
goto st291
case 292:
goto st292
case 293:
goto st293
case 294:
goto st294
case 295:
goto st295
case 35:
goto st35
case 36:
goto st36
case 296:
goto st296
case 297:
goto st297
case 298:
goto st298
case 37:
goto st37
case 38:
goto st38
case 39:
goto st39
case 40:
goto st40
case 41:
goto st41
case 299:
goto st299
case 300:
goto st300
case 301:
goto st301
case 302:
goto st302
case 42:
goto st42
case 303:
goto st303
case 304:
goto st304
case 305:
goto st305
case 306:
goto st306
case 307:
goto st307
case 308:
goto st308
case 309:
goto st309
case 310:
goto st310
case 311:
goto st311
case 312:
goto st312
case 313:
goto st313
case 314:
goto st314
case 315:
goto st315
case 316:
goto st316
case 317:
goto st317
case 318:
goto st318
case 319:
goto st319
case 320:
goto st320
case 321:
goto st321
case 322:
goto st322
case 323:
goto st323
case 324:
goto st324
case 43:
goto st43
case 44:
goto st44
case 45:
goto st45
case 46:
goto st46
case 47:
goto st47
case 48:
goto st48
case 49:
goto st49
case 50:
goto st50
case 51:
goto st51
case 52:
goto st52
case 325:
goto st325
case 326:
goto st326
case 327:
goto st327
case 53:
goto st53
case 54:
goto st54
case 55:
goto st55
case 56:
goto st56
case 57:
goto st57
case 58:
goto st58
case 328:
goto st328
case 329:
goto st329
case 59:
goto st59
case 330:
goto st330
case 331:
goto st331
case 332:
goto st332
case 333:
goto st333
case 334:
goto st334
case 335:
goto st335
case 336:
goto st336
case 337:
goto st337
case 338:
goto st338
case 339:
goto st339
case 340:
goto st340
case 341:
goto st341
case 342:
goto st342
case 343:
goto st343
case 344:
goto st344
case 345:
goto st345
case 346:
goto st346
case 347:
goto st347
case 348:
goto st348
case 349:
goto st349
case 60:
goto st60
case 350:
goto st350
case 351:
goto st351
case 352:
goto st352
case 61:
goto st61
case 353:
goto st353
case 354:
goto st354
case 355:
goto st355
case 356:
goto st356
case 357:
goto st357
case 358:
goto st358
case 359:
goto st359
case 360:
goto st360
case 361:
goto st361
case 362:
goto st362
case 363:
goto st363
case 364:
goto st364
case 365:
goto st365
case 366:
goto st366
case 367:
goto st367
case 368:
goto st368
case 369:
goto st369
case 370:
goto st370
case 371:
goto st371
case 372:
goto st372
case 62:
goto st62
case 63:
goto st63
case 64:
goto st64
case 65:
goto st65
case 66:
goto st66
case 373:
goto st373
case 67:
goto st67
case 68:
goto st68
case 69:
goto st69
case 70:
goto st70
case 71:
goto st71
case 374:
goto st374
case 375:
goto st375
case 376:
goto st376
case 72:
goto st72
case 73:
goto st73
case 74:
goto st74
case 377:
goto st377
case 378:
goto st378
case 379:
goto st379
case 75:
goto st75
case 380:
goto st380
case 381:
goto st381
case 382:
goto st382
case 383:
goto st383
case 384:
goto st384
case 385:
goto st385
case 386:
goto st386
case 387:
goto st387
case 388:
goto st388
case 389:
goto st389
case 390:
goto st390
case 391:
goto st391
case 392:
goto st392
case 393:
goto st393
case 394:
goto st394
case 395:
goto st395
case 396:
goto st396
case 397:
goto st397
case 398:
goto st398
case 399:
goto st399
case 76:
goto st76
case 77:
goto st77
case 78:
goto st78
case 79:
goto st79
case 80:
goto st80
case 81:
goto st81
case 82:
goto st82
case 83:
goto st83
case 84:
goto st84
case 85:
goto st85
case 86:
goto st86
case 87:
goto st87
case 88:
goto st88
case 89:
goto st89
case 400:
goto st400
case 401:
goto st401
case 402:
goto st402
case 403:
goto st403
case 90:
goto st90
case 91:
goto st91
case 92:
goto st92
case 93:
goto st93
case 404:
goto st404
case 405:
goto st405
case 94:
goto st94
case 95:
goto st95
case 406:
goto st406
case 96:
goto st96
case 97:
goto st97
case 407:
goto st407
case 408:
goto st408
case 98:
goto st98
case 409:
goto st409
case 410:
goto st410
case 99:
goto st99
case 100:
goto st100
case 411:
goto st411
case 412:
goto st412
case 413:
goto st413
case 414:
goto st414
case 415:
goto st415
case 416:
goto st416
case 417:
goto st417
case 418:
goto st418
case 419:
goto st419
case 420:
goto st420
case 421:
goto st421
case 422:
goto st422
case 423:
goto st423
case 424:
goto st424
case 425:
goto st425
case 426:
goto st426
case 427:
goto st427
case 428:
goto st428
case 101:
goto st101
case 429:
goto st429
case 430:
goto st430
case 431:
goto st431
case 102:
goto st102
case 103:
goto st103
case 432:
goto st432
case 433:
goto st433
case 434:
goto st434
case 104:
goto st104
case 435:
goto st435
case 436:
goto st436
case 437:
goto st437
case 438:
goto st438
case 439:
goto st439
case 440:
goto st440
case 441:
goto st441
case 442:
goto st442
case 443:
goto st443
case 444:
goto st444
case 445:
goto st445
case 446:
goto st446
case 447:
goto st447
case 448:
goto st448
case 449:
goto st449
case 450:
goto st450
case 451:
goto st451
case 452:
goto st452
case 453:
goto st453
case 454:
goto st454
case 105:
goto st105
case 455:
goto st455
case 456:
goto st456
case 457:
goto st457
case 458:
goto st458
case 459:
goto st459
case 460:
goto st460
case 461:
goto st461
case 462:
goto st462
case 463:
goto st463
case 464:
goto st464
case 465:
goto st465
case 466:
goto st466
case 467:
goto st467
case 468:
goto st468
case 469:
goto st469
case 470:
goto st470
case 471:
goto st471
case 472:
goto st472
case 473:
goto st473
case 474:
goto st474
case 475:
goto st475
case 476:
goto st476
case 106:
goto st106
case 107:
goto st107
case 108:
goto st108
case 109:
goto st109
case 110:
goto st110
case 477:
goto st477
case 111:
goto st111
case 478:
goto st478
case 479:
goto st479
case 112:
goto st112
case 480:
goto st480
case 481:
goto st481
case 482:
goto st482
case 483:
goto st483
case 484:
goto st484
case 485:
goto st485
case 486:
goto st486
case 487:
goto st487
case 488:
goto st488
case 113:
goto st113
case 114:
goto st114
case 115:
goto st115
case 489:
goto st489
case 116:
goto st116
case 117:
goto st117
case 118:
goto st118
case 490:
goto st490
case 119:
goto st119
case 120:
goto st120
case 491:
goto st491
case 492:
goto st492
case 121:
goto st121
case 122:
goto st122
case 123:
goto st123
case 124:
goto st124
case 493:
goto st493
case 494:
goto st494
case 495:
goto st495
case 125:
goto st125
case 496:
goto st496
case 497:
goto st497
case 498:
goto st498
case 499:
goto st499
case 500:
goto st500
case 501:
goto st501
case 502:
goto st502
case 503:
goto st503
case 504:
goto st504
case 505:
goto st505
case 506:
goto st506
case 507:
goto st507
case 508:
goto st508
case 509:
goto st509
case 510:
goto st510
case 511:
goto st511
case 512:
goto st512
case 513:
goto st513
case 514:
goto st514
case 515:
goto st515
case 126:
goto st126
case 127:
goto st127
case 516:
goto st516
case 517:
goto st517
case 518:
goto st518
case 519:
goto st519
case 520:
goto st520
case 521:
goto st521
case 522:
goto st522
case 523:
goto st523
case 524:
goto st524
case 128:
goto st128
case 129:
goto st129
case 130:
goto st130
case 525:
goto st525
case 131:
goto st131
case 132:
goto st132
case 133:
goto st133
case 526:
goto st526
case 134:
goto st134
case 135:
goto st135
case 527:
goto st527
case 528:
goto st528
case 136:
goto st136
case 137:
goto st137
case 138:
goto st138
case 529:
goto st529
case 530:
goto st530
case 139:
goto st139
case 531:
goto st531
case 140:
goto st140
case 532:
goto st532
case 533:
goto st533
case 534:
goto st534
case 535:
goto st535
case 536:
goto st536
case 537:
goto st537
case 538:
goto st538
case 539:
goto st539
case 141: