OmniSketch  0.1
Oh my sketch!
OmniSketch::Test::TestBase< key_len, T > Class Template Reference

Collection of metrics. More...

#include <test.h>

Inheritance diagram for OmniSketch::Test::TestBase< key_len, T >:

Public Member Functions

 TestBase (const std::string_view show_name, const std::string_view config_file, const std::string_view test_path)
 Construct by specifying all necessary tables in config file. More...
 
virtual void show () const final
 Display metrics in a human-readable manner. More...
 
virtual void runTest ()
 Run the test and collect statistics. More...
 
virtual void testSize (std::unique_ptr< Sketch::SketchBase< key_len, T >> &ptr_sketch) final
 Get the size of the sketch. More...
 
virtual void testInsert (std::unique_ptr< Sketch::SketchBase< key_len, T >> &ptr_sketch, typename std::vector< Data::Record< key_len >>::const_iterator begin, typename std::vector< Data::Record< key_len >>::const_iterator end) final
 Insert a row of records. More...
 
virtual void testUpdate (std::unique_ptr< Sketch::SketchBase< key_len, T >> &ptr_sketch, typename std::vector< Data::Record< key_len >>::const_iterator begin, typename std::vector< Data::Record< key_len >>::const_iterator end, Data::CntMethod cnt_method) final
 Update a row of records (with values to the sketch) More...
 
virtual void testQuery (std::unique_ptr< Sketch::SketchBase< key_len, T >> &ptr_sketch, const Data::GndTruth< key_len, T > &gnd_truth) final
 Query for each flow in ground truth. More...
 
virtual void testLookup (std::unique_ptr< Sketch::SketchBase< key_len, T >> &ptr_sketch, const Data::GndTruth< key_len, T > &gnd_truth, const Data::GndTruth< key_len, T > &sample) final
 Lookup each flow in ground truth. More...
 
virtual void testHeavyHitter (std::unique_ptr< Sketch::SketchBase< key_len, T >> &ptr_sketch, double threshold, Data::GndTruth< key_len, T > gnd_truth_heavy_hitters) final
 Test heavy hitters. More...
 
virtual void testHeavyChanger (std::unique_ptr< Sketch::SketchBase< key_len, T >> &ptr_sketch_1, std::unique_ptr< Sketch::SketchBase< key_len, T >> &ptr_sketch_2, double threshold, Data::GndTruth< key_len, T > gnd_truth_heavy_changers) final
 Test heavy changers. More...
 
virtual void testDecode (std::unique_ptr< Sketch::SketchBase< key_len, T >> &ptr_sketch, Data::GndTruth< key_len, T > gnd_truth) final
 Test decode. More...
 

Protected Attributes

const std::string_view show_name
 
const std::string_view config_file
 
const std::string_view test_path
 

Detailed Description

template<int32_t key_len, typename T = int64_t>
class OmniSketch::Test::TestBase< key_len, T >

Collection of metrics.

Todo:
Docs for supported types of statistics
Template Parameters
key_lenlength of flowkey
Ttype of the counter
Test Routine Required Overriden Function Available Metrics (In Test::Metric) Name of the Testing Routine in TOML
testSize() size() SIZE None (Once calling testSize(), the metric is collected)
testInsert() insert() RATE insert
testUpdate() update() RATE update
testQuery() query() RATE, ARE, AAE, ACC, PODF, DIST query
testLookup() lookup() RATE, TP, FP, PRC lookup
testHeavyHitter() getHeavyHitter() TIME, ARE, PRC, RCL, F1 heavyhitter
testHeavyChanger() getHeavyChanger() TIME, ARE, PRC, RCL, F1 heavychanger
testDecode() decode() TIME, RATIO, ARE, AAE, ACC, PODF, DIST decode

Constructor & Destructor Documentation

◆ TestBase()

template<int32_t key_len, typename T = int64_t>
OmniSketch::Test::TestBase< key_len, T >::TestBase ( const std::string_view  show_name,
const std::string_view  config_file,
const std::string_view  test_path 
)
inline

Construct by specifying all necessary tables in config file.

Parameters
show_nameThe name to be shown in the output (may contain whitespaces)
config_filePath to the config file
test_pathPath to the node which stores the testing metrics (concatenated with '.', see example below)

Example

If the toml file is as follows,

# toml.toml
[MySketch]
[MySketch.para]
arg1 = 1
arg2 = 2
[MySketch.test]
insert = ["RATE"]
arg3 = 3
[MySketch.data]
data = "../record.bin"
format = [["flowkey", "padding"], [13, 3]]

and you want the readable name "My Tiny Little Sketch" when showing results, then you should call constructor in this way:

TestBase<...>("My Tiny Little Sketch", "toml.toml", "MySketch.test");
Note
  • Except for show_name, all other strings should contain no whitespaces.

Member Function Documentation

◆ runTest()

◆ show()

template<int32_t key_len, typename T >
void OmniSketch::Test::TestBase< key_len, T >::show
finalvirtual

Display metrics in a human-readable manner.

Todo:
DIST
Todo:
DIST

◆ testDecode()

template<int32_t key_len, typename T >
void OmniSketch::Test::TestBase< key_len, T >::testDecode ( std::unique_ptr< Sketch::SketchBase< key_len, T >> &  ptr_sketch,
Data::GndTruth< key_len, T >  gnd_truth 
)
finalvirtual

Test decode.

You should override the Sketch::SketchBase::decode() method.

Parameters
ptr_sketchpointer to the sketch
gnd_truthground truth

◆ testHeavyChanger()

template<int32_t key_len, typename T >
void OmniSketch::Test::TestBase< key_len, T >::testHeavyChanger ( std::unique_ptr< Sketch::SketchBase< key_len, T >> &  ptr_sketch_1,
std::unique_ptr< Sketch::SketchBase< key_len, T >> &  ptr_sketch_2,
double  threshold,
Data::GndTruth< key_len, T >  gnd_truth_heavy_changers 
)
finalvirtual

Test heavy changers.

You should override the Sketch::SketchBase::getHeavyChangers() method.

Parameters
ptr_sketch_1pointer to the first sketch
ptr_sketch_2pointer to the second sketch
thresholdthreshold value of heavy changers
gnd_truth_heavy_changersground truth of heavy changers (relative to the first sketch)

◆ testHeavyHitter()

template<int32_t key_len, typename T >
void OmniSketch::Test::TestBase< key_len, T >::testHeavyHitter ( std::unique_ptr< Sketch::SketchBase< key_len, T >> &  ptr_sketch,
double  threshold,
Data::GndTruth< key_len, T >  gnd_truth_heavy_hitters 
)
finalvirtual

Test heavy hitters.

You should override the Sketch::SketchBase::getHeavyHitter() method.

Parameters
ptr_sketchpointer to the sketch
thresholdthreshold value of heavy hitters
gnd_truth_heavy_hittersground truth of heavy hitters

◆ testInsert()

template<int32_t key_len, typename T >
void OmniSketch::Test::TestBase< key_len, T >::testInsert ( std::unique_ptr< Sketch::SketchBase< key_len, T >> &  ptr_sketch,
typename std::vector< Data::Record< key_len >>::const_iterator  begin,
typename std::vector< Data::Record< key_len >>::const_iterator  end 
)
finalvirtual

Insert a row of records.

Records in [begin, end) will be sequentially inserted. You should override the Sketch::SketchBase::insert() method.

Parameters
ptr_sketchpointer to the sketch
begin[begin, end)
end[begin, end)

◆ testLookup()

template<int32_t key_len, typename T >
void OmniSketch::Test::TestBase< key_len, T >::testLookup ( std::unique_ptr< Sketch::SketchBase< key_len, T >> &  ptr_sketch,
const Data::GndTruth< key_len, T > &  gnd_truth,
const Data::GndTruth< key_len, T > &  sample 
)
finalvirtual

Lookup each flow in ground truth.

You should override the Sketch::SketchBase::lookup() method.

Parameters
ptr_sketchpointer to the sketch
gnd_truthground truth
samplesampled ground truth

◆ testQuery()

template<int32_t key_len, typename T >
void OmniSketch::Test::TestBase< key_len, T >::testQuery ( std::unique_ptr< Sketch::SketchBase< key_len, T >> &  ptr_sketch,
const Data::GndTruth< key_len, T > &  gnd_truth 
)
finalvirtual

Query for each flow in ground truth.

You should override the Sketch::SketchBase::query() method.

Parameters
ptr_sketchpointer to the sketch
gnd_truthground truth

◆ testSize()

template<int32_t key_len, typename T >
void OmniSketch::Test::TestBase< key_len, T >::testSize ( std::unique_ptr< Sketch::SketchBase< key_len, T >> &  ptr_sketch)
finalvirtual

Get the size of the sketch.

You should override the Sketch::SketchBase::size() method.

Parameters
ptr_sketchpointer to the sketch

◆ testUpdate()

template<int32_t key_len, typename T >
void OmniSketch::Test::TestBase< key_len, T >::testUpdate ( std::unique_ptr< Sketch::SketchBase< key_len, T >> &  ptr_sketch,
typename std::vector< Data::Record< key_len >>::const_iterator  begin,
typename std::vector< Data::Record< key_len >>::const_iterator  end,
Data::CntMethod  cnt_method 
)
finalvirtual

Update a row of records (with values to the sketch)

Records in [begin, end) will be sequentially updated. You should override the Sketch::SketchBase::update() method.

Member Data Documentation

◆ config_file

template<int32_t key_len, typename T = int64_t>
const std::string_view OmniSketch::Test::TestBase< key_len, T >::config_file
protected

◆ show_name

template<int32_t key_len, typename T = int64_t>
const std::string_view OmniSketch::Test::TestBase< key_len, T >::show_name
protected

◆ test_path

template<int32_t key_len, typename T = int64_t>
const std::string_view OmniSketch::Test::TestBase< key_len, T >::test_path
protected
OmniSketch::Test::TestBase::TestBase
TestBase(const std::string_view show_name, const std::string_view config_file, const std::string_view test_path)
Construct by specifying all necessary tables in config file.
Definition: test.h:243