LcsClusterAppendExecStreamTest.cpp

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/lucidera/test/LcsClusterAppendExecStreamTest.cpp#24 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 LucidEra, Inc.
00005 // Copyright (C) 2005-2009 The Eigenbase Project
00006 //
00007 // This program is free software; you can redistribute it and/or modify it
00008 // under the terms of the GNU General Public License as published by the Free
00009 // Software Foundation; either version 2 of the License, or (at your option)
00010 // any later version approved by The Eigenbase Project.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this program; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 */
00021 
00022 #include "fennel/common/CommonPreamble.h"
00023 #include "fennel/test/ExecStreamUnitTestBase.h"
00024 #include "fennel/lucidera/colstore/LcsClusterAppendExecStream.h"
00025 #include "fennel/lucidera/colstore/LcsClusterDump.h"
00026 #include "fennel/lucidera/colstore/LcsClusterVerifier.h"
00027 #include "fennel/lucidera/colstore/LcsRowScanExecStream.h"
00028 #include "fennel/btree/BTreeBuilder.h"
00029 #include "fennel/ftrs/BTreeInsertExecStream.h"
00030 #include "fennel/ftrs/BTreeSearchExecStream.h"
00031 #include "fennel/ftrs/BTreeExecStream.h"
00032 #include "fennel/tuple/StandardTypeDescriptor.h"
00033 #include "fennel/exec/MockProducerExecStream.h"
00034 #include "fennel/exec/ValuesExecStream.h"
00035 #include "fennel/exec/ExecStreamEmbryo.h"
00036 #include "fennel/exec/DynamicParam.h"
00037 #include "fennel/cache/Cache.h"
00038 #include "fennel/common/TraceSource.h"
00039 #include <stdarg.h>
00040 
00041 #include <boost/test/test_tools.hpp>
00042 
00043 using namespace fennel;
00044 
00045 class LcsClusterAppendExecStreamTest : public ExecStreamUnitTestBase
00046 {
00047 protected:
00048     StandardTypeDescriptorFactory stdTypeFactory;
00049     TupleAttributeDescriptor attrDesc_int64;
00050     TupleAttributeDescriptor attrDesc_bitmap;
00051 
00052     PageId  savedRootPageId;
00053     BTreeDescriptor btreeDescriptor;
00054 
00055     void testLoadSingleCol(
00056         uint nRows,
00057         uint startRid,
00058         bool newRoot,
00059         SharedMockProducerExecStreamGenerator pGeneratorInit,
00060         std::string testName = "LcsClusterAppendExecStreamTest");
00061 
00062     void testLoadMultiCol(
00063         uint nRows,
00064         uint nCols,
00065         bool newRoot,
00066         SharedMockProducerExecStreamGenerator pGeneratorInit,
00067         std::string testName = "LcsClusterAppendExecStreamTest");
00068 
00069     void verifyClusterPages(std::string testName, uint nCols);
00070 
00071     void testScanSingleCol(
00072         uint nrows,
00073         SharedMockProducerExecStreamGenerator pGeneratorInit,
00074         SharedMockProducerExecStreamGenerator pResultGenerator);
00075 
00076     void setUpDelIndexScan(ExecStreamEmbryo &valuesStreamEmbryo);
00077 
00078     void testScanMultiCol(
00079         uint nrows,
00080         uint nCols,
00081         SharedMockProducerExecStreamGenerator pGeneratorInit,
00082         SharedMockProducerExecStreamGenerator pResultGenerator);
00083 
00084 public:
00085     explicit LcsClusterAppendExecStreamTest()
00086     {
00087         FENNEL_UNIT_TEST_CASE(
00088             LcsClusterAppendExecStreamTest,
00089             testSingleColNoDupNewRoot);
00090         FENNEL_UNIT_TEST_CASE(
00091             LcsClusterAppendExecStreamTest,
00092             testSingleColNoDupOldRoot);
00093         FENNEL_UNIT_TEST_CASE(
00094             LcsClusterAppendExecStreamTest,
00095             testSingleColConstNewRoot);
00096         FENNEL_UNIT_TEST_CASE(
00097             LcsClusterAppendExecStreamTest,
00098             testSingleColConstOldRoot);
00099         FENNEL_UNIT_TEST_CASE(
00100             LcsClusterAppendExecStreamTest,
00101             testSingleColStairNewRoot);
00102         FENNEL_UNIT_TEST_CASE(
00103             LcsClusterAppendExecStreamTest,
00104             testSingleColStairOldRoot);
00105 
00106         FENNEL_UNIT_TEST_CASE(
00107             LcsClusterAppendExecStreamTest,
00108             testMultiColNoDupNewRoot);
00109         FENNEL_UNIT_TEST_CASE(
00110             LcsClusterAppendExecStreamTest,
00111             testMultiColNoDupOldRoot);
00112         FENNEL_UNIT_TEST_CASE(
00113             LcsClusterAppendExecStreamTest,
00114             testMultiColConstNewRoot);
00115         FENNEL_UNIT_TEST_CASE(
00116             LcsClusterAppendExecStreamTest,
00117             testMultiColConstOldRoot);
00118         FENNEL_UNIT_TEST_CASE(
00119             LcsClusterAppendExecStreamTest,
00120             testMultiColStairNewRoot);
00121         FENNEL_UNIT_TEST_CASE(
00122             LcsClusterAppendExecStreamTest,
00123             testMultiColStairOldRoot);
00124     }
00125     void testCaseSetUp();
00126     void testCaseTearDown();
00127 
00128     void testSingleColNoDupNewRoot();
00129     void testSingleColNoDupOldRoot();
00130 
00131     void testSingleColConstNewRoot();
00132     void testSingleColConstOldRoot();
00133 
00134     void testSingleColStairNewRoot();
00135     void testSingleColStairOldRoot();
00136 
00137     void testMultiColNoDupNewRoot();
00138     void testMultiColNoDupOldRoot();
00139 
00140     void testMultiColConstNewRoot();
00141     void testMultiColConstOldRoot();
00142 
00143     void testMultiColStairNewRoot();
00144     void testMultiColStairOldRoot();
00145 };
00146 
00147 void LcsClusterAppendExecStreamTest::verifyClusterPages(
00148     std::string testName,
00149     uint nCols)
00150 {
00151     bool found;
00152     PConstLcsClusterNode pBlock;
00153     PageId clusterPageId;
00154     LcsRid rid;
00155     ClusterPageData pageData;
00156     uint blockSize =
00157         btreeDescriptor.segmentAccessor.pSegment->getUsablePageSize();
00158     LcsClusterVerifier clusterVerifier(btreeDescriptor);
00159     TupleDescriptor colTupleDesc;
00160     for (uint i = 0; i < nCols; i++) {
00161         colTupleDesc.push_back(attrDesc_int64);
00162     }
00163     LcsClusterDump clusterDump(
00164         btreeDescriptor,
00165         colTupleDesc,
00166         TRACE_INFO,
00167         shared_from_this(),
00168         testName);
00169 
00170     // read every cluster page
00171 
00172     found = clusterVerifier.getFirstClusterPageForRead(pBlock);
00173     if (!found) {
00174         BOOST_FAIL("getFirstClusterPageForRead found nothing");
00175     }
00176     do {
00177         pageData = clusterVerifier.getPageData();
00178         // make sure the rid on the btree matches the rid on the cluster
00179         // page
00180         BOOST_CHECK_EQUAL(pageData.bTreeRid, pBlock->firstRID);
00181         clusterDump.dump(
00182             opaqueToInt(pageData.clusterPageId),
00183             pBlock,
00184             blockSize);
00185     } while (found = clusterVerifier.getNextClusterPageForRead(pBlock));
00186 }
00187 
00188 /*
00189    Tests inserting a single column of non duplicate rows into a cluster.
00190    If newRoot is false, a prior call has already created a btree.  However,
00191    in order for it to be preserved, the subsequent call with newRoot=false must
00192    be done within the same testcase call.
00193  */
00194 void LcsClusterAppendExecStreamTest::testLoadSingleCol(
00195     uint nRows,
00196     uint startRid,
00197     bool newRoot,
00198     SharedMockProducerExecStreamGenerator pGeneratorInit,
00199     std::string testName)
00200 {
00201     SharedMockProducerExecStreamGenerator pGenerator = pGeneratorInit;
00202 
00203     MockProducerExecStreamParams mockParams;
00204     mockParams.outputTupleDesc.push_back(attrDesc_int64);
00205     mockParams.nRows = nRows;
00206     mockParams.pGenerator = pGenerator;
00207 
00208     ExecStreamEmbryo mockStreamEmbryo;
00209     mockStreamEmbryo.init(new MockProducerExecStream(), mockParams);
00210     mockStreamEmbryo.getStream()->setName("MockProducerExecStream");
00211 
00212     LcsClusterAppendExecStreamParams lcsAppendParams;
00213     lcsAppendParams.scratchAccessor =
00214         pSegmentFactory->newScratchSegment(pCache, 10);
00215     lcsAppendParams.pCacheAccessor = pCache;
00216     lcsAppendParams.pSegment = pRandomSegment;
00217 
00218     lcsAppendParams.inputProj.push_back(0);
00219 
00220     // initialize the btree parameter portion of lcsAppendParams
00221     // BTree tuple desc only has one column
00222     (lcsAppendParams.tupleDesc).push_back(attrDesc_int64);
00223     (lcsAppendParams.tupleDesc).push_back(attrDesc_int64);
00224 
00225     // BTree key only has one column which is the first column.
00226     (lcsAppendParams.keyProj).push_back(0);
00227 
00228     // output only single row with 2 columns (# rows loaded, starting rid value)
00229     lcsAppendParams.outputTupleDesc.push_back(attrDesc_int64);
00230     lcsAppendParams.outputTupleDesc.push_back(attrDesc_int64);
00231 
00232     lcsAppendParams.pRootMap = 0;
00233     lcsAppendParams.rootPageIdParamId = DynamicParamId(0);
00234 
00235     // Set up BTreeExecStreamParams using default values from BTreeDescriptor.
00236     lcsAppendParams.segmentId = btreeDescriptor.segmentId;
00237     lcsAppendParams.pageOwnerId = btreeDescriptor.pageOwnerId;
00238 
00239     // setup temporary btree descriptor to get an empty page to start the btree
00240     btreeDescriptor.segmentAccessor.pSegment = lcsAppendParams.pSegment;
00241     btreeDescriptor.segmentAccessor.pCacheAccessor = pCache;
00242     btreeDescriptor.tupleDescriptor = lcsAppendParams.tupleDesc;
00243     btreeDescriptor.keyProjection = lcsAppendParams.keyProj;
00244     btreeDescriptor.rootPageId = newRoot ? NULL_PAGE_ID : savedRootPageId;
00245 
00246     BTreeBuilder builder(btreeDescriptor, pRandomSegment);
00247 
00248     // if BTree root not yet setup
00249     if (newRoot) {
00250         builder.createEmptyRoot();
00251         savedRootPageId = builder.getRootPageId();
00252     }
00253 
00254     lcsAppendParams.rootPageId = btreeDescriptor.rootPageId = savedRootPageId;
00255 
00256     /*
00257       Now use the above initialized parameter
00258      */
00259     LcsClusterAppendExecStream *lcsStream = new LcsClusterAppendExecStream();
00260 
00261     ExecStreamEmbryo lcsAppendStreamEmbryo;
00262     lcsAppendStreamEmbryo.init(lcsStream, lcsAppendParams);
00263     lcsAppendStreamEmbryo.getStream()->setName("LcsClusterAppendExecStream");
00264 
00265     SharedExecStream pOutputStream = prepareTransformGraph(
00266         mockStreamEmbryo, lcsAppendStreamEmbryo);
00267 
00268     // set up a generator which can produce the expected output
00269     vector<boost::shared_ptr<ColumnGenerator<int64_t> > > columnGenerators;
00270     SharedInt64ColumnGenerator colGen =
00271         SharedInt64ColumnGenerator(new SeqColumnGenerator(nRows));
00272     columnGenerators.push_back(colGen);
00273     colGen = SharedInt64ColumnGenerator(new SeqColumnGenerator(startRid));
00274     columnGenerators.push_back(colGen);
00275 
00276     CompositeExecStreamGenerator expectedResultGenerator(columnGenerators);
00277 
00278     verifyOutput(*pOutputStream, 1, expectedResultGenerator);
00279 
00280     // read records from btree to obtain cluster page ids
00281     // and dump out contents of cluster pages
00282     verifyClusterPages(testName, 1);
00283 }
00284 
00285 void LcsClusterAppendExecStreamTest::testLoadMultiCol(
00286     uint nRows,
00287     uint nCols,
00288     bool newRoot,
00289     SharedMockProducerExecStreamGenerator pGeneratorInit,
00290     std::string testName)
00291 {
00292     SharedMockProducerExecStreamGenerator pGenerator = pGeneratorInit;
00293 
00294     MockProducerExecStreamParams mockParams;
00295     for (uint i = 0; i < nCols; i ++) {
00296         mockParams.outputTupleDesc.push_back(attrDesc_int64);
00297     }
00298     mockParams.nRows = nRows;
00299     mockParams.pGenerator = pGenerator;
00300 
00301     ExecStreamEmbryo mockStreamEmbryo;
00302     mockStreamEmbryo.init(new MockProducerExecStream(), mockParams);
00303     mockStreamEmbryo.getStream()->setName("MockProducerExecStream");
00304 
00305     LcsClusterAppendExecStreamParams lcsAppendParams;
00306     lcsAppendParams.scratchAccessor =
00307         pSegmentFactory->newScratchSegment(pCache, 10);
00308     lcsAppendParams.pCacheAccessor = pCache;
00309     lcsAppendParams.pSegment = pRandomSegment;
00310 
00311     // initialize the btree parameter portion of lcsAppendParams
00312     // BTree tuple desc only has one column
00313     (lcsAppendParams.tupleDesc).push_back(attrDesc_int64);
00314     (lcsAppendParams.tupleDesc).push_back(attrDesc_int64);
00315 
00316     // BTree key only has one column which is the first column.
00317     (lcsAppendParams.keyProj).push_back(0);
00318 
00319     // output only one value(rows inserted)
00320     lcsAppendParams.outputTupleDesc.push_back(attrDesc_int64);
00321 
00322     for (uint i = 0; i < nCols; i++) {
00323         lcsAppendParams.inputProj.push_back(i);
00324     }
00325     lcsAppendParams.pRootMap = 0;
00326     lcsAppendParams.rootPageIdParamId = DynamicParamId(0);
00327 
00328     // Set up BTreeExecStreamParams using default values from BTreeDescriptor.
00329     lcsAppendParams.segmentId = btreeDescriptor.segmentId;
00330     lcsAppendParams.pageOwnerId = btreeDescriptor.pageOwnerId;
00331 
00332     // setup temporary btree descriptor to get an empty page to start the btree
00333 
00334     btreeDescriptor.segmentAccessor.pSegment = lcsAppendParams.pSegment;
00335     btreeDescriptor.segmentAccessor.pCacheAccessor = pCache;
00336     btreeDescriptor.tupleDescriptor = lcsAppendParams.tupleDesc;
00337     btreeDescriptor.keyProjection = lcsAppendParams.keyProj;
00338     btreeDescriptor.rootPageId = newRoot ? NULL_PAGE_ID : savedRootPageId;
00339 
00340     BTreeBuilder builder(btreeDescriptor, pRandomSegment);
00341 
00342     // if BTree root not yet setup
00343     if (newRoot) {
00344         builder.createEmptyRoot();
00345         savedRootPageId = builder.getRootPageId();
00346     }
00347 
00348     lcsAppendParams.rootPageId = btreeDescriptor.rootPageId = savedRootPageId;
00349 
00350     /*
00351       Now use the above initialized parameter
00352      */
00353     ExecStreamEmbryo lcsAppendStreamEmbryo;
00354     lcsAppendStreamEmbryo.init(
00355         new LcsClusterAppendExecStream(),
00356         lcsAppendParams);
00357     lcsAppendStreamEmbryo.getStream()->setName("LcsClusterAppendExecStream");
00358 
00359     SharedExecStream pOutputStream = prepareTransformGraph(
00360         mockStreamEmbryo, lcsAppendStreamEmbryo);
00361 
00362     // set up a generator which can produce the expected output
00363     RampExecStreamGenerator expectedResultGenerator(mockParams.nRows);
00364 
00365     verifyOutput(*pOutputStream, 1, expectedResultGenerator);
00366 
00367     // read records from btree to obtain cluster page ids
00368     // and dump out contents of cluster pages
00369     verifyClusterPages(testName, nCols);
00370 }
00371 
00372 void LcsClusterAppendExecStreamTest::testScanSingleCol(
00373     uint nrows,
00374     SharedMockProducerExecStreamGenerator pGeneratorInit,
00375     SharedMockProducerExecStreamGenerator pResultGenerator)
00376 {
00377     SharedMockProducerExecStreamGenerator pGenerator = pGeneratorInit;
00378 
00379     // setup parameters into scan
00380     //  single cluster with only one column, project that single column
00381 
00382     LcsRowScanExecStreamParams scanParams;
00383     scanParams.hasExtraFilter = false;
00384     scanParams.isFullScan = true;
00385     scanParams.samplingMode = SAMPLING_OFF;
00386 
00387     struct LcsClusterScanDef clusterScanDef;
00388 
00389     clusterScanDef.clusterTupleDesc.push_back(attrDesc_int64);
00390     clusterScanDef.pSegment = btreeDescriptor.segmentAccessor.pSegment;
00391     clusterScanDef.pCacheAccessor =
00392         btreeDescriptor.segmentAccessor.pCacheAccessor;
00393     clusterScanDef.tupleDesc = btreeDescriptor.tupleDescriptor;
00394     clusterScanDef.keyProj = btreeDescriptor.keyProjection;
00395     clusterScanDef.rootPageId = btreeDescriptor.rootPageId;
00396     clusterScanDef.segmentId = btreeDescriptor.segmentId;
00397     clusterScanDef.pageOwnerId = btreeDescriptor.pageOwnerId;
00398 
00399     scanParams.lcsClusterScanDefs.push_back(clusterScanDef);
00400     scanParams.outputTupleDesc.push_back(attrDesc_int64);
00401     scanParams.outputProj.push_back(0);
00402 
00403     ExecStreamEmbryo valuesStreamEmbryo;
00404     setUpDelIndexScan(valuesStreamEmbryo);
00405 
00406     ExecStreamEmbryo scanStreamEmbryo;
00407 
00408     scanStreamEmbryo.init(new LcsRowScanExecStream(), scanParams);
00409     scanStreamEmbryo.getStream()->setName("RowScanExecStream");
00410 
00411     SharedExecStream pOutputStream =
00412         prepareTransformGraph(valuesStreamEmbryo, scanStreamEmbryo);
00413 
00414     // result should be sequence of rows
00415     verifyOutput(*pOutputStream, nrows, *pResultGenerator);
00416 }
00417 
00418 void LcsClusterAppendExecStreamTest::setUpDelIndexScan(
00419     ExecStreamEmbryo &valuesStreamEmbryo)
00420 {
00421     ValuesExecStreamParams valuesParams;
00422     boost::shared_array<FixedBuffer> pBuffer;
00423 
00424     // setup a values stream to provide an empty input to simulate
00425     // the scan of the deletion index
00426     valuesParams.outputTupleDesc.push_back(attrDesc_int64);
00427     valuesParams.outputTupleDesc.push_back(attrDesc_bitmap);
00428     valuesParams.outputTupleDesc.push_back(attrDesc_bitmap);
00429 
00430     uint bufferSize = 16;
00431     pBuffer.reset(new FixedBuffer[bufferSize]);
00432     valuesParams.pTupleBuffer = pBuffer;
00433     valuesParams.bufSize = 0;
00434     valuesStreamEmbryo.init(new ValuesExecStream(), valuesParams);
00435     valuesStreamEmbryo.getStream()->setName("ValuesExecStream");
00436 }
00437 
00438 void LcsClusterAppendExecStreamTest::testScanMultiCol(
00439     uint nrows,
00440     uint nCols,
00441     SharedMockProducerExecStreamGenerator pGeneratorInit,
00442     SharedMockProducerExecStreamGenerator pResultGenerator)
00443 {
00444     uint i;
00445     SharedMockProducerExecStreamGenerator pGenerator = pGeneratorInit;
00446 
00447     // setup parameters into scan
00448     //  single cluster with only n columns, project all columns
00449 
00450     LcsRowScanExecStreamParams scanParams;
00451     scanParams.hasExtraFilter = false;
00452     scanParams.isFullScan = true;
00453     scanParams.samplingMode = SAMPLING_OFF;
00454     struct LcsClusterScanDef clusterScanDef;
00455 
00456     for (i = 0; i < nCols; i++) {
00457         clusterScanDef.clusterTupleDesc.push_back(attrDesc_int64);
00458     }
00459 
00460     clusterScanDef.pSegment = btreeDescriptor.segmentAccessor.pSegment;
00461     clusterScanDef.pCacheAccessor =
00462         btreeDescriptor.segmentAccessor.pCacheAccessor;
00463     clusterScanDef.tupleDesc = btreeDescriptor.tupleDescriptor;
00464     clusterScanDef.keyProj = btreeDescriptor.keyProjection;
00465     clusterScanDef.rootPageId = btreeDescriptor.rootPageId;
00466     clusterScanDef.segmentId = btreeDescriptor.segmentId;
00467     clusterScanDef.pageOwnerId = btreeDescriptor.pageOwnerId;
00468 
00469     scanParams.lcsClusterScanDefs.push_back(clusterScanDef);
00470     for (i = 0; i < nCols; i++) {
00471         scanParams.outputTupleDesc.push_back(attrDesc_int64);
00472         scanParams.outputProj.push_back(i);
00473     }
00474 
00475     ExecStreamEmbryo valuesStreamEmbryo;
00476     setUpDelIndexScan(valuesStreamEmbryo);
00477 
00478     ExecStreamEmbryo scanStreamEmbryo;
00479 
00480     scanStreamEmbryo.init(new LcsRowScanExecStream(), scanParams);
00481     scanStreamEmbryo.getStream()->setName("RowScanExecStream");
00482 
00483     SharedExecStream pOutputStream =
00484         prepareTransformGraph(valuesStreamEmbryo, scanStreamEmbryo);
00485 
00486     // result should be sequence of rows
00487     verifyOutput(*pOutputStream, nrows, *pResultGenerator);
00488 }
00489 
00490 void LcsClusterAppendExecStreamTest::testCaseSetUp()
00491 {
00492     ExecStreamUnitTestBase::testCaseSetUp();
00493 
00494     attrDesc_int64 = TupleAttributeDescriptor(
00495         stdTypeFactory.newDataType(STANDARD_TYPE_INT_64));
00496     attrDesc_bitmap = TupleAttributeDescriptor(
00497         stdTypeFactory.newDataType(STANDARD_TYPE_CHAR),
00498         true, pRandomSegment->getUsablePageSize() / 8);
00499 
00500     savedRootPageId = NULL_PAGE_ID;
00501 }
00502 
00503 void LcsClusterAppendExecStreamTest::testCaseTearDown()
00504 {
00505     btreeDescriptor.segmentAccessor.reset();
00506     ExecStreamUnitTestBase::testCaseTearDown();
00507 }
00508 
00509 void LcsClusterAppendExecStreamTest::testSingleColNoDupNewRoot()
00510 {
00511     // 1. load 848 rows
00512     // 2. scan 848 rows
00513 
00514     SharedMockProducerExecStreamGenerator pGenerator =
00515         SharedMockProducerExecStreamGenerator(new RampExecStreamGenerator());
00516     SharedMockProducerExecStreamGenerator pResultGenerator =
00517         SharedMockProducerExecStreamGenerator(new RampExecStreamGenerator());
00518 
00519     testLoadSingleCol(
00520         848, 0, true,  pGenerator, "testSingleColNoDupNewRoot");
00521     resetExecStreamTest();
00522     testScanSingleCol(848, pGenerator, pResultGenerator);
00523 }
00524 
00525 /*
00526   Tests appending to an existing tree by first inserting into a new btree and
00527   then reusing the btree.  Note that all of this needs to be done within a
00528   single testcase with an intervening resetExecStreamTest().  Otherwise, the
00529   btree state from the first set of inserts is not preserved.
00530 */
00531 void LcsClusterAppendExecStreamTest::testSingleColNoDupOldRoot()
00532 {
00533     // 1. load 848 rows
00534     // 2. scan first 848 rows
00535     // 3. load 848 more rows
00536 
00537     SharedMockProducerExecStreamGenerator pGenerator =
00538         SharedMockProducerExecStreamGenerator(new RampExecStreamGenerator());
00539     SharedMockProducerExecStreamGenerator pResultGenerator =
00540         SharedMockProducerExecStreamGenerator(new RampExecStreamGenerator());
00541 
00542     testLoadSingleCol(
00543         848, 0, true,  pGenerator,  "testSingleColNoDupOldRoot");
00544     resetExecStreamTest();
00545     // this will test scans of variable mode batches
00546     testScanSingleCol(848, pGenerator, pResultGenerator);
00547 
00548     resetExecStreamTest();
00549     testLoadSingleCol(
00550         848, 848, false,  pGenerator,  "testSingleColNoDupOldRoot");
00551 }
00552 
00553 
00554 void LcsClusterAppendExecStreamTest::testSingleColConstNewRoot()
00555 {
00556     // 1. load 848 rows
00557     // 2. scan 848 rows
00558 
00559     SharedMockProducerExecStreamGenerator pGenerator =
00560         SharedMockProducerExecStreamGenerator(new ConstExecStreamGenerator(72));
00561     SharedMockProducerExecStreamGenerator pResultGenerator =
00562         SharedMockProducerExecStreamGenerator(new ConstExecStreamGenerator(72));
00563 
00564     testLoadSingleCol(
00565         848, 0, true, pGenerator, "testSingleColConstNewRoot");
00566     resetExecStreamTest();
00567 
00568     pGenerator.reset(new RampExecStreamGenerator());
00569     testScanSingleCol(848, pGenerator, pResultGenerator);
00570 }
00571 
00572 /*
00573   Tests appending to an existing tree by first inserting into a new btree and
00574   then reusing the btree.  Note that all of this needs to be done within a
00575   single testcase with an intervening resetExecStreamTest().  Otherwise, the
00576   btree state from the first set of inserts is not preserved.
00577 */
00578 void LcsClusterAppendExecStreamTest::testSingleColConstOldRoot()
00579 {
00580     // 1. load 10 rows
00581     // 2. load 10 more rows
00582     // 3. scan 20 rows
00583 
00584     SharedMockProducerExecStreamGenerator pGenerator =
00585         SharedMockProducerExecStreamGenerator(new ConstExecStreamGenerator(72));
00586     SharedMockProducerExecStreamGenerator pResultGenerator =
00587         SharedMockProducerExecStreamGenerator(new ConstExecStreamGenerator(72));
00588 
00589     testLoadSingleCol(
00590         10, 0, true,  pGenerator,  "testSingleColConstOldRoot");
00591     resetExecStreamTest();
00592     testLoadSingleCol(
00593         10, 10, false,  pGenerator,  "testSingleColConstOldRoot");
00594 
00595     resetExecStreamTest();
00596     pGenerator.reset(new RampExecStreamGenerator());
00597     testScanSingleCol(20, pGenerator, pResultGenerator);
00598 }
00599 
00600 void LcsClusterAppendExecStreamTest::testSingleColStairNewRoot()
00601 {
00602     // 1. load 848 rows
00603     // 2. scan 848 rows
00604 
00605     SharedMockProducerExecStreamGenerator pGenerator =
00606         SharedMockProducerExecStreamGenerator(
00607             new StairCaseExecStreamGenerator(1,  7));
00608     SharedMockProducerExecStreamGenerator pResultGenerator =
00609         SharedMockProducerExecStreamGenerator(
00610             new StairCaseExecStreamGenerator(1,  7));
00611 
00612     testLoadSingleCol(
00613         848, 0, true, pGenerator, "testSingleColStairNewRoot");
00614     resetExecStreamTest();
00615 
00616     pGenerator.reset(new RampExecStreamGenerator());
00617     testScanSingleCol(848, pGenerator, pResultGenerator);
00618 }
00619 
00620 /*
00621   Tests appending to an existing tree by first inserting into a new btree and
00622   then reusing the btree.  Note that all of this needs to be done within a
00623   single testcase with an intervening resetExecStreamTest().  Otherwise, the
00624   btree state from the first set of inserts is not preserved.
00625 */
00626 void LcsClusterAppendExecStreamTest::testSingleColStairOldRoot()
00627 {
00628     // 1. load 10 rows
00629     // 2. scan first 10 rows
00630     // 3. load 10 more rows
00631 
00632     SharedMockProducerExecStreamGenerator pGenerator =
00633         SharedMockProducerExecStreamGenerator(
00634             new StairCaseExecStreamGenerator(1, 7));
00635     SharedMockProducerExecStreamGenerator pRidGenerator =
00636         SharedMockProducerExecStreamGenerator(
00637             new RampExecStreamGenerator());
00638     SharedMockProducerExecStreamGenerator pResultGenerator =
00639         SharedMockProducerExecStreamGenerator(
00640             new StairCaseExecStreamGenerator(1,  7));
00641 
00642     testLoadSingleCol(
00643         10, 0, true,  pGenerator,  "testSingleColStairOldRoot");
00644     resetExecStreamTest();
00645     testScanSingleCol(10, pRidGenerator, pResultGenerator);
00646 
00647     resetExecStreamTest();
00648     testLoadSingleCol(
00649         10, 10, false,  pGenerator, "testSingleColStairOldRoot");
00650 }
00651 
00652 void LcsClusterAppendExecStreamTest::testMultiColNoDupNewRoot()
00653 {
00654     // 1. load 848 rows
00655     // 2. scan 848 rows
00656 
00657     SharedMockProducerExecStreamGenerator pGenerator =
00658         SharedMockProducerExecStreamGenerator(new RampExecStreamGenerator());
00659     SharedMockProducerExecStreamGenerator pResultGenerator =
00660         SharedMockProducerExecStreamGenerator(new RampExecStreamGenerator());
00661 
00662     testLoadMultiCol(848, 3, true,  pGenerator,  "testMultiColNoDupNewRoot");
00663     resetExecStreamTest();
00664     testScanMultiCol(848, 3, pGenerator, pResultGenerator);
00665 }
00666 
00667 /*
00668   Tests appending to an existing tree by first inserting into a new btree and
00669   then reusing the btree.  Note that all of this needs to be done within a
00670   single testcase with an intervening resetExecStreamTest().  Otherwise, the
00671   btree state from the first set of inserts is not preserved.
00672 */
00673 void LcsClusterAppendExecStreamTest::testMultiColNoDupOldRoot()
00674 {
00675     // 1. load 15000 rows
00676     // 2. scan first 15000 rows
00677     // 3. load 15000 more rows
00678     //
00679     // 15000 rows with 12 cols is large enough to force a split of the
00680     // cluster btree
00681 
00682     SharedMockProducerExecStreamGenerator pGenerator =
00683         SharedMockProducerExecStreamGenerator(new RampExecStreamGenerator());
00684     SharedMockProducerExecStreamGenerator pRidGenerator =
00685         SharedMockProducerExecStreamGenerator(new RampExecStreamGenerator());
00686     SharedMockProducerExecStreamGenerator pResultGenerator =
00687         SharedMockProducerExecStreamGenerator(new RampExecStreamGenerator());
00688 
00689     testLoadMultiCol(15000, 12, true,  pGenerator,"testMultiColNoDupOldRoot");
00690     resetExecStreamTest();
00691     testScanMultiCol(15000, 12, pRidGenerator, pResultGenerator);
00692 
00693     resetExecStreamTest();
00694     testLoadMultiCol(15000, 12, false,  pGenerator, "testMultiColNoDupOldRoot");
00695 }
00696 
00697 
00698 void LcsClusterAppendExecStreamTest::testMultiColConstNewRoot()
00699 {
00700     // 1. load 848 rows
00701     // 2. scan 848 rows
00702 
00703     SharedMockProducerExecStreamGenerator pGenerator =
00704         SharedMockProducerExecStreamGenerator(new ConstExecStreamGenerator(72));
00705     SharedMockProducerExecStreamGenerator pResultGenerator =
00706         SharedMockProducerExecStreamGenerator(new ConstExecStreamGenerator(72));
00707 
00708     testLoadMultiCol(848, 3, true,  pGenerator,  "testMultiColConstNewRoot");
00709     resetExecStreamTest();
00710 
00711     pGenerator.reset(new RampExecStreamGenerator());
00712     testScanMultiCol(848, 3, pGenerator, pResultGenerator);
00713 }
00714 
00715 /*
00716   Tests appending to an existing tree by first inserting into a new btree and
00717   then reusing the btree.  Note that all of this needs to be done within a
00718   single testcase with an intervening resetExecStreamTest().  Otherwise, the
00719   btree state from the first set of inserts is not preserved.
00720 */
00721 void LcsClusterAppendExecStreamTest::testMultiColConstOldRoot()
00722 {
00723     // 1. load 10 rows
00724     // 2. load 10 more rows
00725     // 3. scan 20 rows
00726 
00727     SharedMockProducerExecStreamGenerator pGenerator =
00728         SharedMockProducerExecStreamGenerator(new ConstExecStreamGenerator(72));
00729     SharedMockProducerExecStreamGenerator pResultGenerator =
00730         SharedMockProducerExecStreamGenerator(new ConstExecStreamGenerator(72));
00731 
00732     testLoadMultiCol(10, 3, true,  pGenerator,  "testMultiColConstOldRoot");
00733     resetExecStreamTest();
00734     testLoadMultiCol(10, 3, false,  pGenerator, "testMultiColConstOldRoot");
00735 
00736     resetExecStreamTest();
00737     pGenerator.reset(new RampExecStreamGenerator());
00738     testScanMultiCol(20, 3, pGenerator, pResultGenerator);
00739 }
00740 
00741 void LcsClusterAppendExecStreamTest::testMultiColStairNewRoot()
00742 {
00743     // 1. load 848 rows
00744     // 2. scan 848 rows
00745 
00746     SharedMockProducerExecStreamGenerator pGenerator =
00747         SharedMockProducerExecStreamGenerator(
00748             new StairCaseExecStreamGenerator(1,  7));
00749     SharedMockProducerExecStreamGenerator pResultGenerator =
00750         SharedMockProducerExecStreamGenerator(
00751             new StairCaseExecStreamGenerator(1,  7));
00752 
00753     testLoadMultiCol(848, 3, true,  pGenerator,  "testMultiColStairNewRoot");
00754     resetExecStreamTest();
00755 
00756     pGenerator.reset(new RampExecStreamGenerator());
00757     testScanMultiCol(848, 3, pGenerator, pResultGenerator);
00758 }
00759 
00760 /*
00761   Tests appending to an existing tree by first inserting into a new btree and
00762   then reusing the btree.  Note that all of this needs to be done within a
00763   single testcase with an intervening resetExecStreamTest().  Otherwise, the
00764   btree state from the first set of inserts is not preserved.
00765 */
00766 void LcsClusterAppendExecStreamTest::testMultiColStairOldRoot()
00767 {
00768     // 1. load 10 rows
00769     // 2. scan first 10 rows
00770     // 3. load more 10 rows
00771 
00772     SharedMockProducerExecStreamGenerator pGenerator =
00773         SharedMockProducerExecStreamGenerator(
00774             new StairCaseExecStreamGenerator(1, 7));
00775     SharedMockProducerExecStreamGenerator pRidGenerator =
00776         SharedMockProducerExecStreamGenerator(new RampExecStreamGenerator());
00777     SharedMockProducerExecStreamGenerator pResultGenerator =
00778         SharedMockProducerExecStreamGenerator(
00779             new StairCaseExecStreamGenerator(1,  7));
00780 
00781     testLoadMultiCol(10, 3, true, pGenerator, "testMultiColStairOldRoot");
00782     resetExecStreamTest();
00783     testScanMultiCol(10, 3, pRidGenerator, pResultGenerator);
00784 
00785     resetExecStreamTest();
00786     testLoadMultiCol(10, 3, false, pGenerator, "testMultiColStairOldRoot");
00787 }
00788 
00789 FENNEL_UNIT_TEST_SUITE(LcsClusterAppendExecStreamTest);
00790 
00791 // End LcsClusterAppendExecStreamTest.cpp

Generated on Mon Jun 22 04:00:20 2009 for Fennel by  doxygen 1.5.1