Changeset 398 for branches


Ignore:
Timestamp:
02/08/14 09:59:57 (6 years ago)
Author:
jls17
Message:
Location:
branches/work_304/lists
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/work_304/lists/ARSchemaList.cpp

    r397 r398  
    432432        ARZeroMemory(&valueList); 
    433433         
    434         const int NO_MAX_RESULT_LIMIT = 0; 
    435         SchemaDbQueryBuilder queryBuilder(NO_MAX_RESULT_LIMIT); 
    436  
    437         if (ARGetListSQL(&arIn->arControl, const_cast<char*>(queryBuilder.GetNextQuery()), 0, &valueList, &numMatches, &status) == AR_RETURN_OK) 
    438         { 
    439                 StoreDatabaseDetails(valueList); 
    440                 FreeARValueListList(&valueList, false); 
    441                 FreeARStatusList(&status, false); 
    442         } 
    443         else 
    444         { 
    445                 cout << arIn->GetARStatusError(&status); 
     434        SchemaDbQueryBuilder queryBuilder; 
     435        bool keepGettingNextChunk = true; 
     436 
     437        while (keepGettingNextChunk) 
     438        { 
     439                keepGettingNextChunk = false; 
     440                int result = ARGetListSQL(&arIn->arControl, const_cast<char*>(queryBuilder.GetNextQuery()), 0, &valueList, &numMatches, &status); 
     441 
     442                if (result == AR_RETURN_OK || result == AR_RETURN_WARNING) 
     443                { 
     444                        StoreDatabaseDetails(valueList); 
     445 
     446                        if (valueList.numItems > 0 && status.numItems > 0 && status.statusList[0].messageNum == 66) 
     447                        { 
     448                                unsigned int lastReceiveSchemaId = 0; 
     449                                SchemaDbQueryBuilder::TryReadSchemaId(valueList.valueListList[valueList.numItems-1], lastReceiveSchemaId); 
     450                                queryBuilder.SetLastReceivedSchemaId(lastReceiveSchemaId); 
     451                                queryBuilder.SetMaxRetrieve(valueList.numItems); 
     452                                keepGettingNextChunk = true; 
     453                        } 
     454                        FreeARValueListList(&valueList, false); 
     455                        FreeARStatusList(&status, false); 
     456                } 
     457                else 
     458                { 
     459                        cout << arIn->GetARStatusError(&status); 
     460                } 
    446461        } 
    447462} 
  • branches/work_304/lists/support/SchemaDbQueryBuilder.cpp

    r397 r398  
    1818#include "SchemaDbQueryBuilder.h" 
    1919 
    20 SchemaDbQueryBuilder::SchemaDbQueryBuilder(unsigned int maxRetrieve) 
    21 : maxRetrieve(maxRetrieve), lastReceivedSchemaId(0) 
     20SchemaDbQueryBuilder::SchemaDbQueryBuilder() 
     21: maxRetrieve(0), lastReceivedSchemaId(0) 
    2222{ 
    2323} 
     
    3030{ 
    3131        this->lastReceivedSchemaId = schemaId; 
     32} 
     33 
     34void SchemaDbQueryBuilder::SetMaxRetrieve(unsigned int maxRetrieve) 
     35{ 
     36        this->maxRetrieve = maxRetrieve; 
    3237} 
    3338 
  • branches/work_304/lists/support/SchemaDbQueryBuilder.h

    r397 r398  
    2020{ 
    2121public: 
    22         SchemaDbQueryBuilder(unsigned int maxRetrieve); 
     22        SchemaDbQueryBuilder(); 
    2323        ~SchemaDbQueryBuilder(void); 
    2424 
     
    2626        const char* GetNextQuery(); 
    2727        void SetLastReceivedSchemaId(int schemaId); 
     28        void SetMaxRetrieve(unsigned int maxRetrieve); 
    2829 
    2930        static bool TryReadSchemaId(ARValueList &row, unsigned int &schemaId); 
  • branches/work_304/lists/support/SchemaDbQueryBuilderTest.cpp

    r397 r398  
    1515TEST(SchemaDbQueryBuilder, DefaultQueryIfNoMaxRetrieve) 
    1616{ 
    17         SchemaDbQueryBuilder queryBuilder(NO_MAX_RESULT_LIMIT); 
     17        SchemaDbQueryBuilder queryBuilder; 
    1818 
    1919        const char* sql = queryBuilder.GetNextQuery(); 
    2020 
    2121        ASSERT_STREQ(DEFAULT_SQL_STATEMENT_WITHOUT_QUERY, sql); 
     22} 
     23 
     24#define SECOND1000_SQL_STATEMENT_WITH_QUERY (BASE_STATEMENT BASE_QUERY(1122) BASE_ORDER) 
     25TEST(SchemaDbQueryBuilder, QueryAfterSetMaxRetrieve) 
     26{ 
     27        SchemaDbQueryBuilder queryBuilder; 
     28        queryBuilder.GetNextQuery(); 
     29        // .. execute query and work on results, then start next chunk iteration 
     30        queryBuilder.SetMaxRetrieve(1000);           // take the size of the first result (for the test we assume 1000 entries) 
     31        queryBuilder.SetLastReceivedSchemaId(1122); 
     32 
     33        const char* sql = queryBuilder.GetNextQuery(); 
     34 
     35        ASSERT_STREQ(SECOND1000_SQL_STATEMENT_WITH_QUERY, sql); 
    2236} 
    2337 
     
    3549 
    3650        void SetUp() override { 
    37                 queryBuilder = new SchemaDbQueryBuilder(MAX_RESULT); 
     51                queryBuilder = new SchemaDbQueryBuilder(); 
     52                queryBuilder->SetMaxRetrieve(MAX_RESULT); 
    3853        } 
    3954        void TearDown() override { 
     
    7388 
    7489        void SetUp() override { 
    75                 queryBuilder = new SchemaDbQueryBuilder(NO_MAX_RESULT_LIMIT); 
     90                queryBuilder = new SchemaDbQueryBuilder(); 
    7691 
    7792                values[0].dataType = AR_DATA_TYPE_INTEGER; 
Note: See TracChangeset for help on using the changeset viewer.