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

Commit e5360ae

Browse files
authored
Merge branch 'master' into join_order_fix
2 parents 0c33249 + 5b16e38 commit e5360ae

14 files changed

+625
-85
lines changed

src/brain/kd_tree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void KDTree::Update(UNUSED_ATTRIBUTE Cluster *cluster) {
3434
// to the structure. Will need to change AnnoyIndex to optimize this
3535
// The update to the centroid is reflected in the cluster. There is no change
3636
// to the clusters_, so just rebuild the entire index
37-
index_.reinitialize();
37+
index_.unload();
3838
Build();
3939
}
4040

@@ -64,7 +64,7 @@ void KDTree::Build() {
6464
}
6565

6666
void KDTree::Build(std::set<Cluster *> &clusters) {
67-
index_.reinitialize();
67+
index_.unload();
6868
clusters_.clear();
6969
for (auto &cluster : clusters) {
7070
clusters_.push_back(cluster);

src/brain/modelgen/LSTM.pb

229 KB
Binary file not shown.

src/brain/tf_session_entity/tf_session_entity.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ TFSE_TYPE::TfSessionEntity() {
3131

3232
TFSE_TEMPLATE_ARGUMENTS
3333
TFSE_TYPE::~TfSessionEntity() {
34-
TF_DeleteStatus(status_);
34+
TF_CloseSession(session_, status_);
35+
TF_DeleteSession(session_, status_);
3536
TF_DeleteGraph(graph_);
37+
TF_DeleteStatus(status_);
38+
TF_DeleteSessionOptions(session_options_);
3639
}
3740

3841
/*

src/concurrency/timestamp_ordering_transaction_manager.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,13 @@
2525
namespace peloton {
2626
namespace concurrency {
2727

28-
// timestamp ordering requires a spinlock field for protecting the atomic access
29-
// to txn_id field and last_reader_cid field.
3028
common::synchronization::SpinLatch *TimestampOrderingTransactionManager::GetSpinLatchField(
3129
const storage::TileGroupHeader *const tile_group_header,
3230
const oid_t &tuple_id) {
3331
return (common::synchronization::SpinLatch *)
3432
(tile_group_header->GetReservedFieldRef(tuple_id) + LOCK_OFFSET);
3533
}
3634

37-
// in timestamp ordering, the last_reader_cid records the timestamp of the last
38-
// transaction
39-
// that reads the tuple.
4035
cid_t TimestampOrderingTransactionManager::GetLastReaderCommitId(
4136
const storage::TileGroupHeader *const tile_group_header,
4237
const oid_t &tuple_id) {
@@ -73,7 +68,6 @@ bool TimestampOrderingTransactionManager::SetLastReaderCommitId(
7368
}
7469
}
7570

76-
// Initiate reserved area of a tuple
7771
void TimestampOrderingTransactionManager::InitTupleReserved(
7872
const storage::TileGroupHeader *const tile_group_header,
7973
const oid_t tuple_id) {
@@ -94,7 +88,6 @@ TimestampOrderingTransactionManager::GetInstance(
9488
return txn_manager;
9589
}
9690

97-
// check whether the current transaction owns the tuple version.
9891
bool TimestampOrderingTransactionManager::IsOwner(
9992
TransactionContext *const current_txn,
10093
const storage::TileGroupHeader *const tile_group_header,
@@ -104,7 +97,6 @@ bool TimestampOrderingTransactionManager::IsOwner(
10497
return tuple_txn_id == current_txn->GetTransactionId();
10598
}
10699

107-
// check whether any other transaction owns the tuple version.
108100
bool TimestampOrderingTransactionManager::IsOwned(
109101
TransactionContext *const current_txn,
110102
const storage::TileGroupHeader *const tile_group_header,
@@ -115,19 +107,6 @@ bool TimestampOrderingTransactionManager::IsOwned(
115107
tuple_txn_id != INITIAL_TXN_ID;
116108
}
117109

118-
// This method tests whether the current transaction has
119-
// created this version of the tuple
120-
//
121-
// this method is designed for select_for_update.
122-
//
123-
// The DBMS can acquire write locks for a transaction in two cases:
124-
// (1) Every time a transaction updates a tuple, the DBMS creates
125-
// a new version of the tuple and acquire the locks on both
126-
// the older and the newer version;
127-
// (2) Every time a transaction executes a select_for_update statement,
128-
// the DBMS needs to acquire the lock on the corresponding version
129-
// without creating a new version.
130-
// IsWritten() method is designed for distinguishing these two cases.
131110
bool TimestampOrderingTransactionManager::IsWritten(
132111
UNUSED_ATTRIBUTE TransactionContext *const current_txn,
133112
const storage::TileGroupHeader *const tile_group_header,
@@ -137,9 +116,6 @@ bool TimestampOrderingTransactionManager::IsWritten(
137116
return tuple_begin_cid == MAX_CID;
138117
}
139118

140-
// if the tuple is not owned by any transaction and is visible to current
141-
// transaction.
142-
// the version must be the latest version in the version chain.
143119
bool TimestampOrderingTransactionManager::IsOwnable(
144120
UNUSED_ATTRIBUTE TransactionContext *const current_txn,
145121
const storage::TileGroupHeader *const tile_group_header,
@@ -183,12 +159,6 @@ bool TimestampOrderingTransactionManager::AcquireOwnership(
183159
}
184160
}
185161

186-
// release write lock on a tuple.
187-
// one example usage of this method is when a tuple is acquired, but operation
188-
// (insert,update,delete) can't proceed, the executor needs to yield the
189-
// ownership before return false to upper layer.
190-
// It should not be called if the tuple is in the write set as commit and abort
191-
// will release the write lock anyway.
192162
void TimestampOrderingTransactionManager::YieldOwnership(
193163
UNUSED_ATTRIBUTE TransactionContext *const current_txn,
194164
const storage::TileGroupHeader *const tile_group_header,
@@ -582,7 +552,6 @@ void TimestampOrderingTransactionManager::PerformUpdate(
582552
}
583553
}
584554

585-
// NOTE: this function is deprecated.
586555
void TimestampOrderingTransactionManager::PerformUpdate(
587556
TransactionContext *const current_txn UNUSED_ATTRIBUTE,
588557
const ItemPointer &location) {

src/include/brain/kd_tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class KDTree {
5151
*
5252
* @param feature - the vector whose nearest neigbor is being searched for
5353
* @param cluster - return the cluster of the nearest neighbor in this
54-
* @param feature - return the similarity to the nearest neighbor in this
54+
* @param similarity - return the similarity to the nearest neighbor in this
5555
*/
5656
void GetNN(std::vector<double> &feature, Cluster *&cluster,
5757
double &similarity);

src/include/concurrency/decentralized_epoch_manager.h

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
namespace peloton {
2929
namespace concurrency {
3030

31+
/**
32+
* @brief Class for decentralized epoch manager.
33+
*/
3134
class DecentralizedEpochManager : public EpochManager {
3235
DecentralizedEpochManager(const DecentralizedEpochManager&) = delete;
3336

@@ -41,6 +44,11 @@ class DecentralizedEpochManager : public EpochManager {
4144
RegisterThread(0);
4245
}
4346

47+
/**
48+
* @brief Gets the instance.
49+
*
50+
* @return The instance.
51+
*/
4452
static DecentralizedEpochManager &GetInstance() {
4553
static DecentralizedEpochManager epoch_manager;
4654
return epoch_manager;
@@ -50,6 +58,12 @@ class DecentralizedEpochManager : public EpochManager {
5058
Reset(1);
5159
}
5260

61+
/**
62+
* @brief Reset the current global epoch id to the current epoch
63+
* identifier
64+
*
65+
* @param[in] current_epoch_id The current epoch identifier
66+
*/
5367
virtual void Reset(const uint64_t current_epoch_id) override {
5468
// epoch should be always larger than 0
5569
PL_ASSERT(current_epoch_id != 0);
@@ -61,23 +75,39 @@ class DecentralizedEpochManager : public EpochManager {
6175
RegisterThread(0);
6276
}
6377

78+
/**
79+
* @brief Sets the current epoch identifier.
80+
*
81+
* @param[in] current_epoch_id The current epoch identifier
82+
*/
6483
virtual void SetCurrentEpochId(const uint64_t current_epoch_id) override {
6584
current_global_epoch_id_ = current_epoch_id;
6685
next_txn_id_ = 0;
6786
}
6887

88+
/**
89+
* @brief Starts an epoch.
90+
*
91+
* @param epoch_thread The epoch thread
92+
*/
6993
virtual void StartEpoch(std::unique_ptr<std::thread> &epoch_thread) override {
7094
LOG_TRACE("Starting epoch");
7195
this->is_running_ = true;
7296
epoch_thread.reset(new std::thread(&DecentralizedEpochManager::Running, this));
7397
}
7498

99+
/**
100+
* @brief Starts an epoch.
101+
*/
75102
virtual void StartEpoch() override {
76103
LOG_TRACE("Starting epoch");
77104
this->is_running_ = true;
78105
thread_pool.SubmitDedicatedTask(&DecentralizedEpochManager::Running, this);
79106
}
80107

108+
/**
109+
* @brief Stops an epoch.
110+
*/
81111
virtual void StopEpoch() override {
82112
LOG_TRACE("Stopping epoch");
83113
this->is_running_ = false;
@@ -99,31 +129,68 @@ class DecentralizedEpochManager : public EpochManager {
99129
local_epoch_lock_.Unlock();
100130
}
101131

102-
// a transaction enters epoch with thread id
132+
/**
133+
* @brief A transaction enters epoch with thread id
134+
*
135+
* @param[in] thread_id The thread identifier
136+
* @param[in] ts_type The ts type
137+
*
138+
* @return The expired epoch identifier.
139+
*/
103140
virtual cid_t EnterEpoch(const size_t thread_id, const TimestampType ts_type) override;
104141

105-
// a transaction exits epoch with thread id
142+
/**
143+
* @brief A transaction exits epoch with thread id
144+
*
145+
* @param[in] thread_id The thread identifier
146+
* @param[in] epoch_id The epoch identifier
147+
*/
106148
virtual void ExitEpoch(const size_t thread_id, const eid_t epoch_id) override;
107149

108150

151+
/**
152+
* @brief Gets the expired cid.
153+
*
154+
* @return The expired cid.
155+
*/
109156
virtual cid_t GetExpiredCid() override {
110157
uint64_t max_committed_eid = GetExpiredEpochId();
111158
return (max_committed_eid << 32) | 0xFFFFFFFF;
112159
}
113160

161+
/**
162+
* @brief Gets the expired epoch identifier.
163+
*
164+
* @return The expired epoch identifier.
165+
*/
114166
virtual eid_t GetExpiredEpochId() override;
115167

168+
/**
169+
* @brief Gets the next epoch identifier.
170+
*
171+
* @return The next epoch identifier.
172+
*/
116173
virtual eid_t GetNextEpochId() override {
117174
return current_global_epoch_id_ + 1;
118175
}
119176

177+
/**
178+
* @brief Gets the current epoch identifier.
179+
*
180+
* @return The current epoch identifier.
181+
*/
120182
virtual eid_t GetCurrentEpochId() override {
121183
return current_global_epoch_id_.load();
122184
}
123185

124186
private:
125187

126188

189+
/**
190+
* @brief Gets the next transaction identifier.
191+
*
192+
* @return The next transaction identifier.
193+
*/
127194
inline uint32_t GetNextTransactionId() {
128195
return next_txn_id_.fetch_add(1, std::memory_order_relaxed);
129196
}
@@ -142,17 +209,21 @@ class DecentralizedEpochManager : public EpochManager {
142209

143210
private:
144211

145-
// each thread holds a pointer to a local epoch.
146-
// it updates the local epoch to report their local time.
212+
/**
213+
* Each thread holds a pointer to a local epoch.
214+
* It updates the local epoch to report their local time.
215+
*/
147216
common::synchronization::SpinLatch local_epoch_lock_;
148217
std::unordered_map<int, std::unique_ptr<LocalEpoch>> local_epochs_;
149218

150-
// the global epoch reflects the true time of the system.
219+
/** The global epoch reflects the true time of the system. */
151220
std::atomic<eid_t> current_global_epoch_id_;
152221
std::atomic<uint32_t> next_txn_id_;
153222

154-
// snapshot epoch is an epoch where the corresponding tuples may be still
155-
// visible to on-the-fly transactions
223+
/**
224+
* Snapshot epoch is an epoch where the corresponding tuples may be still
225+
* visible to on-the-fly transactions
226+
*/
156227
eid_t snapshot_global_epoch_id_;
157228

158229
bool is_running_;

src/include/concurrency/epoch_manager.h

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,53 @@
2121
namespace peloton {
2222
namespace concurrency {
2323

24+
/**
25+
* @brief Class for epoch manager.
26+
*/
2427
class EpochManager {
2528
EpochManager(const EpochManager&) = delete;
2629

2730
public:
2831
EpochManager() {}
2932

30-
// TODO: stop epoch threads before resetting epoch id.
33+
/** TODO: stop epoch threads before resetting epoch id. */
3134
virtual void Reset() = 0;
3235

36+
/**
37+
* @brief Reset epoch_id
38+
*
39+
* @param[in] epoch_id The epoch identifier
40+
*/
3341
virtual void Reset(const uint64_t epoch_id) = 0;
3442

43+
/**
44+
* @brief Sets the current epoch identifier.
45+
*
46+
* @param[in] epoch_id The epoch identifier
47+
*/
3548
virtual void SetCurrentEpochId(const uint64_t epoch_id) = 0;
3649

50+
/**
51+
* @brief Starts an epoch.
52+
*
53+
* @param epoch_thread The epoch thread
54+
*/
3755
virtual void StartEpoch(std::unique_ptr<std::thread> &epoch_thread) = 0;
3856

57+
/**
58+
* @brief Starts an epoch.
59+
*/
3960
virtual void StartEpoch() = 0;
4061

62+
/**
63+
* @brief Stops an epoch.
64+
*/
4165
virtual void StopEpoch() = 0;
4266

4367
//====================================================
4468
// designed for decentralized epoch manager
4569
//====================================================
70+
4671
virtual void RegisterThread(const size_t thread_id) = 0;
4772

4873
virtual void DeregisterThread(const size_t thread_id) = 0;
@@ -51,12 +76,32 @@ class EpochManager {
5176

5277
virtual void ExitEpoch(const size_t thread_id, const eid_t epoch_id) = 0;
5378

79+
/**
80+
* @brief Gets the expired epoch identifier.
81+
*
82+
* @return The expired epoch identifier.
83+
*/
5484
virtual eid_t GetExpiredEpochId() = 0;
5585

86+
/**
87+
* @brief Gets the next epoch identifier.
88+
*
89+
* @return The next epoch identifier.
90+
*/
5691
virtual eid_t GetNextEpochId() = 0;
5792

93+
/**
94+
* @brief Gets the current epoch identifier.
95+
*
96+
* @return The current epoch identifier.
97+
*/
5898
virtual eid_t GetCurrentEpochId() = 0;
5999

100+
/**
101+
* @brief Gets the expired cid.
102+
*
103+
* @return The expired cid.
104+
*/
60105
virtual cid_t GetExpiredCid() = 0;
61106

62107
};

0 commit comments

Comments
 (0)