21788d003a
Summary: Dressipi CRUD queries are dummy implemented; Fixes T99 and T131 Test Plan: manual Reviewers: sale Subscribers: buda, sale Maniphest Tasks: T131, T99 Differential Revision: https://memgraph.phacility.com/D9
85 lines
2.4 KiB
C++
85 lines
2.4 KiB
C++
|
|
#pragma once
|
|
|
|
#include <atomic>
|
|
#include <functional>
|
|
#include <memory>
|
|
#include "mvcc/id.hpp"
|
|
|
|
// #include "storage/indexes/index_record.hpp"
|
|
#include "logging/loggable.hpp"
|
|
#include "storage/garbage/delete_sensitive.hpp"
|
|
#include "storage/indexes/index_definition.hpp"
|
|
#include "utils/border.hpp"
|
|
#include "utils/iterator/virtual_iter.hpp"
|
|
|
|
template <class TG, class K>
|
|
class IndexRecord;
|
|
|
|
class DbTransaction;
|
|
class DbAccessor;
|
|
namespace tx
|
|
{
|
|
class Transaction;
|
|
}
|
|
|
|
// Interface for all indexes.
|
|
// TG type group
|
|
// K type of key on which records are ordered
|
|
template <class TG, class K>
|
|
class IndexBase : public DeleteSensitive, public Loggable
|
|
{
|
|
public:
|
|
// Created with the database
|
|
IndexBase(IndexDefinition &&it, std::string &&logger_name = "IndexBase");
|
|
|
|
IndexBase(IndexDefinition &&it, const tx::Transaction &t,
|
|
std::string &&logger_name = "IndexBase");
|
|
|
|
virtual ~IndexBase(){};
|
|
|
|
// Insert's value.
|
|
// unique => returns false if there is already valid equal value.
|
|
// nonunique => always succeds.
|
|
virtual bool insert(IndexRecord<TG, K> &&value) = 0;
|
|
|
|
// Returns iterator which returns valid filled records in range.
|
|
// order==noe => doesn't guarantee any order of returned records.
|
|
// order==Ascending => guarantees order of returnd records will be from
|
|
// smallest to largest.
|
|
// order==Descending => guarantees order of returned records will be from
|
|
// largest to smallest.
|
|
// Range must be from<=to
|
|
virtual iter::Virtual<const typename TG::accessor_t>
|
|
for_range(DbAccessor &, Border<K> from = Border<K>(),
|
|
Border<K> to = Border<K>()) = 0;
|
|
|
|
// Removes for all transactions obsolete Records.
|
|
// Cleaner has to call this method when he decideds that it is time for
|
|
// cleaning. Id must be id of oldest active transaction.
|
|
virtual void clean(const Id &id) = 0;
|
|
|
|
// Activates index for readers.
|
|
void activate();
|
|
|
|
// True if index is ready for reading.
|
|
bool can_read();
|
|
|
|
// True if transaction is obliged to insert T into index.
|
|
bool is_obliged_to_insert(const tx::Transaction &t);
|
|
|
|
IndexType type() const { return it.type; }
|
|
|
|
const IndexDefinition &definition() const { return it; }
|
|
|
|
protected:
|
|
Logger logger;
|
|
|
|
private:
|
|
const IndexDefinition it;
|
|
// Id of transaction which created this index.
|
|
const Id created;
|
|
// Active state
|
|
std::atomic_bool active = {false};
|
|
};
|