6
6
//
7
7
// Identification: src/index/index_factory.cpp
8
8
//
9
- // Copyright (c) 2015-16 , Carnegie Mellon University Database Group
9
+ // Copyright (c) 2015-2018 , Carnegie Mellon University Database Group
10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
13
- #include < iostream >
13
+ #include " index/index_factory.h "
14
14
15
15
#include < sstream>
16
16
17
17
#include " common/logger.h"
18
18
#include " common/macros.h"
19
+ #include " index/art_index.h"
19
20
#include " index/bwtree_index.h"
20
- #include " index/index_factory.h"
21
21
#include " index/index_key.h"
22
22
#include " index/skiplist_index.h"
23
23
@@ -37,9 +37,10 @@ Index *IndexFactory::GetIndex(IndexMetadata *metadata) {
37
37
// If so, then we can rock a specialized IntsKeyComparator
38
38
// that is faster than the FastGenericComparator
39
39
bool ints_only = true ;
40
- for (auto column : metadata->key_schema ->GetColumns ()) {
40
+ for (const auto & column : metadata->key_schema ->GetColumns ()) {
41
41
auto col_type = column.GetType ();
42
- if (col_type != type::TypeId::TINYINT && col_type != type::TypeId::SMALLINT &&
42
+ if (col_type != type::TypeId::TINYINT &&
43
+ col_type != type::TypeId::SMALLINT &&
43
44
col_type != type::TypeId::INTEGER && col_type != type::TypeId::BIGINT) {
44
45
ints_only = false ;
45
46
break ;
@@ -66,19 +67,25 @@ Index *IndexFactory::GetIndex(IndexMetadata *metadata) {
66
67
index = IndexFactory::GetBwTreeGenericKeyIndex (metadata);
67
68
}
68
69
69
- // -----------------------
70
- // SKIP-LIST
71
- // -----------------------
70
+ // -----------------------
71
+ // SKIP-LIST
72
+ // -----------------------
72
73
} else if (index_type == IndexType::SKIPLIST) {
73
74
if (ints_only) {
74
75
index = IndexFactory::GetSkipListIntsKeyIndex (metadata);
75
76
} else {
76
77
index = IndexFactory::GetSkipListGenericKeyIndex (metadata);
77
78
}
78
79
79
- // -----------------------
80
- // ERROR
81
- // -----------------------
80
+ // -----------------------
81
+ // Art
82
+ // -----------------------
83
+ } else if (index_type == IndexType::ART) {
84
+ index = new ArtIndex (metadata);
85
+
86
+ // -----------------------
87
+ // ERROR
88
+ // -----------------------
82
89
} else {
83
90
throw IndexException (" Unsupported index scheme." );
84
91
}
@@ -142,7 +149,8 @@ Index *IndexFactory::GetBwTreeIntsKeyIndex(IndexMetadata *metadata) {
142
149
#ifdef LOG_TRACE_ENABLED
143
150
LOG_TRACE (" %s" , IndexFactory::GetInfo (metadata, comparatorType).c_str ());
144
151
#endif
145
- return (index);
152
+
153
+ return index;
146
154
}
147
155
148
156
Index *IndexFactory::GetBwTreeGenericKeyIndex (IndexMetadata *metadata) {
@@ -213,7 +221,8 @@ Index *IndexFactory::GetBwTreeGenericKeyIndex(IndexMetadata *metadata) {
213
221
#ifdef LOG_TRACE_ENABLED
214
222
LOG_TRACE (" %s" , IndexFactory::GetInfo (metadata, comparatorType).c_str ());
215
223
#endif
216
- return (index);
224
+
225
+ return index;
217
226
}
218
227
219
228
Index *IndexFactory::GetSkipListIntsKeyIndex (IndexMetadata *metadata) {
@@ -271,7 +280,8 @@ Index *IndexFactory::GetSkipListIntsKeyIndex(IndexMetadata *metadata) {
271
280
#ifdef LOG_TRACE_ENABLED
272
281
LOG_TRACE (" %s" , IndexFactory::GetInfo (metadata, comparatorType).c_str ());
273
282
#endif
274
- return (index);
283
+
284
+ return index;
275
285
}
276
286
277
287
Index *IndexFactory::GetSkipListGenericKeyIndex (IndexMetadata *metadata) {
@@ -339,18 +349,19 @@ Index *IndexFactory::GetSkipListGenericKeyIndex(IndexMetadata *metadata) {
339
349
#ifdef LOG_TRACE_ENABLED
340
350
LOG_TRACE (" %s" , IndexFactory::GetInfo (metadata, comparatorType).c_str ());
341
351
#endif
342
- return (index);
352
+
353
+ return index;
343
354
}
344
355
345
356
std::string IndexFactory::GetInfo (IndexMetadata *metadata,
346
- std::string comparatorType ) {
357
+ const std::string &comparator_type ) {
347
358
std::ostringstream os;
348
359
os << " Index '" << metadata->GetName () << " ' => "
349
- << IndexTypeToString (metadata->GetIndexType ()) << " ::" << comparatorType
360
+ << IndexTypeToString (metadata->GetIndexType ()) << " ::" << comparator_type
350
361
<< " (" ;
351
362
bool first = true ;
352
363
for (auto column : metadata->key_schema ->GetColumns ()) {
353
- if (first == false ) os << " , " ;
364
+ if (! first) os << " , " ;
354
365
os << column.GetName ();
355
366
first = false ;
356
367
}
0 commit comments