aboutsummaryrefslogtreecommitdiff
path: root/contrib/native
diff options
context:
space:
mode:
authorAlexander Zarei <azarei@ece.ubc.ca>2014-08-07 16:32:00 -0700
committerSteven Phillips <sphillips@maprtech.com>2014-09-29 18:21:46 -0700
commit4862b2b08bf16e9ef8906d257bf547a948939517 (patch)
treeba35cf9c85f79208617d32e105d7484caa44f504 /contrib/native
parentef254649f89617e792a45a3c66d9340b82efa048 (diff)
DRILL-1297: C++ Client. Hide Dependencies From Public API to enable using C++ Client as a DLL
Diffstat (limited to 'contrib/native')
-rw-r--r--contrib/native/client/example/querySubmitter.cpp10
-rw-r--r--contrib/native/client/readme.win.txt25
-rwxr-xr-xcontrib/native/client/scripts/cpProtofiles.sh2
-rw-r--r--contrib/native/client/src/clientlib/drillClient.cpp11
-rw-r--r--contrib/native/client/src/clientlib/recordBatch.cpp33
-rw-r--r--contrib/native/client/src/include/drill/drillClient.hpp25
-rw-r--r--contrib/native/client/src/include/drill/drillc.hpp1
-rw-r--r--contrib/native/client/src/include/drill/recordBatch.hpp36
-rw-r--r--contrib/native/client/src/protobuf/CMakeLists.txt2
-rw-r--r--contrib/native/client/src/protobuf/User.pb.h (renamed from contrib/native/client/src/include/drill/protobuf/User.pb.h)0
10 files changed, 96 insertions, 49 deletions
diff --git a/contrib/native/client/example/querySubmitter.cpp b/contrib/native/client/example/querySubmitter.cpp
index 9feb61d8d..f886e819f 100644
--- a/contrib/native/client/example/querySubmitter.cpp
+++ b/contrib/native/client/example/querySubmitter.cpp
@@ -253,7 +253,7 @@ int main(int argc, char* argv[]) {
std::string logLevel=qsOptionValues["logLevel"];
std::string testCancel=qsOptionValues["testCancel"];
- exec::shared::QueryType type;
+ Drill::QueryType type;
if(!validate(type_str, queryList, planList)){
exit(1);
@@ -264,16 +264,16 @@ int main(int argc, char* argv[]) {
std::vector<std::string> queryInputs;
if(type_str=="sql" ){
readQueries(queryList, queryInputs);
- type=exec::shared::SQL;
+ type=Drill::SQL;
}else if(type_str=="physical" ){
readPlans(planList, queryInputs);
- type=exec::shared::PHYSICAL;
+ type=Drill::PHYSICAL;
}else if(type_str == "logical"){
readPlans(planList, queryInputs);
- type=exec::shared::LOGICAL;
+ type=Drill::LOGICAL;
}else{
readQueries(queryList, queryInputs);
- type=exec::shared::SQL;
+ type=Drill::SQL;
}
bTestCancel = !strcmp(testCancel.c_str(), "true")?true:false;
diff --git a/contrib/native/client/readme.win.txt b/contrib/native/client/readme.win.txt
index df6ee6443..f1fdef852 100644
--- a/contrib/native/client/readme.win.txt
+++ b/contrib/native/client/readme.win.txt
@@ -35,6 +35,7 @@ Windows platforms should be more or less similar.
Note: For 64 bit builds, change the platform toolset to Windows SDK for your
project.
(Root node, i.e. the projectname) Properties ->Configuration Properties->General->Platform Toolset = Windows7.1SDK
+ If you are running Windows 7 and having problem isntalling windows SDK follow the instructions here http://stackoverflow.com/questions/19366006/error-when-installing-windows-sdk-7-1
1.3 [Optional] Windows Driver kit
The Windows Driver kit is required to get the 64 bit assembler ml64. The
@@ -76,7 +77,9 @@ Windows platforms should be more or less similar.
2.1 Boost (version 1.55)
a) Download Boost from:
- http://www.boost.org/users/history/version_1_55_0.html
+ i) http://www.boost.org/users/history/version_1_55_0.html
+ ii) open boost_1_55_0\boost/archive/iterators/transform_width.hpp and add the following to the include statements: #include <algorithm>
+ iii) Yes somehow this header was not included and has been missed! See here for more info: https://svn.boost.org/trac/boost/ticket/8757
b) i) Boost 32 bit build -
Open a Visual Studio command prompt from the Visual Studio IDE
ii) Boost 64 bit build -
@@ -89,19 +92,19 @@ Windows platforms should be more or less similar.
and build the libraries. Boost build will write the libraries to
<BOOST_HOME>/stage/lib. Copy them to an appropriately named directory
- C:> .\b2 variant=debug link=static threading=multi address-model=64 toolset=msvc runtime-link=shared
+ C:> .\b2 variant=debug link=static threading=multi address-model=64 toolset=msvc-10.0 runtime-link=shared
C:> mkdir Debug64
C:> copy stage\lib\* Debug64
- C:> .\b2 variant=release link=static threading=multi address-model=64 toolset=msvc runtime-link=shared
+ C:> .\b2 variant=release link=static threading=multi address-model=64 toolset=msvc-10.0 runtime-link=shared
C:> mkdir Release64
C:> copy stage\lib\* Release64
- C:> .\b2 variant=debug link=static threading=multi address-model=32 toolset=msvc runtime-link=shared
+ C:> .\b2 variant=debug link=static threading=multi address-model=32 toolset=msvc-10.0 runtime-link=shared
C:> mkdir Debug32
C:> copy stage\lib\* Debug32
- C:> .\b2 variant=release link=static threading=multi address-model=32 toolset=msvc runtime-link=shared
+ C:> .\b2 variant=release link=static threading=multi address-model=32 toolset=msvc-10.0 runtime-link=shared
C:> mkdir Release32
C:> copy stage\lib\* Release32
e) Notes:
@@ -113,12 +116,16 @@ Windows platforms should be more or less similar.
build. It is safe to ignore it as boost-context is not needed for Drill
2.2 Protobuf (2.5.0)
+ Get protobuf from here: https://protobuf.googlecode.com/files/protobuf-2.5.0.zip
+
+
a) Protobuf builds static libraries
b) In Visual Studio, open <PROTOBUF_HOME>/vsprojects/protobuf.sln. The IDE may
update the solution file. This should go thru successfully.
c) If build for 64 bit, add a 64 bit project configuration for each project. (Make sure the
platform toolset is set to Windows7.1SDK)
- d) Build
+ d) Build the protobuf project first (not the solution)
+ e) Build the solution!
2.3 Zookeeper (3.4.6)
a) Set the ZOOKEEPER_HOME environment variable
@@ -132,7 +139,7 @@ Windows platforms should be more or less similar.
ii) Change the output type for the zookeeper project to a static lib
Properties->Configuration Properties->General->Configuration Type = Static Library
iii) In the cli project add the preprocessor define USE_STATIC_LIB
- iiii) Build. Build zookeeper lib first, then build cli
+ iv) Build. Build zookeeper lib first, then build cli
3 Building Drill Clientlib
3.1 SET the following environment variables
@@ -176,4 +183,6 @@ Windows platforms should be more or less similar.
Check the libraries are all the same as your configuration (all debug, or all
release).
In particular, for debug builds, check the path of the protobuf library.
-
+
+5 Testing with querySubmitter
+querySubmitter query="select * from INFORMAITON_SCHEMA.SCHEMATA" type=sql connectStr=local=192.168.39.43:31010 api=sync logLevel=trace \ No newline at end of file
diff --git a/contrib/native/client/scripts/cpProtofiles.sh b/contrib/native/client/scripts/cpProtofiles.sh
index 4b0df36e1..1e2d01e3a 100755
--- a/contrib/native/client/scripts/cpProtofiles.sh
+++ b/contrib/native/client/scripts/cpProtofiles.sh
@@ -40,8 +40,6 @@ main() {
fi
mv ${TARGDIR}/Types.pb.h ${INCDIR}
- mv ${TARGDIR}/User.pb.h ${INCDIR}
-
}
main
diff --git a/contrib/native/client/src/clientlib/drillClient.cpp b/contrib/native/client/src/clientlib/drillClient.cpp
index a7aafaa06..db7d5a868 100644
--- a/contrib/native/client/src/clientlib/drillClient.cpp
+++ b/contrib/native/client/src/clientlib/drillClient.cpp
@@ -276,15 +276,18 @@ void DrillClient::close() {
this->m_pImpl->Close();
}
-status_t DrillClient::submitQuery(::exec::shared::QueryType t, const std::string& plan, pfnQueryResultsListener listener, void* listenerCtx, QueryHandle_t* qHandle){
- DrillClientQueryResult* pResult=this->m_pImpl->SubmitQuery(t, plan, listener, listenerCtx);
+status_t DrillClient::submitQuery(Drill::QueryType t, const std::string& plan, pfnQueryResultsListener listener, void* listenerCtx, QueryHandle_t* qHandle){
+
+ ::exec::shared::QueryType castedType = static_cast<::exec::shared::QueryType> (t);
+ DrillClientQueryResult* pResult=this->m_pImpl->SubmitQuery(castedType, plan, listener, listenerCtx);
*qHandle=(QueryHandle_t)pResult;
return QRY_SUCCESS;
}
-RecordIterator* DrillClient::submitQuery(::exec::shared::QueryType t, const std::string& plan, DrillClientError* err){
+RecordIterator* DrillClient::submitQuery(Drill::QueryType t, const std::string& plan, DrillClientError* err){
RecordIterator* pIter=NULL;
- DrillClientQueryResult* pResult=this->m_pImpl->SubmitQuery(t, plan, NULL, NULL);
+ ::exec::shared::QueryType castedType = static_cast<::exec::shared::QueryType> (t);
+ DrillClientQueryResult* pResult=this->m_pImpl->SubmitQuery(castedType, plan, NULL, NULL);
if(pResult){
pIter=new RecordIterator(pResult);
}
diff --git a/contrib/native/client/src/clientlib/recordBatch.cpp b/contrib/native/client/src/clientlib/recordBatch.cpp
index 4c55f0482..dfa12fd05 100644
--- a/contrib/native/client/src/clientlib/recordBatch.cpp
+++ b/contrib/native/client/src/clientlib/recordBatch.cpp
@@ -19,6 +19,7 @@
#include "drill/common.hpp"
#include "drill/recordBatch.hpp"
#include "utils.hpp"
+#include "../protobuf/User.pb.h"
const int32_t YEARS_TO_MONTHS=12;
const int32_t DAYS_TO_MILLIS=24*60*60*1000;
@@ -300,6 +301,18 @@ ret_t FieldBatch::load(){
return RET_SUCCESS;
}
+RecordBatch::RecordBatch(exec::shared::QueryResult* pResult, AllocatedBufferPtr r, ByteBuf_t b)
+ :m_fieldDefs(new(std::vector<Drill::FieldMetadata*>)){
+ m_pQueryResult=pResult;
+ m_pRecordBatchDef=&pResult->def();
+ m_numRecords=pResult->row_count();
+ m_allocatedBuffer=r;
+ m_buffer=b;
+ m_numFields=pResult->def().field_size();
+ m_bHasSchemaChanged=false;
+}
+
+
RecordBatch::~RecordBatch(){
m_buffer=NULL;
//free memory allocated for FieldBatch objects saved in m_fields;
@@ -369,6 +382,26 @@ void RecordBatch::print(std::ostream& s, size_t num){
s<<values<<std::endl;
}
}
+size_t RecordBatch::getNumFields(){
+ return m_pRecordBatchDef->field_size();
+}
+
+bool RecordBatch::isLastChunk(){
+ return m_pQueryResult->is_last_chunk();
+}
+
+
+
+void FieldMetadata::set(const exec::shared::SerializedField& f){
+ m_name=f.name_part().name();
+ m_minorType=f.major_type().minor_type();
+ m_dataMode=f.major_type().mode();
+ m_valueCount=f.value_count();
+ m_scale=f.major_type().scale();
+ m_precision=f.major_type().precision();
+ m_bufferLength=f.buffer_length();
+}
+
void DateHolder::load(){
m_year=1970;
diff --git a/contrib/native/client/src/include/drill/drillClient.hpp b/contrib/native/client/src/include/drill/drillClient.hpp
index d03f88dad..f1369ee74 100644
--- a/contrib/native/client/src/include/drill/drillClient.hpp
+++ b/contrib/native/client/src/include/drill/drillClient.hpp
@@ -23,7 +23,7 @@
#include <vector>
#include <boost/thread.hpp>
#include "drill/common.hpp"
-#include "drill/protobuf/User.pb.h"
+#include "drill/protobuf/Types.pb.h"
#if defined _WIN32 || defined __CYGWIN__
@@ -44,7 +44,14 @@
#endif
#endif
-namespace Drill {
+namespace exec{
+ namespace shared{
+ class DrillPBError;
+ enum QueryType;
+ };
+};
+
+namespace Drill{
//struct UserServerEndPoint;
class DrillClientImpl;
@@ -53,6 +60,12 @@ class FieldMetadata;
class RecordBatch;
class SchemaDef;
+enum QueryType{
+ SQL = 1,
+ LOGICAL = 2,
+ PHYSICAL = 3
+};
+
class DECLSPEC_DRILL_CLIENT DrillClientError{
public:
static const uint32_t CONN_ERROR_START = 100;
@@ -222,16 +235,16 @@ class DECLSPEC_DRILL_CLIENT DrillClient{
void close() ;
/*
- * Submit a query asynchronously and wait for results to be returned thru a callback. A query context handle is passed
+ * Submit a query asynchronously and wait for results to be returned through a callback. A query context handle is passed
* back. The listener callback will return the handle in the ctx parameter.
*/
- status_t submitQuery(::exec::shared::QueryType t, const std::string& plan, pfnQueryResultsListener listener, void* listenerCtx, QueryHandle_t* qHandle);
+ status_t submitQuery(Drill::QueryType t, const std::string& plan, pfnQueryResultsListener listener, void* listenerCtx, QueryHandle_t* qHandle);
/*
- * Submit a query asynchronously and wait for results to be returned thru an iterator that returns
+ * Submit a query asynchronously and wait for results to be returned through an iterator that returns
* results synchronously. The client app needs to call delete on the iterator when done.
*/
- RecordIterator* submitQuery(::exec::shared::QueryType t, const std::string& plan, DrillClientError* err);
+ RecordIterator* submitQuery(Drill::QueryType t, const std::string& plan, DrillClientError* err);
/*
* The client application should call this function to wait for results if it has registered a
diff --git a/contrib/native/client/src/include/drill/drillc.hpp b/contrib/native/client/src/include/drill/drillc.hpp
index 93a6b79d3..3697ee8cd 100644
--- a/contrib/native/client/src/include/drill/drillc.hpp
+++ b/contrib/native/client/src/include/drill/drillc.hpp
@@ -23,7 +23,6 @@
#include "drill/drillClient.hpp"
#include "drill/recordBatch.hpp"
#include "drill/protobuf/Types.pb.h"
-#include "drill/protobuf/User.pb.h"
#endif
diff --git a/contrib/native/client/src/include/drill/recordBatch.hpp b/contrib/native/client/src/include/drill/recordBatch.hpp
index 61db88c8c..1c89cea2a 100644
--- a/contrib/native/client/src/include/drill/recordBatch.hpp
+++ b/contrib/native/client/src/include/drill/recordBatch.hpp
@@ -30,7 +30,8 @@
#include <boost/lexical_cast.hpp>
#include "drill/common.hpp"
#include "drill/decimalUtils.hpp"
-#include "drill/protobuf/User.pb.h"
+#include "drill/protobuf/Types.pb.h"
+
#if defined _WIN32 || defined __CYGWIN__
#ifdef DRILL_CLIENT_EXPORTS
@@ -50,6 +51,13 @@
#endif
#endif
+namespace exec{
+ namespace shared {
+ class SerializedField;
+ class RecordBatchDef;
+ class QueryResult;
+ };
+};
namespace Drill {
@@ -759,16 +767,9 @@ typedef NullableValueVectorTyped<IntervalYearHolder, ValueVectorIntervalYear> N
class DECLSPEC_DRILL_CLIENT FieldMetadata{
public:
+
FieldMetadata(){};
- void set(const exec::shared::SerializedField& f){
- m_name=f.name_part().name();
- m_minorType=f.major_type().minor_type();
- m_dataMode=f.major_type().mode();
- m_valueCount=f.value_count();
- m_scale=f.major_type().scale();
- m_precision=f.major_type().precision();
- m_bufferLength=f.buffer_length();
- }
+ void set(const exec::shared::SerializedField& f);
const std::string& getName() const{ return m_name;}
common::MinorType getMinorType() const{ return m_minorType;}
common::DataMode getDataMode() const{return m_dataMode;}
@@ -839,16 +840,7 @@ class DECLSPEC_DRILL_CLIENT RecordBatch{
//m_allocatedBuffer is the memory block allocated to hold the incoming RPC message. Record Batches operate on
//slices of the allocated buffer. The first slice (the first Field Batch), begins at m_buffer. Data in the
//allocated buffer before m_buffer is mostly the RPC header, and the QueryResult object.
- RecordBatch(exec::shared::QueryResult* pResult, AllocatedBufferPtr r, ByteBuf_t b)
- :m_fieldDefs(new(std::vector<Drill::FieldMetadata*>)){
- m_pQueryResult=pResult;
- m_pRecordBatchDef=&pResult->def();
- m_numRecords=pResult->row_count();
- m_allocatedBuffer=r;
- m_buffer=b;
- m_numFields=pResult->def().field_size();
- m_bHasSchemaChanged=false;
- }
+ RecordBatch(exec::shared::QueryResult* pResult, AllocatedBufferPtr r, ByteBuf_t b);
~RecordBatch();
@@ -860,8 +852,8 @@ class DECLSPEC_DRILL_CLIENT RecordBatch{
size_t getNumRecords(){ return m_numRecords;}
std::vector<FieldBatch*>& getFields(){ return m_fields;}
- size_t getNumFields() { return m_pRecordBatchDef->field_size(); }
- bool isLastChunk() { return m_pQueryResult->is_last_chunk(); }
+ size_t getNumFields();
+ bool isLastChunk();
boost::shared_ptr<std::vector<Drill::FieldMetadata*> > getColumnDefs(){ return m_fieldDefs;}
diff --git a/contrib/native/client/src/protobuf/CMakeLists.txt b/contrib/native/client/src/protobuf/CMakeLists.txt
index 1d0b3af1b..474d2f63f 100644
--- a/contrib/native/client/src/protobuf/CMakeLists.txt
+++ b/contrib/native/client/src/protobuf/CMakeLists.txt
@@ -58,13 +58,13 @@ set (PROTO_CPPHDR_FILES
${PROTO_HDR_DIR}/BitData.pb.h
${PROTO_HDR_DIR}/ExecutionProtos.pb.h
${PROTO_HDR_DIR}/SchemaDef.pb.h
+ ${PROTO_HDR_DIR}/User.pb.h
)
set (PROTO_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include/drill/protobuf)
set (PROTO_CPPINC_FILES
${PROTO_INC_DIR}/Types.pb.h
- ${PROTO_INC_DIR}/User.pb.h
)
set(ProtoIncludes ${PROTO_CPPINC_FILES} )
diff --git a/contrib/native/client/src/include/drill/protobuf/User.pb.h b/contrib/native/client/src/protobuf/User.pb.h
index eca199dc0..eca199dc0 100644
--- a/contrib/native/client/src/include/drill/protobuf/User.pb.h
+++ b/contrib/native/client/src/protobuf/User.pb.h