forked from griddb/griddb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base_index.h
116 lines (103 loc) · 3.08 KB
/
base_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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
Copyright (c) 2017 TOSHIBA Digital Solutions Corporation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
@file
@brief Definition of Index base class
*/
#ifndef BASE_INDEX_H_
#define BASE_INDEX_H_
#include "util/trace.h"
#include "data_type.h"
#include "gs_error.h"
#include "object_manager.h"
#include "transaction_context.h"
#include "value.h"
#include <iomanip>
#include <iostream>
class TransactionContext;
class BaseContainer;
/*!
@brief Index base class
*/
class BaseIndex : public BaseObject {
public:
BaseIndex(TransactionContext &txn, ObjectManager &objectManager,
const AllocateStrategy &strategy, BaseContainer *container,
MapType mapType)
: BaseObject(txn.getPartitionId(), objectManager),
allocateStrategy_(strategy),
container_(container),
mapType_(mapType) {}
BaseIndex(TransactionContext &txn, ObjectManager &objectManager, OId oId,
const AllocateStrategy &strategy, BaseContainer *container,
MapType mapType)
: BaseObject(txn.getPartitionId(), objectManager, oId),
allocateStrategy_(strategy),
container_(container),
mapType_(mapType) {}
virtual bool finalize(TransactionContext &txn) = 0;
virtual int32_t insert(
TransactionContext &txn, const void *key, OId oId) = 0;
virtual int32_t remove(
TransactionContext &txn, const void *key, OId oId) = 0;
virtual int32_t update(
TransactionContext &txn, const void *key, OId oId, OId newOId) = 0;
MapType getMapType() {return mapType_;}
static const uint64_t NUM_PER_EXEC = 50;
public:
struct SearchContext {
enum NullCondition {
IS_NULL,
ALL,
NOT_IS_NULL
};
enum ResumeStatus {
NOT_RESUME,
NULL_RESUME,
NOT_NULL_RESUME
};
ColumnId columnId_;
uint32_t conditionNum_;
TermCondition *conditionList_;
ResultSize limit_;
NullCondition nullCond_;
SearchContext()
: columnId_(0),
conditionNum_(0),
conditionList_(NULL),
limit_(MAX_RESULT_SIZE)
,
nullCond_(NOT_IS_NULL)
{
}
SearchContext(ColumnId columnId, uint32_t conditionNum,
TermCondition *conditionList, ResultSize limit)
: columnId_(columnId),
conditionNum_(conditionNum),
conditionList_(conditionList),
limit_(limit)
,
nullCond_(NOT_IS_NULL)
{
}
};
protected:
AllocateStrategy allocateStrategy_;
BaseContainer *container_;
MapType mapType_;
};
typedef BaseIndex::SearchContext::ResumeStatus ResumeStatus;
typedef BaseIndex::SearchContext::NullCondition NullCondition;
typedef BaseIndex::SearchContext BaseSearchContext;
#endif