You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by jn...@apache.org on 2014/11/08 01:03:03 UTC
[02/16] incubator-drill git commit: DRILL-1566: C++ Client does not
handle incoming record batches with zero records
DRILL-1566: C++ Client does not handle incoming record batches with zero records
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/fdbd6a9f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/fdbd6a9f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/fdbd6a9f
Branch: refs/heads/master
Commit: fdbd6a9fc8d846567a272025bd37002d43c7a3fa
Parents: 2e07c62
Author: Parth Chandra <pc...@maprtech.com>
Authored: Tue Oct 21 14:30:50 2014 -0700
Committer: Jinfeng Ni <jn...@maprtech.com>
Committed: Fri Nov 7 10:50:55 2014 -0800
----------------------------------------------------------------------
contrib/native/client/example/querySubmitter.cpp | 2 +-
contrib/native/client/src/clientlib/drillClientImpl.cpp | 12 +++++++++---
contrib/native/client/src/clientlib/recordBatch.cpp | 5 ++++-
contrib/native/client/src/include/drill/recordBatch.hpp | 6 ++++--
4 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fdbd6a9f/contrib/native/client/example/querySubmitter.cpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/example/querySubmitter.cpp b/contrib/native/client/example/querySubmitter.cpp
index 040f9d7..7b98bc9 100644
--- a/contrib/native/client/example/querySubmitter.cpp
+++ b/contrib/native/client/example/querySubmitter.cpp
@@ -71,7 +71,7 @@ Drill::status_t QueryResultsListener(void* ctx, Drill::RecordBatch* b, Drill::Dr
if(bTestCancel){
return Drill::QRY_FAILURE;
}else{
- return Drill::QRY_SUCCESS ;
+ return Drill::QRY_SUCCESS ;
}
}else{
assert(b==NULL);
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fdbd6a9f/contrib/native/client/src/clientlib/drillClientImpl.cpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/clientlib/drillClientImpl.cpp b/contrib/native/client/src/clientlib/drillClientImpl.cpp
index 2f27b48..cc70020 100644
--- a/contrib/native/client/src/clientlib/drillClientImpl.cpp
+++ b/contrib/native/client/src/clientlib/drillClientImpl.cpp
@@ -509,8 +509,10 @@ status_t DrillClientImpl::processQueryResult(AllocatedBufferPtr allocatedBuffer
// Ignore these state messages since they means the query is not completed.
// I have not observed those messages in testing though.
break;
+
// m_pendingRequests should be decremented when the query is
- // canncelled or completed
+ // canceled or completed
+ // in both cases, fall back to free mememory
case exec::shared::QueryResult_QueryState_CANCELED:
ret=handleTerminatedQryState(ret,
getMessage(ERR_QRY_CANCELED),
@@ -519,7 +521,6 @@ status_t DrillClientImpl::processQueryResult(AllocatedBufferPtr allocatedBuffer
ret=handleTerminatedQryState(ret,
getMessage(ERR_QRY_COMPLETED),
pDrillClientQueryResult);
- // in both case, fall back to free mememory
delete allocatedBuffer;
delete qr;
break;
@@ -534,6 +535,8 @@ status_t DrillClientImpl::processQueryResult(AllocatedBufferPtr allocatedBuffer
break;
}
return ret;
+ }else{
+ DRILL_LOG(LOG_WARNING) << "DrillClientImpl::processQueryResult: Query State was not set (assuming a query with no result set.\n";
}
//Validate the RPC message
@@ -562,7 +565,9 @@ status_t DrillClientImpl::processQueryResult(AllocatedBufferPtr allocatedBuffer
<< pRecordBatch->isLastChunk() << std::endl;
ret=pDrillClientQueryResult->setupColumnDefs(qr);
- if(ret==QRY_SUCCESS_WITH_INFO)pRecordBatch->schemaChanged(true);
+ if(ret==QRY_SUCCESS_WITH_INFO){
+ pRecordBatch->schemaChanged(true);
+ }
pDrillClientQueryResult->m_bIsQueryPending=true;
pDrillClientQueryResult->m_bIsLastChunk=qr->is_last_chunk();
@@ -781,6 +786,7 @@ void DrillClientImpl::broadcastError(DrillClientError* pErr){
}
return;
}
+
// The implementation is similar to handleQryError
status_t DrillClientImpl::handleTerminatedQryState(
status_t status,
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fdbd6a9f/contrib/native/client/src/clientlib/recordBatch.cpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/clientlib/recordBatch.cpp b/contrib/native/client/src/clientlib/recordBatch.cpp
index dfa12fd..2a679fa 100644
--- a/contrib/native/client/src/clientlib/recordBatch.cpp
+++ b/contrib/native/client/src/clientlib/recordBatch.cpp
@@ -346,7 +346,10 @@ ret_t RecordBatch::build(){
size_t len=pFmd->getBufferLength();
FieldBatch* pField = new FieldBatch(*pFmd, this->m_buffer, startOffset, len) ;
startOffset+=len;
- pField->load(); // set up the value vectors
+ // We may get an empty record batch. All the fields will be empty, except for metadata.
+ if(len>0){
+ pField->load(); // set up the value vectors
+ }
this->m_fields.push_back(pField);
this->m_fieldDefs->push_back(pFmd);
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fdbd6a9f/contrib/native/client/src/include/drill/recordBatch.hpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/include/drill/recordBatch.hpp b/contrib/native/client/src/include/drill/recordBatch.hpp
index de65202..28377cb 100644
--- a/contrib/native/client/src/include/drill/recordBatch.hpp
+++ b/contrib/native/client/src/include/drill/recordBatch.hpp
@@ -804,8 +804,10 @@ class FieldBatch{
public:
FieldBatch(const Drill::FieldMetadata& fmd, const ByteBuf_t data, size_t start, size_t length):
m_fieldMetadata(fmd){
- m_pValueVector=NULL;
- m_pFieldData=new SlicedByteBuf(data, start, length);
+ m_pValueVector=NULL;m_pFieldData=NULL;
+ if(length>0){
+ m_pFieldData=new SlicedByteBuf(data, start, length);
+ }
}
~FieldBatch(){