You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by da...@apache.org on 2017/12/21 05:58:09 UTC
[1/4] kudu git commit: thirdparty: fix bison compilation in macOS
High Sierra
Repository: kudu
Updated Branches:
refs/heads/master b357fa9b7 -> 36ecb3009
thirdparty: fix bison compilation in macOS High Sierra
Apparently bison needs a patch to compile in macOS High Sierra.
See: https://github.com/spack/spack/issues/5521
This changeset just adds the patch from that issue and applies
it to bison source tree.
Change-Id: I25e384c5715951488f2fc10b64da764e48e1fec0
Reviewed-on: http://gerrit.cloudera.org:8080/8815
Reviewed-by: Dan Burkert <da...@apache.org>
Tested-by: Kudu Jenkins
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/538736c6
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/538736c6
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/538736c6
Branch: refs/heads/master
Commit: 538736c6a7aeac1914b86b142d5c94d0af98484c
Parents: b357fa9
Author: David Alves <dr...@apache.org>
Authored: Mon Dec 11 17:01:46 2017 -0800
Committer: David Ribeiro Alves <da...@gmail.com>
Committed: Tue Dec 19 21:35:20 2017 +0000
----------------------------------------------------------------------
thirdparty/download-thirdparty.sh | 5 ++++-
.../bison-fix-high-sierra-compilation-issue.patch | 15 +++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/538736c6/thirdparty/download-thirdparty.sh
----------------------------------------------------------------------
diff --git a/thirdparty/download-thirdparty.sh b/thirdparty/download-thirdparty.sh
index 11d2025..decb2be 100755
--- a/thirdparty/download-thirdparty.sh
+++ b/thirdparty/download-thirdparty.sh
@@ -354,12 +354,15 @@ if [ ! -d "$THRIFT_SOURCE" ]; then
popd
fi
-BISON_PATCHLEVEL=0
+BISON_PATCHLEVEL=1
if [ ! -d "$BISON_SOURCE" ]; then
fetch_and_expand $BISON_NAME.tar.gz
# This would normally call autoreconf, but it does not succeed with
# autoreconf 2.69 (RHEL 7): "autoreconf: 'configure.ac' or 'configure.in' is required".
pushd $BISON_SOURCE
+ # Fix compilation issue in macOS High Sierra
+ # See: https://github.com/spack/spack/issues/5521
+ patch -p0 < $TP_DIR/patches/bison-fix-high-sierra-compilation-issue.patch
touch patchlevel-$BISON_PATCHLEVEL
popd
fi
http://git-wip-us.apache.org/repos/asf/kudu/blob/538736c6/thirdparty/patches/bison-fix-high-sierra-compilation-issue.patch
----------------------------------------------------------------------
diff --git a/thirdparty/patches/bison-fix-high-sierra-compilation-issue.patch b/thirdparty/patches/bison-fix-high-sierra-compilation-issue.patch
new file mode 100644
index 0000000..0dff749
--- /dev/null
+++ b/thirdparty/patches/bison-fix-high-sierra-compilation-issue.patch
@@ -0,0 +1,15 @@
+With format string strictness, High Sierra also enforces that %n isn't used
+in dynamic format strings, but we should just disable its use on darwin in
+general.
+
+--- lib/vasnprintf.c.orig 2017-06-22 15:19:15.000000000 -0700
++++ lib/vasnprintf.c 2017-06-22 15:20:20.000000000 -0700
+@@ -4869,7 +4869,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *
+ #endif
+ *fbp = dp->conversion;
+ #if USE_SNPRINTF
+-# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
++# if !defined(__APPLE__) && !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+ fbp[1] = '%';
+ fbp[2] = 'n';
+ fbp[3] = '\0';
[3/4] kudu git commit: KUDU-2237: Allow idle server connection
scanning to be disabled
Posted by da...@apache.org.
KUDU-2237: Allow idle server connection scanning to be disabled
Currently, a server connection being idle for more than
FLAGS_rpc_default_keepalive_time_ms ms will be closed.
However, certain services (e.g. Impala) using KRPC may want to
keep the idle connections alive for various reasons (e.g. sheer
number of connections to re-establish, negotiation overhead
in a secure cluster). To avoid idle connection from being
closed, one currently have to set FLAGS_rpc_default_keepalive_time_ms
to a very large value.
This change implements a cleaner solution by disabling idle
connection scanning if FLAGS_rpc_default_keepalive_time_ms is
set to any negative value. This avoids the unnecessary
overhead of scanning for idle server connections and alleviates
the user from having to pick a random large number to make sure
the connection is always kept alive.
Change-Id: I6161b9e753f05620784565a417d248acf8e7050a
Reviewed-on: http://gerrit.cloudera.org:8080/8831
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <to...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/948ac0eb
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/948ac0eb
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/948ac0eb
Branch: refs/heads/master
Commit: 948ac0eb45b83cbba476cf722dd5c043ddac5de3
Parents: f2184c1
Author: Michael Ho <kw...@cloudera.com>
Authored: Wed Dec 13 14:30:25 2017 -0800
Committer: Todd Lipcon <to...@apache.org>
Committed: Thu Dec 21 04:48:14 2017 +0000
----------------------------------------------------------------------
src/kudu/rpc/messenger.h | 1 +
src/kudu/rpc/reactor.cc | 40 +++++++++++++++++++-----------------
src/kudu/rpc/reactor.h | 3 ++-
src/kudu/rpc/rpc-test-base.h | 15 +++++++-------
src/kudu/rpc/rpc-test.cc | 41 +++++++++++++++++++++++++++++++++++++
src/kudu/server/server_base.cc | 3 ++-
6 files changed, 75 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/948ac0eb/src/kudu/rpc/messenger.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/messenger.h b/src/kudu/rpc/messenger.h
index 6a0581b..e030a5c 100644
--- a/src/kudu/rpc/messenger.h
+++ b/src/kudu/rpc/messenger.h
@@ -322,6 +322,7 @@ class Messenger {
private:
FRIEND_TEST(TestRpc, TestConnectionKeepalive);
+ FRIEND_TEST(TestRpc, TestConnectionAlwaysKeepalive);
FRIEND_TEST(TestRpc, TestCredentialsPolicy);
FRIEND_TEST(TestRpc, TestReopenOutboundConnections);
http://git-wip-us.apache.org/repos/asf/kudu/blob/948ac0eb/src/kudu/rpc/reactor.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/reactor.cc b/src/kudu/rpc/reactor.cc
index 7f13cb8..3898196 100644
--- a/src/kudu/rpc/reactor.cc
+++ b/src/kudu/rpc/reactor.cc
@@ -403,28 +403,30 @@ void ReactorThread::ScanIdleConnections() {
// Enforce TCP connection timeouts: server-side connections.
const auto server_conns_end = server_conns_.end();
uint64_t timed_out = 0;
- for (auto it = server_conns_.begin(); it != server_conns_end; ) {
- Connection* conn = it->get();
- if (!conn->Idle()) {
- VLOG(10) << "Connection " << conn->ToString() << " not idle";
- ++it;
- continue;
- }
+ // Scan for idle server connections if it's enabled.
+ if (connection_keepalive_time_ >= MonoDelta::FromMilliseconds(0)) {
+ for (auto it = server_conns_.begin(); it != server_conns_end; ) {
+ Connection* conn = it->get();
+ if (!conn->Idle()) {
+ VLOG(10) << "Connection " << conn->ToString() << " not idle";
+ ++it;
+ continue;
+ }
- const MonoDelta connection_delta(cur_time_ - conn->last_activity_time());
- if (connection_delta <= connection_keepalive_time_) {
- ++it;
- continue;
- }
+ const MonoDelta connection_delta(cur_time_ - conn->last_activity_time());
+ if (connection_delta <= connection_keepalive_time_) {
+ ++it;
+ continue;
+ }
- conn->Shutdown(Status::NetworkError(
- Substitute("connection timed out after $0", connection_keepalive_time_.ToString())));
- VLOG(1) << "Timing out connection " << conn->ToString() << " - it has been idle for "
- << connection_delta.ToString();
- ++timed_out;
- it = server_conns_.erase(it);
+ conn->Shutdown(Status::NetworkError(
+ Substitute("connection timed out after $0", connection_keepalive_time_.ToString())));
+ VLOG(1) << "Timing out connection " << conn->ToString() << " - it has been idle for "
+ << connection_delta.ToString();
+ ++timed_out;
+ it = server_conns_.erase(it);
+ }
}
-
// Take care of idle client-side connections marked for shutdown.
uint64_t shutdown = 0;
for (auto it = client_conns_.begin(); it != client_conns_.end();) {
http://git-wip-us.apache.org/repos/asf/kudu/blob/948ac0eb/src/kudu/rpc/reactor.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/reactor.h b/src/kudu/rpc/reactor.h
index 288e38e..370c4b7 100644
--- a/src/kudu/rpc/reactor.h
+++ b/src/kudu/rpc/reactor.h
@@ -244,7 +244,8 @@ class ReactorThread {
std::unique_ptr<ErrorStatusPB> rpc_error = {});
// Scan any open connections for idle ones that have been idle longer than
- // connection_keepalive_time_
+ // connection_keepalive_time_. If connection_keepalive_time_ < 0, the scan
+ // is skipped.
void ScanIdleConnections();
// Create a new client socket (non-blocking, NODELAY)
http://git-wip-us.apache.org/repos/asf/kudu/blob/948ac0eb/src/kudu/rpc/rpc-test-base.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpc-test-base.h b/src/kudu/rpc/rpc-test-base.h
index 53ba71d..cc2480e 100644
--- a/src/kudu/rpc/rpc-test-base.h
+++ b/src/kudu/rpc/rpc-test-base.h
@@ -445,13 +445,14 @@ class RpcTestBase : public KuduTest {
}
bld.set_num_reactors(n_reactors);
- bld.set_connection_keepalive_time(
- MonoDelta::FromMilliseconds(keepalive_time_ms_));
- // In order for the keepalive timing to be accurate, we need to scan connections
- // significantly more frequently than the keepalive time. This "coarse timer"
- // granularity determines this.
- bld.set_coarse_timer_granularity(MonoDelta::FromMilliseconds(
- std::min(keepalive_time_ms_ / 5, 100)));
+ bld.set_connection_keepalive_time(MonoDelta::FromMilliseconds(keepalive_time_ms_));
+ if (keepalive_time_ms_ >= 0) {
+ // In order for the keepalive timing to be accurate, we need to scan connections
+ // significantly more frequently than the keepalive time. This "coarse timer"
+ // granularity determines this.
+ bld.set_coarse_timer_granularity(
+ MonoDelta::FromMilliseconds(std::min(keepalive_time_ms_ / 5, 100)));
+ }
bld.set_metric_entity(metric_entity_);
std::shared_ptr<Messenger> messenger;
CHECK_OK(bld.Build(&messenger));
http://git-wip-us.apache.org/repos/asf/kudu/blob/948ac0eb/src/kudu/rpc/rpc-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpc-test.cc b/src/kudu/rpc/rpc-test.cc
index d3360f8..26d0a7b 100644
--- a/src/kudu/rpc/rpc-test.cc
+++ b/src/kudu/rpc/rpc-test.cc
@@ -403,6 +403,47 @@ TEST_P(TestRpc, TestConnectionKeepalive) {
ASSERT_EQ(0, metrics.num_client_connections_) << "Client should have 0 client connections";
}
+// Test that idle connection is kept alive when 'keepalive_time_ms_' is set to -1.
+TEST_P(TestRpc, TestConnectionAlwaysKeepalive) {
+ // Only run one reactor per messenger, so we can grab the metrics from that
+ // one without having to check all.
+ n_server_reactor_threads_ = 1;
+ keepalive_time_ms_ = -1;
+
+ // Set up server.
+ Sockaddr server_addr;
+ bool enable_ssl = GetParam();
+ StartTestServer(&server_addr, enable_ssl);
+
+ // Set up client.
+ LOG(INFO) << "Connecting to " << server_addr.ToString();
+ shared_ptr<Messenger> client_messenger(CreateMessenger("Client", 1, enable_ssl));
+ Proxy p(client_messenger, server_addr, server_addr.host(),
+ GenericCalculatorService::static_service_name());
+
+ ASSERT_OK(DoTestSyncCall(p, GenericCalculatorService::kAddMethodName));
+
+ ReactorMetrics metrics;
+ ASSERT_OK(server_messenger_->reactors_[0]->GetMetrics(&metrics));
+ ASSERT_EQ(1, metrics.num_server_connections_) << "Server should have 1 server connection";
+ ASSERT_EQ(0, metrics.num_client_connections_) << "Server should have 0 client connections";
+
+ ASSERT_OK(client_messenger->reactors_[0]->GetMetrics(&metrics));
+ ASSERT_EQ(0, metrics.num_server_connections_) << "Client should have 0 server connections";
+ ASSERT_EQ(1, metrics.num_client_connections_) << "Client should have 1 client connections";
+
+ SleepFor(MonoDelta::FromSeconds(3));
+
+ // After sleeping, the connection should still be alive.
+ ASSERT_OK(server_messenger_->reactors_[0]->GetMetrics(&metrics));
+ ASSERT_EQ(1, metrics.num_server_connections_) << "Server should have 1 server connections";
+ ASSERT_EQ(0, metrics.num_client_connections_) << "Server should have 0 client connections";
+
+ ASSERT_OK(client_messenger->reactors_[0]->GetMetrics(&metrics));
+ ASSERT_EQ(0, metrics.num_server_connections_) << "Client should have 0 server connections";
+ ASSERT_EQ(1, metrics.num_client_connections_) << "Client should have 1 client connections";
+}
+
// Test that outbound connections to the same server are reopen upon every RPC
// call when the 'rpc_reopen_outbound_connections' flag is set.
TEST_P(TestRpc, TestReopenOutboundConnections) {
http://git-wip-us.apache.org/repos/asf/kudu/blob/948ac0eb/src/kudu/server/server_base.cc
----------------------------------------------------------------------
diff --git a/src/kudu/server/server_base.cc b/src/kudu/server/server_base.cc
index 269c098..90e60ed 100644
--- a/src/kudu/server/server_base.cc
+++ b/src/kudu/server/server_base.cc
@@ -199,7 +199,8 @@ TAG_FLAG(rpc_ca_certificate_file, experimental);
DEFINE_int32(rpc_default_keepalive_time_ms, 65000,
"If an RPC connection from a client is idle for this amount of time, the server "
- "will disconnect the client.");
+ "will disconnect the client. Setting this to any negative value keeps connections "
+ "always alive.");
TAG_FLAG(rpc_default_keepalive_time_ms, advanced);
DECLARE_bool(use_hybrid_clock);
[2/4] kudu git commit: [web server] fix typo in parameter description
Posted by da...@apache.org.
[web server] fix typo in parameter description
Fixed a minor typo in description of the webserver_encryption parameter.
This changelist does not contain any functional changes.
Change-Id: I92a879b586fd627c3b1ec77ec40e0f7d2c63dfb7
Reviewed-on: http://gerrit.cloudera.org:8080/8899
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <to...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/f2184c1d
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/f2184c1d
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/f2184c1d
Branch: refs/heads/master
Commit: f2184c1d3a80d3ec13774868c14e251a5e1c1489
Parents: 538736c
Author: Alexey Serbin <as...@cloudera.com>
Authored: Wed Dec 20 18:12:33 2017 -0800
Committer: Todd Lipcon <to...@apache.org>
Committed: Thu Dec 21 04:31:18 2017 +0000
----------------------------------------------------------------------
src/kudu/server/default_path_handlers.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/f2184c1d/src/kudu/server/default_path_handlers.cc
----------------------------------------------------------------------
diff --git a/src/kudu/server/default_path_handlers.cc b/src/kudu/server/default_path_handlers.cc
index a76a565..4db825d 100644
--- a/src/kudu/server/default_path_handlers.cc
+++ b/src/kudu/server/default_path_handlers.cc
@@ -239,7 +239,7 @@ static void ConfigurationHandler(const Webserver::WebRequest& /* req */,
webserver_encryption["secure"] = !FLAGS_webserver_certificate_file.empty();
webserver_encryption["id"] = "webserver_encryption";
webserver_encryption["explanation"] = "Configure with --webserver_certificate_file and "
- "webserver_private_key_file.";
+ "--webserver_private_key_file.";
EasyJson webserver_redaction = security_configs.PushBack(EasyJson::kObject);
webserver_redaction["name"] = "Webserver Redaction";
[4/4] kudu git commit: KUDU-2231: sparse column predicate can cause
excessive data-block reads
Posted by da...@apache.org.
KUDU-2231: sparse column predicate can cause excessive data-block reads
When scanning with a sparsely-matching predicate, the CFileIterator can
repeatedly materialize non-predicate column blocks multiple times. The
result is huge amounts of CPU wasted in block decoding and poor
performance.
The root cause is that CFileIterator::SeekToOrdinal does not check
whether the currently materialized data block contains the ordinal index
being seeked to. Instead, it throws away the currently prepared blocks
(in CFileIterator::PrepareForNewSeek), and re-materializes the blocks
again.
This commit is a very targeted fix. Since I've had some time to get
familiar with this codepath in the past few days, I've found some things
that I think we could improve and simplify in follow-up commits, which
I've filed as KUDU-2243.
Change-Id: I8eb3be4a809f882ccd80c48612099b2071306ff7
Reviewed-on: http://gerrit.cloudera.org:8080/8869
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <da...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/36ecb300
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/36ecb300
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/36ecb300
Branch: refs/heads/master
Commit: 36ecb300901daf4006fae0c9be5657f2f6127233
Parents: 948ac0e
Author: Dan Burkert <da...@apache.org>
Authored: Fri Dec 15 17:03:25 2017 -0800
Committer: Dan Burkert <da...@apache.org>
Committed: Thu Dec 21 05:57:41 2017 +0000
----------------------------------------------------------------------
src/kudu/cfile/cfile_reader.cc | 62 ++++++++++++++++---------
src/kudu/tablet/tablet-pushdown-test.cc | 67 +++++++++++++++++++++++++++-
2 files changed, 106 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/36ecb300/src/kudu/cfile/cfile_reader.cc
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/cfile_reader.cc b/src/kudu/cfile/cfile_reader.cc
index c6e163a..6f19487 100644
--- a/src/kudu/cfile/cfile_reader.cc
+++ b/src/kudu/cfile/cfile_reader.cc
@@ -668,37 +668,57 @@ CFileIterator::~CFileIterator() {
}
Status CFileIterator::SeekToOrdinal(rowid_t ord_idx) {
- RETURN_NOT_OK(PrepareForNewSeek());
- if (PREDICT_FALSE(posidx_iter_ == nullptr)) {
- return Status::NotSupported("no positional index in file");
- }
+ // Check to see if we already have the required block prepared. Typically
+ // (when seeking forward during a scan), only the final block might be
+ // suitable, since all previous blocks will have been scanned in the prior
+ // batch. Only reusing the final block also ensures posidx_iter_ is already
+ // seeked to the correct block.
+ if (!prepared_blocks_.empty() &&
+ prepared_blocks_.back()->last_row_idx() >= ord_idx &&
+ prepared_blocks_.back()->first_row_idx() <= ord_idx) {
+ PreparedBlock* b = prepared_blocks_.back();
+ prepared_blocks_.pop_back();
+ for (PreparedBlock* pb : prepared_blocks_) {
+ prepared_block_pool_.Destroy(pb);
+ }
+ prepared_blocks_.clear();
- tmp_buf_.clear();
- KeyEncoderTraits<UINT32, faststring>::Encode(ord_idx, &tmp_buf_);
- RETURN_NOT_OK(posidx_iter_->SeekAtOrBefore(Slice(tmp_buf_)));
+ prepared_blocks_.push_back(b);
+ } else {
+ // Otherwise, prepare a new cblock to scan.
+ RETURN_NOT_OK(PrepareForNewSeek());
+ if (PREDICT_FALSE(posidx_iter_ == nullptr)) {
+ return Status::NotSupported("no positional index in file");
+ }
- // TODO: fast seek within block (without reseeking index)
- pblock_pool_scoped_ptr b = prepared_block_pool_.make_scoped_ptr(
- prepared_block_pool_.Construct());
- RETURN_NOT_OK(ReadCurrentDataBlock(*posidx_iter_, b.get()));
-
- // If the data block doesn't actually contain the data
- // we're looking for, then we're probably in the last
- // block in the file.
- // TODO: could assert that each of the index layers is
- // at its last entry (ie HasNext() is false for each)
- if (PREDICT_FALSE(ord_idx > b->last_row_idx())) {
- return Status::NotFound("trying to seek past highest ordinal in file");
+ tmp_buf_.clear();
+ KeyEncoderTraits<UINT32, faststring>::Encode(ord_idx, &tmp_buf_);
+ RETURN_NOT_OK(posidx_iter_->SeekAtOrBefore(Slice(tmp_buf_)));
+
+ pblock_pool_scoped_ptr b = prepared_block_pool_.make_scoped_ptr(
+ prepared_block_pool_.Construct());
+ RETURN_NOT_OK(ReadCurrentDataBlock(*posidx_iter_, b.get()));
+
+ // If the data block doesn't actually contain the data
+ // we're looking for, then we're probably in the last
+ // block in the file.
+ // TODO(unknown): could assert that each of the index layers is
+ // at its last entry (ie HasNext() is false for each)
+ if (PREDICT_FALSE(ord_idx > b->last_row_idx())) {
+ return Status::NotFound("trying to seek past highest ordinal in file");
+ }
+ prepared_blocks_.push_back(b.release());
}
+ PreparedBlock* b = prepared_blocks_.back();
+
// Seek data block to correct index
DCHECK(ord_idx >= b->first_row_idx() &&
ord_idx <= b->last_row_idx())
<< "got wrong data block. looking for ord_idx=" << ord_idx
<< " but got dblk " << b->ToString();
- SeekToPositionInBlock(b.get(), ord_idx - b->first_row_idx());
+ SeekToPositionInBlock(b, ord_idx - b->first_row_idx());
- prepared_blocks_.push_back(b.release());
last_prepare_idx_ = ord_idx;
last_prepare_count_ = 0;
seeked_ = posidx_iter_.get();
http://git-wip-us.apache.org/repos/asf/kudu/blob/36ecb300/src/kudu/tablet/tablet-pushdown-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet-pushdown-test.cc b/src/kudu/tablet/tablet-pushdown-test.cc
index c8c4190..3023697 100644
--- a/src/kudu/tablet/tablet-pushdown-test.cc
+++ b/src/kudu/tablet/tablet-pushdown-test.cc
@@ -35,7 +35,6 @@
#include "kudu/common/scan_spec.h"
#include "kudu/common/schema.h"
#include "kudu/gutil/gscoped_ptr.h"
-#include "kudu/gutil/port.h"
#include "kudu/gutil/stringprintf.h"
#include "kudu/tablet/local_tablet_writer.h"
#include "kudu/tablet/tablet-test-util.h"
@@ -68,7 +67,7 @@ class TabletPushdownTest : public KuduTabletTest,
ColumnSchema("string_val", STRING) }, 1)) {
}
- virtual void SetUp() OVERRIDE {
+ void SetUp() override {
KuduTabletTest::SetUp();
FillTestTablet();
@@ -226,5 +225,69 @@ INSTANTIATE_TEST_CASE_P(AllMemory, TabletPushdownTest, ::testing::Values(ALL_IN_
INSTANTIATE_TEST_CASE_P(SplitMemoryDisk, TabletPushdownTest, ::testing::Values(SPLIT_MEMORY_DISK));
INSTANTIATE_TEST_CASE_P(AllDisk, TabletPushdownTest, ::testing::Values(ALL_ON_DISK));
+class TabletSparsePushdownTest : public KuduTabletTest {
+ public:
+ TabletSparsePushdownTest()
+ : KuduTabletTest(Schema({ ColumnSchema("key", INT32),
+ ColumnSchema("val", INT32, true) },
+ 1)) {
+ }
+
+ void SetUp() override {
+ KuduTabletTest::SetUp();
+
+ RowBuilder rb(client_schema_);
+
+ LocalTabletWriter writer(tablet().get(), &client_schema_);
+ KuduPartialRow row(&client_schema_);
+
+ // FLAGS_scanner_batch_size_rows * 2
+ int kWidth = 100 * 2;
+ for (int i = 0; i < kWidth * 2; i++) {
+ CHECK_OK(row.SetInt32(0, i));
+ if (i % 3 == 0) {
+ CHECK_OK(row.SetNull(1));
+ } else {
+ CHECK_OK(row.SetInt32(1, i % kWidth));
+ }
+ ASSERT_OK_FAST(writer.Insert(row));
+ }
+ ASSERT_OK(tablet()->Flush());
+ }
+};
+
+// The is a regression test for KUDU-2231, which fixed a CFileReader bug causing
+// cblocks to be repeatedly materialized when a scan had predicates on other
+// columns which caused sections of a column to be skipped. The setup for this
+// test creates a dataset and predicate which only match every-other batch of
+// 100 rows of the 'val' column.
+TEST_F(TabletSparsePushdownTest, Kudu2231) {
+ ScanSpec spec;
+ int32_t value = 50;
+ spec.AddPredicate(ColumnPredicate::Equality(schema_.column(1), &value));
+
+ gscoped_ptr<RowwiseIterator> iter;
+ ASSERT_OK(tablet()->NewRowIterator(client_schema_, &iter));
+ ASSERT_OK(iter->Init(&spec));
+ ASSERT_TRUE(spec.predicates().empty()) << "Should have accepted all predicates";
+
+ vector<string> results;
+ ASSERT_OK(IterateToStringList(iter.get(), &results));
+
+ EXPECT_EQ(results, vector<string>({
+ "(int32 key=50, int32 val=50)",
+ "(int32 key=250, int32 val=50)",
+ }));
+
+ vector<IteratorStats> stats;
+ iter->GetIteratorStats(&stats);
+
+ EXPECT_EQ(1, stats[0].data_blocks_read_from_disk);
+ EXPECT_EQ(1, stats[1].data_blocks_read_from_disk);
+
+ EXPECT_EQ(400, stats[0].cells_read_from_disk);
+ EXPECT_EQ(400, stats[1].cells_read_from_disk);
+}
+
} // namespace tablet
} // namespace kudu