souffle  2.0.2-371-g6315b36
Table.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2016, The Souffle Developers. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 #pragma once
10 
12 #include "souffle/profile/Row.h"
13 #include <algorithm>
14 #include <memory>
15 #include <vector>
16 
17 namespace souffle {
18 namespace profile {
19 
20 /*
21  * Table class for holding a vector of rows
22  * And sorting the rows based on a datacomparator function
23  */
24 class Table {
25 public:
26  std::vector<std::shared_ptr<Row>> rows;
27 
28  Table() : rows() {}
29 
30  void addRow(std::shared_ptr<Row> row) {
31  rows.push_back(row);
32  }
33 
34  inline std::vector<std::shared_ptr<Row>> getRows() {
35  return rows;
36  }
37 
38  void sort(int col_num) {
39  switch (col_num) {
40  case 1: std::sort(rows.begin(), rows.end(), DataComparator::NR_T); break;
41  case 2: std::sort(rows.begin(), rows.end(), DataComparator::R_T); break;
42  case 3: std::sort(rows.begin(), rows.end(), DataComparator::C_T); break;
43  case 4: std::sort(rows.begin(), rows.end(), DataComparator::TUP); break;
44  case 5: std::sort(rows.begin(), rows.end(), DataComparator::ID); break;
45  case 6: std::sort(rows.begin(), rows.end(), DataComparator::NAME); break;
46  case 0:
47  default: // if the col_num isn't defined use TIME
48  std::sort(rows.begin(), rows.end(), DataComparator::TIME);
49  break;
50  }
51  }
52 };
53 
54 } // namespace profile
55 } // namespace souffle
souffle::profile::Table::addRow
void addRow(std::shared_ptr< Row > row)
Definition: Table.h:30
souffle::profile::DataComparator::TIME
static bool TIME(const std::shared_ptr< Row > &a, const std::shared_ptr< Row > &b)
Sort by total time.
Definition: DataComparator.h:30
souffle::profile::Table::rows
std::vector< std::shared_ptr< Row > > rows
Definition: Table.h:26
souffle::profile::Table::sort
void sort(int col_num)
Definition: Table.h:38
souffle::profile::Table::Table
Table()
Definition: Table.h:28
souffle::profile::DataComparator::R_T
static bool R_T(const std::shared_ptr< Row > &a, const std::shared_ptr< Row > &b)
Sort by recursive time.
Definition: DataComparator.h:40
souffle::profile::DataComparator::NR_T
static bool NR_T(const std::shared_ptr< Row > &a, const std::shared_ptr< Row > &b)
Sort by non-recursive time.
Definition: DataComparator.h:35
souffle::profile::DataComparator::ID
static bool ID(const std::shared_ptr< Row > &a, const std::shared_ptr< Row > &b)
Sort by ID.
Definition: DataComparator.h:60
souffle::profile::DataComparator::C_T
static bool C_T(const std::shared_ptr< Row > &a, const std::shared_ptr< Row > &b)
Sort by copy time.
Definition: DataComparator.h:45
DataComparator.h
souffle
Definition: AggregateOp.h:25
Row.h
souffle::profile::DataComparator::NAME
static bool NAME(const std::shared_ptr< Row > &a, const std::shared_ptr< Row > &b)
Sort by name.
Definition: DataComparator.h:55
souffle::profile::DataComparator::TUP
static bool TUP(const std::shared_ptr< Row > &a, const std::shared_ptr< Row > &b)
Sort by tuple count.
Definition: DataComparator.h:50
souffle::profile::Table::getRows
std::vector< std::shared_ptr< Row > > getRows()
Definition: Table.h:34
souffle::profile::Table
Definition: Table.h:24