Skip to content

Commit

Permalink
Merge branch 'master' into wenxuan/split_store_segment
Browse files Browse the repository at this point in the history
  • Loading branch information
breezewish authored Sep 9, 2022
2 parents 72b9c28 + 4299bef commit 02a789c
Show file tree
Hide file tree
Showing 22 changed files with 1,009 additions and 614 deletions.
23 changes: 7 additions & 16 deletions dbms/src/Common/MPMCQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class MPMCQueue
using Status = MPMCQueueStatus;
using Result = MPMCQueueResult;

explicit MPMCQueue(Int64 capacity_)
explicit MPMCQueue(size_t capacity_)
: capacity(capacity_)
, data(capacity * sizeof(T))
{
Expand Down Expand Up @@ -191,7 +191,7 @@ class MPMCQueue
{
return changeStatus([&] {
status = Status::CANCELLED;
cancelReason = std::move(reason);
cancel_reason = std::move(reason);
});
}

Expand All @@ -206,18 +206,6 @@ class MPMCQueue
});
}

bool isNextPopNonBlocking() const
{
std::unique_lock lock(mu);
return read_pos < write_pos || !isNormal();
}

bool isNextPushNonBlocking() const
{
std::unique_lock lock(mu);
return write_pos - read_pos < capacity || !isNormal();
}

Status getStatus() const
{
std::unique_lock lock(mu);
Expand All @@ -235,7 +223,7 @@ class MPMCQueue
{
std::unique_lock lock(mu);
RUNTIME_ASSERT(isCancelled());
return cancelReason;
return cancel_reason;
}

private:
Expand Down Expand Up @@ -427,6 +415,9 @@ class MPMCQueue
std::unique_lock lock(mu);
for (; read_pos < write_pos; ++read_pos)
destruct(getObj(read_pos));

read_pos = 0;
write_pos = 0;
}

template <typename F>
Expand All @@ -451,7 +442,7 @@ class MPMCQueue
Int64 read_pos = 0;
Int64 write_pos = 0;
Status status = Status::NORMAL;
String cancelReason;
String cancel_reason;

std::vector<UInt8> data;
};
Expand Down
9 changes: 1 addition & 8 deletions dbms/src/Common/TiFlashSecurity.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,13 @@
// limitations under the License.

#pragma once
#include <Common/grpcpp.h>
#include <Core/Types.h>
#include <IO/createReadBufferFromFileBase.h>
#include <Poco/String.h>
#include <Poco/StringTokenizer.h>
#include <Poco/Util/LayeredConfiguration.h>
#include <common/logger_useful.h>
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
#include <grpc++/grpc++.h>
#ifdef __clang__
#pragma clang diagnostic pop
#endif

#include <set>

Expand Down
28 changes: 28 additions & 0 deletions dbms/src/Common/VariantOp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2022 PingCAP, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <variant>

namespace variant_op
{
template <class... Ts>
struct overloaded : Ts...
{
using Ts::operator()...;
};
template <class... Ts>
overloaded(Ts...) -> overloaded<Ts...>;
} // namespace variant_op
24 changes: 24 additions & 0 deletions dbms/src/Common/grpcpp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2022 PingCAP, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
#include <grpcpp/grpcpp.h>
#ifdef __clang__
#pragma clang diagnostic pop
#endif
33 changes: 0 additions & 33 deletions dbms/src/Common/tests/gtest_mpmc_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,39 +649,6 @@ try
}
CATCH

TEST_F(MPMCQueueTest, isNextOpNonBlocking)
try
{
MPMCQueue<int> q(2);
ASSERT_TRUE(q.isNextPushNonBlocking());
ASSERT_FALSE(q.isNextPopNonBlocking());
ASSERT_TRUE(q.push(1) == MPMCQueueResult::OK);
ASSERT_TRUE(q.isNextPushNonBlocking());
ASSERT_TRUE(q.isNextPopNonBlocking());
int val;
ASSERT_TRUE(q.pop(val) == MPMCQueueResult::OK);
ASSERT_TRUE(q.isNextPushNonBlocking());
ASSERT_FALSE(q.isNextPopNonBlocking());
ASSERT_TRUE(q.push(1) == MPMCQueueResult::OK);
ASSERT_TRUE(q.isNextPushNonBlocking());
ASSERT_TRUE(q.isNextPopNonBlocking());
ASSERT_TRUE(q.push(1) == MPMCQueueResult::OK);
ASSERT_FALSE(q.isNextPushNonBlocking());
ASSERT_TRUE(q.isNextPopNonBlocking());

ASSERT_TRUE(q.finish());
ASSERT_FALSE(q.finish());

//check isNextPush/PopNonBlocking after finish
ASSERT_TRUE(q.pop(val) == MPMCQueueResult::OK);
ASSERT_TRUE(q.isNextPushNonBlocking());
ASSERT_TRUE(q.isNextPopNonBlocking());
ASSERT_TRUE(q.pop(val) == MPMCQueueResult::OK);
ASSERT_TRUE(q.isNextPushNonBlocking());
ASSERT_TRUE(q.isNextPopNonBlocking());
}
CATCH

struct Counter
{
static int count;
Expand Down
Loading

0 comments on commit 02a789c

Please sign in to comment.