This repository has been archived by the owner on Sep 27, 2019. It is now read-only.
/
skiplist_index.h
100 lines (75 loc) · 2.82 KB
/
skiplist_index.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//===----------------------------------------------------------------------===//
//
// Peloton
//
// skiplist_index.h
//
// Identification: src/index/skiplist_index.h
//
// Copyright (c) 2015-17, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#pragma once
#include <vector>
#include <string>
#include <map>
#include "catalog/manager.h"
#include "common/platform.h"
#include "common/internal_types.h"
#include "index/index.h"
#include "index/skiplist.h"
#define SKIPLIST_INDEX_TYPE \
SkipListIndex<KeyType, ValueType, KeyComparator, KeyEqualityChecker, \
ValueEqualityChecker>
namespace peloton {
namespace index {
/**
* Skiplist-based index implementation.
*
* @see Index
*/
template <typename KeyType, typename ValueType, typename KeyComparator,
typename KeyEqualityChecker, typename ValueEqualityChecker>
class SkipListIndex : public Index {
friend class IndexFactory;
// typedef SkipList<KeyType, ValueType, KeyComparator, KeyEqualityChecker,
// ValueEqualityChecker> MapType;
using MapType = SkipList<KeyType, ValueType, KeyComparator,
KeyEqualityChecker, ValueEqualityChecker>;
public:
SkipListIndex(IndexMetadata *metadata);
~SkipListIndex();
bool InsertEntry(const storage::Tuple *key, ItemPointer *value);
bool DeleteEntry(const storage::Tuple *key, ItemPointer *value);
bool CondInsertEntry(const storage::Tuple *key, ItemPointer *value,
std::function<bool(const void *)> predicate);
void Scan(const std::vector<type::Value> &values,
const std::vector<oid_t> &key_column_ids,
const std::vector<ExpressionType> &expr_types,
ScanDirectionType scan_direction, std::vector<ValueType> &result,
const ConjunctionScanPredicate *csp_p);
void ScanLimit(const std::vector<type::Value> &values,
const std::vector<oid_t> &key_column_ids,
const std::vector<ExpressionType> &expr_types,
ScanDirectionType scan_direction,
std::vector<ValueType> &result,
const ConjunctionScanPredicate *csp_p, uint64_t limit,
uint64_t offset);
void ScanAllKeys(std::vector<ValueType> &result);
void ScanKey(const storage::Tuple *key, std::vector<ValueType> &result);
std::string GetTypeName() const;
// TODO: Implement this
size_t GetMemoryFootprint() { return 0; }
// TODO: Implement this
bool NeedGC() { return false; }
// TODO: Implement this
void PerformGC() { return; }
protected:
// equality checker and comparator
KeyComparator comparator;
KeyEqualityChecker equals;
// container
MapType container;
};
} // namespace index
} // namespace peloton