-
Notifications
You must be signed in to change notification settings - Fork 15
ENG-15036 add c-client to voltdb-client-cpp #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
boost::atomic and boost::memory_order_*, mutex and locks.
By using C++11 features, and copying 2 boost header files over. Clean up make file and README.
And proof-read/formated README.md
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
struct c_client; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't a prefix of voltdb or something like that be better for name spacing and readability than c_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like a c_
prefix to differentiate from C++ world. Yes, I think voltdb
is necessary in the name in case some other DB client is linked to the executable. So I'll change it to c_voltdb_client
and the same for the rest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I have explained previously, I will vote against the c_
prefix. Everything in C++ used the camel case and was under the voltdb
namespace, which I think was different enough from C functions. I would recommend not to complicate the naming.
@@ -163,7 +162,7 @@ class ClientImpl { | |||
/* | |||
* Initiate connection based on pending connection instance | |||
*/ | |||
void initiateConnection(boost::shared_ptr<PendingConnection> &pc) throw (ConnectException, LibEventException, SSLException); | |||
void initiateConnection(std::shared_ptr<PendingConnection> &pc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this change break backwards compatibility with the previous public client API? When is it OK to break backwards compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does. But I think using C++ STL is the preferred way over 3rd party dependencies.
I'll note this in the README.build
file, and poll other's opinion on this.
/*voltdb::ClientAuthHashScheme schema,*/ bool enableAbandon, bool enableTimeout, | ||
int timeoutInSec, bool useSSL) { | ||
voltdb::ClientConfig* client_config = new voltdb::ClientConfig( | ||
usrname, pwd, voltdb::HASH_SHA1/*schema*/, enableAbandon, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought SHA1 was deprecated for hashing in volt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to change it back to an argument. To be consistent with C++ method argument list. Thanks for the reminder.
int c_status_code(struct c_invocation_response*); | ||
void c_destroy_response(struct c_invocation_response*); | ||
|
||
struct c_stringified_table { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the client has no way of know what data type each column is and just would have to deal with the string representation of the column which is not very flexible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Supporting all column types would be some extra work, especially with memory management for the C++ world (and all the typings).
I created a follow-up ticket ENG-15044 to track this.
c_stringified_table* tables; | ||
}; | ||
|
||
c_stringified_tables* c_exec_result(struct c_invocation_response*); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really any execution it is more of a conversion to strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it's just getting result tuples from invocation response. Maybe a better name would be c_voltdb_get_execution_result
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, too long.
voltdb::ClientConfig* client_config = new voltdb::ClientConfig( | ||
usrname, pwd, voltdb::HASH_SHA1/*schema*/, enableAbandon, | ||
enableTimeout, timeoutInSec, useSSL); | ||
voltdb::Client* client = new voltdb::Client(new voltdb::ClientImpl(*client_config)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this or any other C++ call throws an exception a C program or anything using the C wrapper wouldn't handle the exception and I think it would be ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, which I chose to ignore but shouldn't.
I'll use NULL with errno to address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you have to expose the ClientImpl
class?
It was used to be voltdb::Client client = voltdb::Client::create(config);
@@ -46,7 +23,7 @@ version of libevent - simply replace the libevent tarball. | |||
Running the tests | |||
|
|||
The tests require CPPUnit. You can install cppunit on ubuntu with the | |||
command: `apt get install libcppunit-dev` | |||
command: `apt-get install libcppunit-dev` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More likely people need to add sudo
to use this command.
Plus, apt get
without the dash is a legitimate way to call.
This file was not written using MarkDown. If we do not intend to do so, we shouldn't use `
@@ -16,14 +16,26 @@ The Linux binary was compiled with GCC 4.4.7 on Centos 6.7. | |||
The OSX binary was compiled with Xcode 7.2 on OSX 10.11. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OS X
XCode
|
||
New Features in 8.4 | ||
================== | ||
- Removed dependency on Boost library (by taking advantage of C++11 features) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Removed dependency on Boost library (by taking advantage of C++11 features) | |
- Removed the dependency on the Boost library (by taking advantage of C++11 features) |
================== | ||
- Removed dependency on Boost library (by taking advantage of C++11 features) | ||
|
||
- Added a C wrapper for a few functions to support synchronous execution of Ad-Hoc query. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Added a C wrapper for a few functions to support synchronous execution of Ad-Hoc query. | |
- Added a C wrapper for a few functions to support synchronous execution of Ad-Hoc queries. |
needs to be instantiated using client config (voltdb::ClientConfig) with the ssl field (m_useSSL) set to true. Code | ||
snippet: | ||
|
||
- Add SSL support to C++ client to enable communication between VoltDB server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add SSL support to C++ client to enable communication between VoltDB server | |
- Added the SSL support to enable communications with a VoltDB server |
|
||
c_procedure* c_create_procedure(const char* name, | ||
int nparams, voltdb::Parameter* params) { | ||
c_procedure* proc = new c_procedure; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c_procedure* proc = new c_procedure; | |
ProcCall* proc = new ProcCall; |
fprintf(stderr, "Client is null\n"); | ||
} | ||
if (proc == nullptr) { | ||
fprintf(stderr, "Procedure is null\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fprintf(stderr, "Procedure is null\n"); | |
fprintf(stderr, "Procedure call is null\n"); |
} | ||
|
||
c_invocation_response* c_exec_adhoc(struct c_client* client, struct c_procedure* proc, const char* param) { | ||
const char* params[] = {param, nullptr}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the nullptr
here?
@@ -26,7 +26,7 @@ | |||
|
|||
namespace voltdb { | |||
|
|||
Client Client::create(ClientConfig config) throw (voltdb::Exception, voltdb::LibEventException) { | |||
Client Client::create(ClientConfig config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why didn't you use this factory method but exposed the ClientImpl
? What was the benefit?
@@ -194,7 +190,7 @@ void Distributer::updateAffinityTopology(const std::vector<voltdb::Table>& topoT | |||
const std::string hashMode = hashRow.getString(0); | |||
//Check if token ring is correct | |||
if (hashMode.compare("ELASTIC") == 0 ) { | |||
boost::scoped_array<char> tokens(new char[realsize]); | |||
std::unique_ptr<char[]> tokens(new char[realsize]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spacing
Innovation project follow-up: a simple C-wrapper for the C++ client.
Together included are:
include/
directory. Therefore, building the client no longer needs Boost library.