drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From par...@apache.org
Subject [1/4] drill git commit: DRILL-1533: C++ Drill Client always sets hasSchemaChanged to true for every new record batch
Date Wed, 07 Jan 2015 01:56:26 GMT
Repository: drill
Updated Branches:
  refs/heads/master b491cdb37 -> 363d30b54


DRILL-1533: C++ Drill Client always sets hasSchemaChanged to true for every new record batch


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/07f276d6
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/07f276d6
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/07f276d6

Branch: refs/heads/master
Commit: 07f276d686c99bc6485661ece0425c1a187aa802
Parents: b491cdb
Author: norrislee <norrislee18@hotmail.com>
Authored: Mon Jan 5 15:28:34 2015 -0800
Committer: Parth Chandra <pchandra@maprtech.com>
Committed: Tue Jan 6 09:00:14 2015 -0800

----------------------------------------------------------------------
 .../client/src/clientlib/drillClientImpl.cpp    | 51 +++++++++-----------
 1 file changed, 23 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/07f276d6/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 23dc407..5b390ef 100644
--- a/contrib/native/client/src/clientlib/drillClientImpl.cpp
+++ b/contrib/native/client/src/clientlib/drillClientImpl.cpp
@@ -923,49 +923,44 @@ status_t DrillClientQueryResult::setupColumnDefs(exec::shared::QueryResult*
pQue
     bool isFirstIter=false;
     boost::lock_guard<boost::mutex> schLock(this->m_schemaMutex);
 
-    FieldDefPtr prevSchema=this->m_columnDefs;
     isFirstIter=this->m_numBatches==1?true:false;
     std::map<std::string, Drill::FieldMetadata*> oldSchema;
     if(!m_columnDefs->empty()){
-        for(std::vector<Drill::FieldMetadata*>::iterator it = prevSchema->begin();
it != prevSchema->end(); ++it){
+        for(std::vector<Drill::FieldMetadata*>::iterator it = this->m_columnDefs->begin();
it != this->m_columnDefs->end(); ++it){
             // the key is the field_name + type
             char type[256];
             sprintf(type, ":%d:%d",(*it)->getMinorType(), (*it)->getDataMode() );
             std::string k= (*it)->getName()+type;
             oldSchema[k]=*it;
+            delete *it;
         }
     }
     m_columnDefs->clear();
     size_t numFields=pQueryResult->def().field_size();
-    for(size_t i=0; i<numFields; i++){
-        Drill::FieldMetadata* fmd= new Drill::FieldMetadata;
-        fmd->set(pQueryResult->def().field(i));
-        this->m_columnDefs->push_back(fmd);
-
-        //Look for changes in the vector and trigger a Schema change event if necessary.
-        //If vectors are different, then call the schema change listener.
-        char type[256];
-        sprintf(type, ":%d:%d",fmd->getMinorType(), fmd->getDataMode() );
-        std::string k= fmd->getName()+type;
-        std::map<std::string, Drill::FieldMetadata*>::iterator iter=oldSchema.find(k);
-        if(iter==oldSchema.end()){
-            // not found
-            hasSchemaChanged=true;
-        }else{
-            oldSchema.erase(iter);
+    if (numFields > 0){
+        for(size_t i=0; i<numFields; i++){
+            Drill::FieldMetadata* fmd= new Drill::FieldMetadata;
+            fmd->set(pQueryResult->def().field(i));
+            this->m_columnDefs->push_back(fmd);
+
+            //Look for changes in the vector and trigger a Schema change event if necessary.
+            //If vectors are different, then call the schema change listener.
+            char type[256];
+            sprintf(type, ":%d:%d",fmd->getMinorType(), fmd->getDataMode() );
+            std::string k= fmd->getName()+type;
+            std::map<std::string, Drill::FieldMetadata*>::iterator iter=oldSchema.find(k);
+            if(iter==oldSchema.end()){
+                // not found
+                hasSchemaChanged=true;
+            }else{
+                oldSchema.erase(iter);
+            }
         }
-    }
-    if(oldSchema.size()>0){
-        hasSchemaChanged=true;
-    }
-
-    //free memory allocated for FieldMetadata objects saved in previous columnDefs;
-    if(!prevSchema->empty()){
-        for(std::vector<Drill::FieldMetadata*>::iterator it = prevSchema->begin();
it != prevSchema->end(); ++it){
-            delete *it;
+        if(oldSchema.size()>0){
+            hasSchemaChanged=true;
+            oldSchema.clear();
         }
     }
-    prevSchema->clear();
     this->m_bHasSchemaChanged=hasSchemaChanged&&!isFirstIter;
     if(this->m_bHasSchemaChanged){
         //invoke schema change Listener


Mime
View raw message