Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit c28873c

Browse files
authored
Merge pull request #1215 from GustavoAngulo/master
Add access methods to optimizer tests
2 parents fd2cf84 + 1586efd commit c28873c

21 files changed

+667
-624
lines changed

src/include/optimizer/memo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Memo {
5454
GroupExpression* InsertExpression(std::shared_ptr<GroupExpression> gexpr,
5555
GroupID target_group, bool enforced);
5656

57-
const std::vector<std::unique_ptr<Group>>& Groups() const;
57+
std::vector<std::unique_ptr<Group>>& Groups();
5858

5959
Group* GetGroupByID(GroupID id);
6060

src/include/optimizer/optimizer.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// Identification: src/include/optimizer/optimizer.h
88
//
9-
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
9+
// Copyright (c) 2015-2018, Carnegie Mellon University Database Group
1010
//
1111
//===----------------------------------------------------------------------===//
1212

@@ -81,6 +81,19 @@ class Optimizer : public AbstractOptimizer {
8181

8282
void Reset() override;
8383

84+
OptimizerMetadata &GetMetadata() { return metadata_; }
85+
86+
/* For test purposes only */
87+
std::shared_ptr<GroupExpression> TestInsertQueryTree(parser::SQLStatement *tree,
88+
concurrency::TransactionContext *txn) {
89+
return InsertQueryTree(tree, txn);
90+
}
91+
/* For test purposes only */
92+
void TestExecuteTaskStack(OptimizerTaskStack &task_stack, int root_group_id,
93+
std::shared_ptr<OptimizeContext> root_context) {
94+
return ExecuteTaskStack(task_stack, root_group_id, root_context);
95+
}
96+
8497
private:
8598
/* HandleDDLStatement - Check and handle DDL statment (currently only support
8699
*CREATE), set

src/include/optimizer/rule.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// Identification: src/include/optimizer/rule.h
88
//
9-
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
9+
// Copyright (c) 2015-2018, Carnegie Mellon University Database Group
1010
//
1111
//===----------------------------------------------------------------------===//
1212

@@ -146,6 +146,10 @@ class RuleSet {
146146
return rewrite_rules_map_[static_cast<uint32_t>(set)];
147147
}
148148

149+
std::unordered_map<uint32_t, std::vector<std::unique_ptr<Rule>>> &GetRewriteRulesMap() { return rewrite_rules_map_; }
150+
151+
std::vector<std::unique_ptr<Rule>> &GetPredicatePushDownRules() { return predicate_push_down_rules_; }
152+
149153
private:
150154
std::vector<std::unique_ptr<Rule>> transformation_rules_;
151155
std::vector<std::unique_ptr<Rule>> implementation_rules_;

src/optimizer/memo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ GroupExpression *Memo::InsertExpression(std::shared_ptr<GroupExpression> gexpr,
6363
}
6464
}
6565

66-
const std::vector<std::unique_ptr<Group>> &Memo::Groups() const {
66+
std::vector<std::unique_ptr<Group>> &Memo::Groups() {
6767
return groups_;
6868
}
6969

test/optimizer/column_stats_collector_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// Identification: test/optimizer/column_stats_collector_test.cpp
88
//
9-
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
9+
// Copyright (c) 2015-2018, Carnegie Mellon University Database Group
1010
//
1111
//===----------------------------------------------------------------------===//
1212

@@ -20,7 +20,6 @@
2020
#include "type/value.h"
2121
#include "type/value_factory.h"
2222

23-
#define private public
2423
#define TEST_OID 0
2524

2625
namespace peloton {

test/optimizer/cost_test.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
//
77
// Identification: test/optimizer/cost_test.cpp
88
//
9-
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
9+
// Copyright (c) 2015-2018, Carnegie Mellon University Database Group
1010
//
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "common/harness.h"
1414

15-
#define private public
16-
1715
#include <iostream>
1816
#include <sstream>
1917
#include <string>

test/optimizer/count_min_sketch_test.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
//
77
// Identification: test/optimizer/count_min_sketch_test.cpp
88
//
9-
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
9+
// Copyright (c) 2015-2018, Carnegie Mellon University Database Group
1010
//
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "common/harness.h"
1414

15-
#define private public
16-
1715
#include "optimizer/stats/count_min_sketch.h"
1816
#include "common/logger.h"
1917
#include "common/statement.h"

test/optimizer/histogram_test.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
//
77
// Identification: test/optimizer/histogram_test.cpp
88
//
9-
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
9+
// Copyright (c) 2015-2018, Carnegie Mellon University Database Group
1010
//
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "common/harness.h"
1414

15-
#define private public
16-
1715
#include <random>
1816

1917
#include "optimizer/stats/histogram.h"

test/optimizer/hyperloglog_test.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
//
77
// Identification: test/optimizer/hyperloglog_test.cpp
88
//
9-
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
9+
// Copyright (c) 2015-2018, Carnegie Mellon University Database Group
1010
//
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "common/harness.h"
1414

15-
#define private public
16-
1715
#include "optimizer/stats/hyperloglog.h"
1816

1917
#include "common/logger.h"

test/optimizer/old_optimizer_test.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
#include "common/harness.h"
2-
3-
#define private public
4-
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Peloton
4+
//
5+
// old_optimizer_test.cpp
6+
//
7+
// Identification: test/optimizer/old_optimizer_test.cpp
8+
//
9+
// Copyright (c) 2015-2018, Carnegie Mellon University Database Group
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include <common/harness.h>
514
#include "catalog/catalog.h"
615
#include "common/statement.h"
716
#include "concurrency/transaction_manager_factory.h"

0 commit comments

Comments
 (0)