#!/usr/bin/perl -T

use strict;
use warnings;

use Time::HiRes qw( time );
use Value::Convertor;
use Mentat::Message::Storage::Mongo;
use Mentat::Message::Convertor::Mongo;
use Mentat::Message::Filter::Factory;
use Mentat::Message::Query::Mongo;

my $storage  = Mentat::Message::Query::Mongo->new(Mentat::Message::Convertor::Mongo->new(), Mentat::Message::Storage::Mongo->new());
my $ffactory = Mentat::Message::Filter::Factory->new_from_file('/etc/mentat/filter-grammar.conf');
my $filter   = $ffactory->filter_from_string('Alert/Source/Node/Address/ipv4/min ge 158.196.158.0 and Alert/Source/Node/Address/ipv4/max le 158.196.158.255 and Alert/Classification/@text eq "Webatack"');
my ($results, $count);

my $start = time;

################################################################################
# OPTION A
################################################################################

($results, $count) = $storage->query($filter);

################################################################################
my $end = time;
print STDERR "DURATION: ".($end-$start).", COUNT: $count\n";

