You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2016/09/12 08:26:37 UTC
[23/46] ignite git commit: IGNITE-3628: ODBC: Added ability to
configure page size in DSN,
changed default value from 32 to 1024. This closes #1014.
IGNITE-3628: ODBC: Added ability to configure page size in DSN, changed default value from 32 to 1024. This closes #1014.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8970b3e3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8970b3e3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8970b3e3
Branch: refs/heads/master
Commit: 8970b3e3a36b18274b451fddf365627ba23459d6
Parents: 3550829
Author: Igor Sapego <is...@gridgain.com>
Authored: Mon Sep 5 18:15:11 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Sep 5 18:15:11 2016 +0300
----------------------------------------------------------------------
.../cpp/common/include/ignite/ignite_error.h | 2 +-
.../platforms/cpp/common/src/ignite_error.cpp | 2 +-
.../cpp/odbc-test/src/configuration_test.cpp | 14 ++++-
.../odbc-test/src/sql_test_suite_fixture.cpp | 2 +-
.../include/ignite/odbc/config/configuration.h | 59 ++++++++++++++++----
.../cpp/odbc/include/ignite/odbc/result_page.h | 3 -
.../odbc/system/ui/dsn_configuration_window.h | 8 +++
.../src/system/ui/dsn_configuration_window.cpp | 29 ++++++++--
.../cpp/odbc/src/config/configuration.cpp | 32 +++--------
modules/platforms/cpp/odbc/src/dsn_config.cpp | 12 +++-
.../platforms/cpp/odbc/src/query/data_query.cpp | 2 +-
11 files changed, 113 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8970b3e3/modules/platforms/cpp/common/include/ignite/ignite_error.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/ignite_error.h b/modules/platforms/cpp/common/include/ignite/ignite_error.h
index 4c0e263..a41a42f 100644
--- a/modules/platforms/cpp/common/include/ignite/ignite_error.h
+++ b/modules/platforms/cpp/common/include/ignite/ignite_error.h
@@ -199,7 +199,7 @@ namespace ignite
*
* @param err Error.
*/
- static void ThrowIfNeeded(IgniteError& err);
+ static void ThrowIfNeeded(const IgniteError& err);
/**
* Default constructor.
http://git-wip-us.apache.org/repos/asf/ignite/blob/8970b3e3/modules/platforms/cpp/common/src/ignite_error.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/ignite_error.cpp b/modules/platforms/cpp/common/src/ignite_error.cpp
index 5acbed2..8179184 100644
--- a/modules/platforms/cpp/common/src/ignite_error.cpp
+++ b/modules/platforms/cpp/common/src/ignite_error.cpp
@@ -24,7 +24,7 @@ using namespace ignite::java;
namespace ignite
{
- void IgniteError::ThrowIfNeeded(IgniteError& err)
+ void IgniteError::ThrowIfNeeded(const IgniteError& err)
{
if (err.code != IGNITE_SUCCESS)
throw err;
http://git-wip-us.apache.org/repos/asf/ignite/blob/8970b3e3/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
index 0fd3277..bfdb220 100644
--- a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
@@ -37,6 +37,7 @@ namespace
const uint16_t testServerPort = 4242;
const std::string testCacheName = "TestCache";
const std::string testDsn = "Ignite DSN";
+ const int32_t testPageSize = 4321;
const std::string testAddress = testServerHost + ':' + ignite::common::LexicalCast<std::string>(testServerPort);
}
@@ -76,12 +77,14 @@ void CheckConnectionConfig(const Configuration& cfg)
BOOST_CHECK_EQUAL(cfg.GetAddress(), testAddress);
BOOST_CHECK_EQUAL(cfg.GetCache(), testCacheName);
BOOST_CHECK_EQUAL(cfg.GetDsn(), std::string());
+ BOOST_CHECK_EQUAL(cfg.GetPageSize(), testPageSize);
std::stringstream constructor;
constructor << "address=" << testAddress << ';'
<< "cache=" << testCacheName << ';'
- << "driver={" << testDriverName << "};";
+ << "driver={" << testDriverName << "};"
+ << "page_size=" << testPageSize << ';';
const std::string& expectedStr = constructor.str();
@@ -96,6 +99,7 @@ void CheckDsnConfig(const Configuration& cfg)
BOOST_CHECK_EQUAL(cfg.GetAddress(), Configuration::DefaultValue::address);
BOOST_CHECK_EQUAL(cfg.GetHost(), std::string());
BOOST_CHECK_EQUAL(cfg.GetTcpPort(), Configuration::DefaultValue::port);
+ BOOST_CHECK_EQUAL(cfg.GetPageSize(), Configuration::DefaultValue::pageSize);
}
BOOST_AUTO_TEST_SUITE(ConfigurationTestSuite)
@@ -107,6 +111,7 @@ BOOST_AUTO_TEST_CASE(CheckTestValuesNotEquealDefault)
BOOST_CHECK_NE(testServerPort, Configuration::DefaultValue::port);
BOOST_CHECK_NE(testCacheName, Configuration::DefaultValue::cache);
BOOST_CHECK_NE(testDsn, Configuration::DefaultValue::dsn);
+ BOOST_CHECK_NE(testPageSize, Configuration::DefaultValue::pageSize);
}
BOOST_AUTO_TEST_CASE(TestConnectStringUppercase)
@@ -117,7 +122,8 @@ BOOST_AUTO_TEST_CASE(TestConnectStringUppercase)
constructor << "DRIVER={" << testDriverName << "};"
<< "ADDRESS=" << testAddress << ';'
- << "CACHE=" << testCacheName;
+ << "CACHE=" << testCacheName << ';'
+ << "PAGE_SIZE=" << testPageSize;
const std::string& connectStr = constructor.str();
@@ -134,6 +140,7 @@ BOOST_AUTO_TEST_CASE(TestConnectStringLowercase)
constructor << "driver={" << testDriverName << "};"
<< "address=" << testAddress << ';'
+ << "page_size=" << testPageSize << ';'
<< "cache=" << testCacheName << ';';
const std::string& connectStr = constructor.str();
@@ -151,6 +158,7 @@ BOOST_AUTO_TEST_CASE(TestConnectStringZeroTerminated)
constructor << "driver={" << testDriverName << "};"
<< "address=" << testAddress << ';'
+ << "page_size=" << testPageSize << ';'
<< "cache=" << testCacheName << ';';
const std::string& connectStr = constructor.str();
@@ -168,6 +176,7 @@ BOOST_AUTO_TEST_CASE(TestConnectStringMixed)
constructor << "Driver={" << testDriverName << "};"
<< "Address=" << testAddress << ';'
+ << "Page_Size=" << testPageSize << ';'
<< "Cache=" << testCacheName << ';';
const std::string& connectStr = constructor.str();
@@ -185,6 +194,7 @@ BOOST_AUTO_TEST_CASE(TestConnectStringWhitepaces)
constructor << "DRIVER = {" << testDriverName << "} ;\n"
<< " ADDRESS =" << testAddress << "; "
+ << " PAGE_SIZE= " << testPageSize << ';'
<< "CACHE = \n\r" << testCacheName << ';';
const std::string& connectStr = constructor.str();
http://git-wip-us.apache.org/repos/asf/ignite/blob/8970b3e3/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
index e9a8fc5..29d1d18 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
@@ -131,7 +131,7 @@ namespace ignite
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
ret = SQLFetch(stmt);
- BOOST_CHECK(ret == SQL_NO_DATA) ;
+ BOOST_CHECK(ret == SQL_NO_DATA);
}
template<>
http://git-wip-us.apache.org/repos/asf/ignite/blob/8970b3e3/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h b/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
index f90fa2d..b5f385e 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
@@ -64,6 +64,9 @@ namespace ignite
/** Connection attribute keyword for protocol version attribute. */
static const std::string protocolVersion;
+
+ /** Connection attribute keyword for fetch results page size attribute. */
+ static const std::string pageSize;
};
/** Default values for configuration. */
@@ -89,6 +92,9 @@ namespace ignite
/** Default value for port attribute. */
static const uint16_t port;
+
+ /** Default value for fetch results page size attribute. */
+ static const int32_t pageSize;
};
/**
@@ -126,7 +132,10 @@ namespace ignite
*
* @param str Connect string.
*/
- void FillFromConnectString(const std::string& str);
+ void FillFromConnectString(const std::string& str)
+ {
+ FillFromConnectString(str.data(), str.size());
+ }
/**
* Convert configure to connect string.
@@ -158,7 +167,10 @@ namespace ignite
*
* @param port Server port.
*/
- void SetTcpPort(uint16_t port);
+ void SetTcpPort(uint16_t port)
+ {
+ arguments[Key::port] = common::LexicalCast<std::string>(port);
+ }
/**
* Get DSN.
@@ -251,28 +263,51 @@ namespace ignite
}
/**
- * Get argument map.
+ * Get protocol version.
*
- * @return Argument map.
+ * @return Protocol version.
*/
- const ArgumentMap& GetMap() const
+ ProtocolVersion GetProtocolVersion() const;
+
+ /**
+ * Set protocol version.
+ *
+ * @param version Version to set.
+ */
+ void SetProtocolVersion(const std::string& version)
{
- return arguments;
+ arguments[Key::protocolVersion] = version;
}
/**
- * Get protocol version.
+ * Get fetch results page size.
*
- * @return Protocol version.
+ * @return Fetch results page size.
*/
- ProtocolVersion GetProtocolVersion() const;
+ int32_t GetPageSize() const
+ {
+ return static_cast<int32_t>(GetIntValue(Key::pageSize, DefaultValue::pageSize));
+ }
/**
- * Set protocol version.
+ * Set fetch results page size.
*
- * @param version Version to set.
+ * @param size Fetch results page size.
*/
- void SetProtocolVersion(const std::string& version);
+ void SetPageSize(int32_t size)
+ {
+ arguments[Key::pageSize] = common::LexicalCast<std::string>(size);
+ }
+
+ /**
+ * Get argument map.
+ *
+ * @return Argument map.
+ */
+ const ArgumentMap& GetMap() const
+ {
+ return arguments;
+ }
/**
* Get string value from the config.
http://git-wip-us.apache.org/repos/asf/ignite/blob/8970b3e3/modules/platforms/cpp/odbc/include/ignite/odbc/result_page.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/result_page.h b/modules/platforms/cpp/odbc/include/ignite/odbc/result_page.h
index 3533229..c175487 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/result_page.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/result_page.h
@@ -37,9 +37,6 @@ namespace ignite
enum { DEFAULT_ALLOCATED_MEMORY = 1024 };
public:
- // Default result page size.
- enum { DEFAULT_SIZE = 32 };
-
/**
* Constructor.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/8970b3e3/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h b/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
index 034de82..f034a8b 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
@@ -46,6 +46,8 @@ namespace ignite
ID_ADDRESS_LABEL,
ID_CACHE_EDIT,
ID_CACHE_LABEL,
+ ID_PAGE_SIZE_EDIT,
+ ID_PAGE_SIZE_LABEL,
ID_OK_BUTTON,
ID_CANCEL_BUTTON
};
@@ -116,6 +118,12 @@ namespace ignite
/** DSN cache edit field. */
std::auto_ptr<Window> cacheEdit;
+ /** DSN fetch page size edit field label. */
+ std::auto_ptr<Window> pageSizeLabel;
+
+ /** DSN fetch page size edit field. */
+ std::auto_ptr<Window> pageSizeEdit;
+
/** Ok button. */
std::auto_ptr<Window> okButton;
http://git-wip-us.apache.org/repos/asf/ignite/blob/8970b3e3/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
index 76132bd..49f87d8 100644
--- a/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
+++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
@@ -30,7 +30,7 @@ namespace ignite
DsnConfigurationWindow::DsnConfigurationWindow(Window* parent, config::Configuration& config):
CustomWindow(parent, "IgniteConfigureDsn", "Configure Apache Ignite DSN"),
width(360),
- height(160),
+ height(200),
connectionSettingsGroupBox(),
nameLabel(),
nameEdit(),
@@ -38,6 +38,8 @@ namespace ignite
addressEdit(),
cacheLabel(),
cacheEdit(),
+ pageSizeLabel(),
+ pageSizeEdit(),
okButton(),
cancelButton(),
config(config),
@@ -111,6 +113,16 @@ namespace ignite
cacheLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "Cache name:", ID_CACHE_LABEL);
cacheEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ID_CACHE_EDIT);
+ rowPos += interval + rowSize;
+
+ std::string tmp = common::LexicalCast<std::string>(config.GetPageSize());
+ val = tmp.c_str();
+ pageSizeLabel = CreateLabel(labelPosX, rowPos, labelSizeX,
+ rowSize, "Page size:", ID_PAGE_SIZE_LABEL);
+
+ pageSizeEdit = CreateEdit(editPosX, rowPos, editSizeX,
+ rowSize, val, ID_PAGE_SIZE_EDIT, ES_NUMBER);
+
rowPos += interval * 2 + rowSize;
connectionSettingsGroupBox = CreateGroupBox(margin, sectionBegin, width - 2 * margin,
@@ -186,18 +198,26 @@ namespace ignite
std::string dsn;
std::string address;
std::string cache;
+ std::string pageSizeStr;
nameEdit->GetText(dsn);
addressEdit->GetText(address);
cacheEdit->GetText(cache);
+ pageSizeEdit->GetText(pageSizeStr);
+
+ int32_t pageSize = common::LexicalCast<int32_t>(pageSizeStr);
+
+ if (pageSize <= 0)
+ pageSize = config.GetPageSize();
common::StripSurroundingWhitespaces(address);
common::StripSurroundingWhitespaces(dsn);
LOG_MSG("Retriving arguments:\n");
- LOG_MSG("DSN: %s\n", dsn.c_str());
- LOG_MSG("Address: %s\n", address.c_str());
- LOG_MSG("Cache: %s\n", cache.c_str());
+ LOG_MSG("DSN: %s\n", dsn.c_str());
+ LOG_MSG("Address: %s\n", address.c_str());
+ LOG_MSG("Cache: %s\n", cache.c_str());
+ LOG_MSG("Page size: %d\n", pageSize);
if (dsn.empty())
throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "DSN name can not be empty.");
@@ -205,6 +225,7 @@ namespace ignite
cfg.SetDsn(dsn);
cfg.SetAddress(address);
cfg.SetCache(cache);
+ cfg.SetPageSize(pageSize);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8970b3e3/modules/platforms/cpp/odbc/src/config/configuration.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/config/configuration.cpp b/modules/platforms/cpp/odbc/src/config/configuration.cpp
index f40c74f..74ccaaf 100644
--- a/modules/platforms/cpp/odbc/src/config/configuration.cpp
+++ b/modules/platforms/cpp/odbc/src/config/configuration.cpp
@@ -39,18 +39,19 @@ namespace ignite
const std::string Configuration::Key::server = "server";
const std::string Configuration::Key::port = "port";
const std::string Configuration::Key::protocolVersion = "protocol_version";
+ const std::string Configuration::Key::pageSize = "page_size";
- const std::string Configuration::DefaultValue::dsn = "Apache Ignite DSN";
- const std::string Configuration::DefaultValue::driver = "Apache Ignite";
- const std::string Configuration::DefaultValue::cache = "";
- const std::string Configuration::DefaultValue::address = "";
- const std::string Configuration::DefaultValue::server = "";
+ const std::string Configuration::DefaultValue::dsn = "Apache Ignite DSN";
+ const std::string Configuration::DefaultValue::driver = "Apache Ignite";
+ const std::string Configuration::DefaultValue::cache = "";
+ const std::string Configuration::DefaultValue::address = "";
+ const std::string Configuration::DefaultValue::server = "";
- const uint16_t Configuration::DefaultValue::port = 10800;
+ const uint16_t Configuration::DefaultValue::port = 10800;
+ const int32_t Configuration::DefaultValue::pageSize = 1024;
const ProtocolVersion& Configuration::DefaultValue::protocolVersion = ProtocolVersion::GetCurrent();
-
Configuration::Configuration() :
arguments()
{
@@ -91,11 +92,6 @@ namespace ignite
}
}
- void Configuration::FillFromConnectString(const std::string& str)
- {
- FillFromConnectString(str.data(), str.size());
- }
-
std::string Configuration::ToConnectString() const
{
std::stringstream connect_string_buffer;
@@ -145,11 +141,6 @@ namespace ignite
}
}
- void Configuration::SetTcpPort(uint16_t port)
- {
- arguments[Key::port] = common::LexicalCast<std::string>(port);
- }
-
ProtocolVersion Configuration::GetProtocolVersion() const
{
ArgumentMap::const_iterator it = arguments.find(Key::protocolVersion);
@@ -160,11 +151,6 @@ namespace ignite
return DefaultValue::protocolVersion;
}
- void Configuration::SetProtocolVersion(const std::string& version)
- {
- arguments[Key::protocolVersion] = version;
- }
-
const std::string& Configuration::GetStringValue(const std::string& key, const std::string& dflt) const
{
ArgumentMap::const_iterator it = arguments.find(common::ToLower(key));
@@ -193,8 +179,6 @@ namespace ignite
return dflt;
}
-
-
void Configuration::ParseAttributeList(const char * str, size_t len, char delimeter, ArgumentMap & args)
{
std::string connect_str(str, len);
http://git-wip-us.apache.org/repos/asf/ignite/blob/8970b3e3/modules/platforms/cpp/odbc/src/dsn_config.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/dsn_config.cpp b/modules/platforms/cpp/odbc/src/dsn_config.cpp
index 99635dc..356bcaa 100644
--- a/modules/platforms/cpp/odbc/src/dsn_config.cpp
+++ b/modules/platforms/cpp/odbc/src/dsn_config.cpp
@@ -91,21 +91,27 @@ namespace ignite
void ReadDsnConfiguration(const char* dsn, Configuration& config)
{
std::string address = ReadDsnString(dsn, Configuration::Key::address, config.GetAddress().c_str());
+
std::string server = ReadDsnString(dsn, Configuration::Key::server, config.GetHost().c_str());
+
uint16_t port = ReadDsnInt(dsn, Configuration::Key::port, config.GetTcpPort());
+
std::string cache = ReadDsnString(dsn, Configuration::Key::cache, config.GetCache().c_str());
+
std::string version = ReadDsnString(dsn, Configuration::Key::protocolVersion,
config.GetProtocolVersion().ToString().c_str());
- LOG_MSG("%d\n", __LINE__);
+ int32_t pageSize = ReadDsnInt(dsn, Configuration::Key::pageSize, config.GetPageSize());
+
+ if (pageSize <= 0)
+ pageSize = config.GetPageSize();
config.SetAddress(address);
config.SetHost(server);
config.SetTcpPort(port);
config.SetCache(cache);
config.SetProtocolVersion(version);
-
- LOG_MSG("%d\n", __LINE__);
+ config.SetPageSize(pageSize);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8970b3e3/modules/platforms/cpp/odbc/src/query/data_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/query/data_query.cpp b/modules/platforms/cpp/odbc/src/query/data_query.cpp
index 183bbb5..7a25ccb 100644
--- a/modules/platforms/cpp/odbc/src/query/data_query.cpp
+++ b/modules/platforms/cpp/odbc/src/query/data_query.cpp
@@ -241,7 +241,7 @@ namespace ignite
{
std::auto_ptr<ResultPage> resultPage(new ResultPage());
- QueryFetchRequest req(cursor->GetQueryId(), ResultPage::DEFAULT_SIZE);
+ QueryFetchRequest req(cursor->GetQueryId(), connection.GetConfiguration().GetPageSize());
QueryFetchResponse rsp(*resultPage);
try