souffle  2.0.2-371-g6315b36
ParallelIndexScan.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2018, 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 /************************************************************************
10  *
11  * @file ParallelIndexScan.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "AggregateOp.h"
18 #include "ram/AbstractParallel.h"
19 #include "ram/Condition.h"
20 #include "ram/Expression.h"
21 #include "ram/IndexOperation.h"
22 #include "ram/IndexScan.h"
23 #include "ram/NestedOperation.h"
24 #include "ram/Node.h"
25 #include "ram/Relation.h"
26 #include "ram/utility/NodeMapper.h"
27 #include "ram/utility/Utils.h"
31 #include <cassert>
32 #include <cstddef>
33 #include <iosfwd>
34 #include <memory>
35 #include <ostream>
36 #include <string>
37 #include <utility>
38 #include <vector>
39 
40 namespace souffle::ram {
41 
42 /**
43  * @class ParallelIndexScan
44  * @brief Search for tuples of a relation matching a criteria
45  *
46  * For example:
47  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
48  * QUERY
49  * ...
50  * PARALLEL FOR t1 IN X ON INDEX t1.c = t0.0
51  * ...
52  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
53  */
54 class ParallelIndexScan : public IndexScan, public AbstractParallel {
55 public:
56  ParallelIndexScan(std::string rel, int ident, RamPattern queryPattern, Own<Operation> nested,
57  std::string profileText = "")
58  : IndexScan(rel, ident, std::move(queryPattern), std::move(nested), profileText) {}
59 
60  ParallelIndexScan* clone() const override {
61  RamPattern resQueryPattern;
62  for (const auto& i : queryPattern.first) {
63  resQueryPattern.first.emplace_back(i->clone());
64  }
65  for (const auto& i : queryPattern.second) {
66  resQueryPattern.second.emplace_back(i->clone());
67  }
68  return new ParallelIndexScan(relation, getTupleId(), std::move(resQueryPattern),
70  }
71 
72 protected:
73  void print(std::ostream& os, int tabpos) const override {
74  os << times(" ", tabpos);
75  os << "PARALLEL FOR t" << getTupleId() << " IN " << relation;
76  printIndex(os);
77  os << std::endl;
78  IndexOperation::print(os, tabpos + 1);
79  }
80 };
81 
82 } // namespace souffle::ram
souffle::ram::NestedOperation::profileText
const std::string profileText
Text used by the profiler.
Definition: NestedOperation.h:93
souffle::ram::ParallelIndexScan
Search for tuples of a relation matching a criteria.
Definition: ParallelIndexScan.h:58
NestedOperation.h
souffle::ram::ParallelIndexScan::ParallelIndexScan
ParallelIndexScan(std::string rel, int ident, RamPattern queryPattern, Own< Operation > nested, std::string profileText="")
Definition: ParallelIndexScan.h:60
AggregateOp.h
souffle::ram::ParallelIndexScan::clone
ParallelIndexScan * clone() const override
Create a clone (i.e.
Definition: ParallelIndexScan.h:64
souffle::ram::NestedOperation::getOperation
Operation & getOperation() const
Get nested operation.
Definition: NestedOperation.h:62
MiscUtil.h
souffle::ram
Definition: AstToRamTranslator.h:54
souffle::ram::RelationOperation::relation
const std::string relation
Search relation.
Definition: RelationOperation.h:60
IndexScan.h
souffle::clone
auto clone(const std::vector< A * > &xs)
Definition: ContainerUtil.h:172
NodeMapper.h
souffle::ram::ParallelIndexScan::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: ParallelIndexScan.h:77
souffle::times
detail::multiplying_printer< T > times(const T &value, unsigned num)
A utility printing a given value multiple times.
Definition: StreamUtil.h:322
i
size_t i
Definition: json11.h:663
ContainerUtil.h
souffle::ram::NestedOperation::getProfileText
const std::string & getProfileText() const
Get profile text.
Definition: NestedOperation.h:67
Relation.h
Condition.h
souffle::ram::TupleOperation::getTupleId
int getTupleId() const
Get identifier.
Definition: TupleOperation.h:43
Utils.h
souffle::ram::IndexOperation::printIndex
void printIndex(std::ostream &os) const
Helper method for printing.
Definition: IndexOperation.h:108
souffle::ram::IndexScan
Search for tuples of a relation matching a criteria.
Definition: IndexScan.h:52
IndexOperation.h
AbstractParallel.h
Node.h
std
Definition: Brie.h:3053
souffle::ram::IndexOperation::queryPattern
RamPattern queryPattern
Values of index per column of table (if indexable)
Definition: IndexOperation.h:161
souffle::ram::RamPattern
std::pair< RamBound, RamBound > RamPattern
Definition: IndexOperation.h:42
StreamUtil.h
Expression.h
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086
souffle::ram::NestedOperation::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: NestedOperation.h:80