2016-08-18 22:34:36 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "storage/indexes/index_base.hpp"
|
2016-08-25 22:29:45 +08:00
|
|
|
// #include "storage/indexes/index_record.hpp"
|
2016-08-18 22:34:36 +08:00
|
|
|
|
|
|
|
#include "data_structures/concurrent/concurrent_list.hpp"
|
|
|
|
|
2016-08-25 22:29:45 +08:00
|
|
|
template <class TG, class K>
|
|
|
|
class NonUniqueUnorderedIndex : public IndexBase<TG, K>
|
2016-08-18 22:34:36 +08:00
|
|
|
{
|
|
|
|
public:
|
2016-09-13 03:13:04 +08:00
|
|
|
using store_t = ConcurrentList<IndexRecord<TG, K>>;
|
2016-08-25 22:29:45 +08:00
|
|
|
// typedef T value_type;
|
|
|
|
// typedef K key_type;
|
2016-08-18 22:34:36 +08:00
|
|
|
|
2016-08-25 22:29:45 +08:00
|
|
|
// Created with the database
|
2016-09-08 20:25:52 +08:00
|
|
|
NonUniqueUnorderedIndex(IndexLocation &&loc);
|
2016-08-18 22:34:36 +08:00
|
|
|
|
2016-09-08 20:25:52 +08:00
|
|
|
NonUniqueUnorderedIndex(IndexLocation &&loc, tx::Transaction const &t);
|
2016-08-25 22:29:45 +08:00
|
|
|
|
2016-08-18 22:34:36 +08:00
|
|
|
// Insert's value.
|
|
|
|
// nonunique => always succeds.
|
2016-08-25 22:29:45 +08:00
|
|
|
bool insert(IndexRecord<TG, K> &&value) final;
|
2016-08-18 22:34:36 +08:00
|
|
|
|
|
|
|
// Returns iterator which returns valid records in range.
|
|
|
|
// ordered==None => doesn't guarantee any order of submitting records.
|
2016-08-31 01:13:23 +08:00
|
|
|
iter::Virtual<const typename TG::accessor_t>
|
2016-08-18 22:34:36 +08:00
|
|
|
for_range(DbAccessor &t, Border<K> from = Border<K>(),
|
|
|
|
Border<K> to = Border<K>()) final;
|
|
|
|
|
|
|
|
// Same as for_range just whit known returned iterator.
|
|
|
|
auto for_range_exact(DbAccessor &t, Border<K> from = Border<K>(),
|
|
|
|
Border<K> to = Border<K>());
|
|
|
|
|
|
|
|
// Removes for all transactions obsolete Records.
|
|
|
|
// Cleaner has to call this method when he decideds that it is time for
|
2016-08-30 07:45:07 +08:00
|
|
|
// cleaning. Id must be id of oldest active transaction.
|
|
|
|
void clean(const Id &id) final;
|
2016-08-18 22:34:36 +08:00
|
|
|
|
|
|
|
private:
|
2016-08-30 07:45:07 +08:00
|
|
|
store_t list;
|
2016-08-18 22:34:36 +08:00
|
|
|
};
|