@@ -264,7 +264,7 @@ func (d *DataStore) GetWaitObject(req *Request) (*DataRow, bool) {
264
264
return obj , ok
265
265
}
266
266
267
- type getPreFilteredDataFilter func (* DataStore , map [string ]bool , * Filter ) bool
267
+ type getPreFilteredDataFilter func (map [string ]bool , * Filter ) bool
268
268
269
269
// GetPreFilteredData returns d.Data but try to return reduced dataset by using host / service index if table supports it.
270
270
func (d * DataStore ) GetPreFilteredData (filter []* Filter ) []* DataRow {
@@ -274,11 +274,11 @@ func (d *DataStore) GetPreFilteredData(filter []*Filter) []*DataRow {
274
274
275
275
switch {
276
276
case d .Table .Name == TableHosts :
277
- return (d .tryFilterIndexData (filter , appendIndexHostsFromHostColumns ))
277
+ return (d .tryFilterIndexData (filter , d . appendIndexHostsFromHostColumns ))
278
278
case d .Table .Name == TableServices :
279
- return (d .tryFilterIndexData (filter , appendIndexHostsFromServiceColumns ))
279
+ return (d .tryFilterIndexData (filter , d . appendIndexHostsFromServiceColumns ))
280
280
case len (d .Table .PrimaryKey ) == 1 :
281
- return (d .tryFilterIndexData (filter , appendIndexFromPrimaryKey ))
281
+ return (d .tryFilterIndexData (filter , d . appendIndexFromPrimaryKey ))
282
282
default :
283
283
// only hosts and services are supported
284
284
}
@@ -462,7 +462,7 @@ func (d *DataStore) TryFilterIndex(uniqHosts map[string]bool, filter []*Filter,
462
462
}
463
463
filterFound ++
464
464
default :
465
- if filterCb (d , uniqHosts , fil ) {
465
+ if filterCb (uniqHosts , fil ) {
466
466
filterFound ++
467
467
} else if breakOnNoneIndexableFilter {
468
468
return false
@@ -474,7 +474,7 @@ func (d *DataStore) TryFilterIndex(uniqHosts map[string]bool, filter []*Filter,
474
474
return filterFound > 0
475
475
}
476
476
477
- func appendIndexHostsFromHostColumns ( dStore * DataStore , uniqHosts map [string ]bool , fil * Filter ) bool {
477
+ func ( d * DataStore ) appendIndexHostsFromHostColumns ( uniqHosts map [string ]bool , fil * Filter ) bool {
478
478
switch fil .Column .Name {
479
479
case "name" :
480
480
switch fil .Operator {
@@ -487,7 +487,7 @@ func appendIndexHostsFromHostColumns(dStore *DataStore, uniqHosts map[string]boo
487
487
// name =~ <value>
488
488
case EqualNocase :
489
489
uniqHosts [fil .StrValue ] = true
490
- for _ , key := range dStore .IndexLowerCase [strings .ToLower (fil .StrValue )] {
490
+ for _ , key := range d .IndexLowerCase [strings .ToLower (fil .StrValue )] {
491
491
uniqHosts [key ] = true
492
492
}
493
493
@@ -500,7 +500,7 @@ func appendIndexHostsFromHostColumns(dStore *DataStore, uniqHosts map[string]boo
500
500
// name == <value>
501
501
case Equal , EqualNocase :
502
502
uniqHosts [fil .StrValue ] = true
503
- for _ , key := range dStore .IndexLowerCase [strings .ToLower (fil .StrValue )] {
503
+ for _ , key := range d .IndexLowerCase [strings .ToLower (fil .StrValue )] {
504
504
uniqHosts [key ] = true
505
505
}
506
506
@@ -513,7 +513,7 @@ func appendIndexHostsFromHostColumns(dStore *DataStore, uniqHosts map[string]boo
513
513
switch fil .Operator {
514
514
// groups >= <value>
515
515
case GreaterThan :
516
- store := dStore .DataSet .tables [TableHostgroups ]
516
+ store := d .DataSet .tables [TableHostgroups ]
517
517
group , ok := store .Index [fil .StrValue ]
518
518
if ok {
519
519
members := group .GetStringListByName ("members" )
@@ -524,7 +524,7 @@ func appendIndexHostsFromHostColumns(dStore *DataStore, uniqHosts map[string]boo
524
524
525
525
return true
526
526
case RegexMatch , RegexNoCaseMatch , Contains , ContainsNoCase :
527
- store := dStore .DataSet .tables [TableHostgroups ]
527
+ store := d .DataSet .tables [TableHostgroups ]
528
528
for groupname , group := range store .Index {
529
529
if fil .MatchString (strings .ToLower (groupname )) {
530
530
members := group .GetStringListByName ("members" )
@@ -543,7 +543,7 @@ func appendIndexHostsFromHostColumns(dStore *DataStore, uniqHosts map[string]boo
543
543
return false
544
544
}
545
545
546
- func appendIndexHostsFromServiceColumns ( dStore * DataStore , uniqHosts map [string ]bool , fil * Filter ) bool {
546
+ func ( d * DataStore ) appendIndexHostsFromServiceColumns ( uniqHosts map [string ]bool , fil * Filter ) bool {
547
547
switch fil .Column .Name {
548
548
case "host_name" :
549
549
switch fil .Operator {
@@ -554,7 +554,7 @@ func appendIndexHostsFromServiceColumns(dStore *DataStore, uniqHosts map[string]
554
554
return true
555
555
// host_name ~ <value>
556
556
case RegexMatch , Contains :
557
- store := dStore .DataSet .tables [TableHosts ]
557
+ store := d .DataSet .tables [TableHosts ]
558
558
for hostname := range store .Index {
559
559
if fil .MatchString (hostname ) {
560
560
uniqHosts [hostname ] = true
@@ -569,7 +569,7 @@ func appendIndexHostsFromServiceColumns(dStore *DataStore, uniqHosts map[string]
569
569
switch fil .Operator {
570
570
// host_name ~~ <value>
571
571
case RegexMatch , Contains , RegexNoCaseMatch , ContainsNoCase , EqualNocase , Equal :
572
- store := dStore .DataSet .tables [TableHosts ]
572
+ store := d .DataSet .tables [TableHosts ]
573
573
for hostname := range store .Index {
574
574
if fil .MatchString (strings .ToLower (hostname )) {
575
575
uniqHosts [hostname ] = true
@@ -585,7 +585,7 @@ func appendIndexHostsFromServiceColumns(dStore *DataStore, uniqHosts map[string]
585
585
switch fil .Operator {
586
586
// groups >= <value>
587
587
case GreaterThan :
588
- store := dStore .DataSet .tables [TableHostgroups ]
588
+ store := d .DataSet .tables [TableHostgroups ]
589
589
group , ok := store .Index [fil .StrValue ]
590
590
if ok {
591
591
members := group .GetStringListByName ("members" )
@@ -596,7 +596,7 @@ func appendIndexHostsFromServiceColumns(dStore *DataStore, uniqHosts map[string]
596
596
597
597
return true
598
598
case RegexMatch , RegexNoCaseMatch , Contains , ContainsNoCase :
599
- store := dStore .DataSet .tables [TableHostgroups ]
599
+ store := d .DataSet .tables [TableHostgroups ]
600
600
for groupname , group := range store .Index {
601
601
if fil .MatchString (strings .ToLower (groupname )) {
602
602
members := group .GetStringListByName ("members" )
@@ -615,7 +615,7 @@ func appendIndexHostsFromServiceColumns(dStore *DataStore, uniqHosts map[string]
615
615
switch fil .Operator {
616
616
// groups >= <value>
617
617
case GreaterThan :
618
- store := dStore .DataSet .tables [TableServicegroups ]
618
+ store := d .DataSet .tables [TableServicegroups ]
619
619
group , ok := store .Index [fil .StrValue ]
620
620
if ok {
621
621
members := group .GetServiceMemberListByName ("members" )
@@ -626,7 +626,7 @@ func appendIndexHostsFromServiceColumns(dStore *DataStore, uniqHosts map[string]
626
626
627
627
return true
628
628
case RegexMatch , RegexNoCaseMatch , Contains , ContainsNoCase :
629
- store := dStore .DataSet .tables [TableServicegroups ]
629
+ store := d .DataSet .tables [TableServicegroups ]
630
630
for groupname , group := range store .Index {
631
631
if fil .MatchString (groupname ) {
632
632
members := group .GetServiceMemberListByName ("members" )
@@ -647,8 +647,8 @@ func appendIndexHostsFromServiceColumns(dStore *DataStore, uniqHosts map[string]
647
647
return false
648
648
}
649
649
650
- func appendIndexFromPrimaryKey ( dStore * DataStore , uniqRows map [string ]bool , fil * Filter ) bool {
651
- key := dStore .Table .PrimaryKey [0 ]
650
+ func ( d * DataStore ) appendIndexFromPrimaryKey ( uniqRows map [string ]bool , fil * Filter ) bool {
651
+ key := d .Table .PrimaryKey [0 ]
652
652
653
653
switch fil .Column .Name {
654
654
case key :
@@ -662,7 +662,7 @@ func appendIndexFromPrimaryKey(dStore *DataStore, uniqRows map[string]bool, fil
662
662
// name =~ <value>
663
663
case EqualNocase :
664
664
uniqRows [fil .StrValue ] = true
665
- for _ , key := range dStore .IndexLowerCase [strings .ToLower (fil .StrValue )] {
665
+ for _ , key := range d .IndexLowerCase [strings .ToLower (fil .StrValue )] {
666
666
uniqRows [key ] = true
667
667
}
668
668
@@ -675,7 +675,7 @@ func appendIndexFromPrimaryKey(dStore *DataStore, uniqRows map[string]bool, fil
675
675
// name == <value>
676
676
case Equal , EqualNocase :
677
677
uniqRows [fil .StrValue ] = true
678
- for _ , key := range dStore .IndexLowerCase [strings .ToLower (fil .StrValue )] {
678
+ for _ , key := range d .IndexLowerCase [strings .ToLower (fil .StrValue )] {
679
679
uniqRows [key ] = true
680
680
}
681
681
0 commit comments