souffle
2.0.2-371-g6315b36
|
Go to the documentation of this file.
56 res.order.resize(arity);
57 for (
size_t i = 0;
i < arity;
i++) {
73 if (i < 0 || i >=
int(
order.size())) {
78 for (
size_t i = 0;
i <
order.size();
i++) {
79 for (
size_t j =
i + 1;
j <
order.size();
j++) {
91 template <
size_t Arity>
92 Tuple<RamDomain, Arity>
encode(
const Tuple<RamDomain, Arity>& entry)
const {
93 Tuple<RamDomain, Arity> res{};
94 for (
size_t i = 0;
i < Arity; ++
i) {
103 template <
size_t Arity>
106 for (
size_t i = 0;
i < Arity; ++
i) {
117 return order == other.order;
121 return !(*
this == other);
131 inline std::ostream&
operator<<(std::ostream& out,
const Order& order) {
132 return out <<
"[" <<
join(order.order) <<
"]";
145 template <
size_t _Arity,
template <
size_t>
typename Structure>
148 static constexpr
size_t Arity = _Arity;
149 using Data = Structure<Arity>;
151 using iterator =
typename Data::iterator;
152 using Hints =
typename Data::operation_hints;
194 return View(this->data);
222 size_t size()
const {
237 for (
const auto&
tuple : src) {
273 std::vector<souffle::range<iterator>>
partitionScan(
int partitionCount)
const {
274 auto chunks =
data.partition(partitionCount);
275 std::vector<souffle::range<iterator>> res;
276 res.reserve(chunks.size());
277 for (
const auto& cur : chunks) {
278 res.push_back({cur.begin(), cur.end()});
289 auto chunks = ranges.partition(partitionCount);
290 std::vector<souffle::range<iterator>> res;
291 res.reserve(chunks.size());
292 for (
const auto& cur : chunks) {
293 res.push_back({cur.begin(), cur.end()});
310 template <
template <
size_t>
typename Structure>
311 class Index<0, Structure> {
313 static constexpr
size_t Arity = 0;
318 std::atomic<bool>
data{
false};
324 class iterator :
public std::iterator<std::forward_iterator_tag, Tuple> {
329 iterator(
bool v =
false) : value(v) {}
336 return other.value == value;
339 bool operator!=(
const iterator& other)
const {
340 return other.value != value;
380 return View(this->data);
391 size_t size()
const {
412 return {this->
begin(), this->
end()};
416 return {this->
begin(), this->
end()};
419 std::vector<souffle::range<iterator>>
partitionScan(
int )
const {
420 std::vector<souffle::range<iterator>> res;
const AttributeOrder & getOrder() const
typename souffle::Tuple< RamDomain, 0 > Tuple
static Order create(size_t arity)
bool operator==(const Order &other) const
bool operator!=(const Order &other) const
A utility class enabling representation of ranges by pairing two iterator instances marking lower and...
virtual ~ViewWrapper()=default
bool valid() const
Determines whether this order is a valid order.
For EqrelIndex we do inheritence since EqrelIndex only diff with one extra function.
souffle::range< iterator > range(const Tuple &low, const Tuple &high)
Obtains a pair of iterators representing the given range within this index.
bool empty() const
Tests whether this index is empty or not.
std::ostream & operator<<(std::ostream &out, const Order &order)
bool contains(const Tuple &tuple) const
Tests whether the given tuple is present in this index or not.
static constexpr size_t Arity
An order to be enforced for storing tuples within indexes.
A dummy wrapper for indexViews.
void extend(const EquivalenceRelation< TupleType > &other)
Extend this relation with another relation, expanding this equivalence relation The supplied relation...
Attribute operator[](const size_t idx) const
souffle::range< iterator > scan() const
Returns a pair of iterators covering the entire index content.
An index is an abstraction of a data structure.
std::vector< Attribute > AttributeOrder
typename Data::operation_hints Hints
friend std::ostream & operator<<(std::ostream &out, const Order &order)
detail::joined_sequence< Iter, Printer > join(const Iter &a, const Iter &b, const std::string &sep, const Printer &p)
Creates an object to be forwarded to some output stream for printing sequences of elements interspers...
void clear()
Clears the content of this index, turning it empty.
typename souffle::Tuple< RamDomain, Arity > Tuple
const std::atomic< bool > & data
Tuple< RamDomain, Arity > decode(const Tuple< RamDomain, Arity > &entry) const
Decode the tuple by order.
bool insert(const Tuple &tuple)
Inserts a tuple into this index.
typename Data::iterator iterator
void extend(EqrelIndex *otherIndex)
Extend another index.
size_t size() const
Obtains the number of elements stored in this index.
Order getOrder() const
Obtains the lex order of this index.
View createView()
Requests the creation of a view on this index.
A view on a relation caching local access patterns (not thread safe!).
std::vector< souffle::range< iterator > > partitionScan(int partitionCount) const
Retruns a partitioned list of iterators for parallel computation.
souffle::range< iterator > range(const Tuple &low, const Tuple &high) const
Returns a pair of iterators covering elements in the range [low,high)
std::vector< souffle::range< iterator > > partitionRange(const Tuple &low, const Tuple &high, int partitionCount) const
Returns a partitioned list of iterators coving elements in range [low, high].
Defines a tuple for the OO interface such that relations with varying columns can be accessed.
bool contains(const Tuple &entry)
Tests whether the given entry is contained in this index.
Tuple< RamDomain, Arity > encode(const Tuple< RamDomain, Arity > &entry) const
Encode the tuple with order.