LbmEntryTest Class Reference

Testcase for LbmEntry class. More...

Inheritance diagram for LbmEntryTest:

SegStorageTestBase CacheTestBase TestBase TraceTarget List of all members.

Public Member Functions

 LbmEntryTest ()
virtual void testCaseSetUp ()
 Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked.
virtual void testCaseTearDown ()
 Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked.
void testRandom1 ()
void testRandom2 ()
void testRandom3 ()
void testRandom4 ()
void testRandom5 ()
void testCombos ()
void testldb35 ()
void testler5920 ()
void testZeroBytes ()
void testMergeSingletonInFront1 ()
void testMergeSingletonInFront2 ()
void testMergeSingletonMidSegment1 ()
void testMergeSingletonMidSegment2 ()
void testMergeSingletonMidSegment3 ()
void testMergeSingletonMidSegment4 ()
void testMergeSingletonEndSegment ()
void testMergeSingletonStartSegment1 ()
void testMergeSingletonStartSegment2 ()
void testMergeSingletonInBetweenSegment ()
void testMergeSingletonSplitLeft1 ()
void testMergeSingletonSplitLeft2 ()
void testMergeSingletonSplitRight1 ()
void testMergeSingletonSplitRight2 ()
void testMergeSingletonSplitHalf ()
void testMergeSingletonSplitLast ()
void testMergeSingletonSplitMaxSegments ()
void testMergeSingletonZeros1 ()
void testMergeSingletonZeros2 ()
void testMergeSingletonZeros3 ()
void testMergeSingletonZeros4 ()
void testMergeSingletonAfterSplit ()
void testMergeSingletonCombine ()
void testMergeSingletonMaxSeg ()
void testMergeSingletonRandom1 ()
void testMergeSingletonRandom2 ()
void testMergeSingletonWithSingleton1 ()
void testMergeSingletonWithSingleton2 ()
virtual void openStorage (DeviceMode openMode)
virtual void openSegmentStorage (DeviceMode openMode)
virtual void openRandomSegment ()
SharedSegment createLinearDeviceSegment (DeviceId deviceId, uint nPages)
void closeLinearSegment ()
void closeRandomSegment ()
void closeVersionedRandomSegment ()
void closeSnapshotRandomSegment ()
virtual void closeStorage ()
CachegetCache ()
virtual SharedCache newCache ()
SharedRandomAccessDevice openDevice (std::string devName, DeviceMode openMode, uint nDevicePages, DeviceId deviceId)
void closeDevice (DeviceId deviceId, SharedRandomAccessDevice &pDevice)
TestSuitereleaseTestSuite ()
void beforeTestCase (std::string testCaseName)
void afterTestCase (std::string testCaseName)
virtual void notifyTrace (std::string source, TraceLevel level, std::string message)
 Receives notification when a trace event occurs.
virtual TraceLevel getSourceTraceLevel (std::string source)
 Gets the level at which a particular source should be traced.

Static Public Member Functions

static void readParams (int argc, char **argv)
 Parses the command line.

Static Public Attributes

static ParamName paramTestSuiteName
static ParamName paramTraceFileName
static ParamName paramDictionaryFileName
static ParamName paramTraceLevel
static ParamName paramStatsFileName
static ParamName paramTraceStdout
static ParamName paramDegreeOfParallelism
static ConfigMap configMap
 Configuration parameters.

Protected Types

enum  VictimPolicy { victimTwoQ, victimLRU, victimRandom }
 The available victim policy implementations. More...

Protected Member Functions

void snooze (uint nSeconds)

Protected Attributes

SharedSegmentFactory pSegmentFactory
SharedSegment pLinearSegment
 Segment supporting linear page allocation.
SharedSegment pRandomSegment
 (Optional) segment supporting random page allocation.
SharedSegment pVersionedRandomSegment
 (Optional) segment supporting versioned random page allocation.
SharedSegment pSnapshotRandomSegment
 (Optional) segment supporting snapshot random page allocation.
VictimPolicy victimPolicy
 VictimPolicy to instantiate.
CacheParams cacheParams
 Parameters for cache initialization.
SharedCache pCache
 Cache instance being tested.
SharedRandomAccessDevice pRandomAccessDevice
 The default cached device.
uint nMemPages
 Size of cache in memory pages.
uint nDiskPages
 Size of device in disk pages.
uint cbPageFull
 Disk page size.
DeviceId dataDeviceId
 Fixed ID to assign to data device.
TestSuitepTestSuite
 Boost test suite.
boost::shared_ptr< TestBasepTestObj
std::ofstream traceStream
 Output file stream for tracing.
StrictMutex traceMutex
 Protects traceStream.
std::string testName
 Name of test.
TraceLevel traceLevel
 Level at which to trace test execution.
FileStatsTarget statsTarget
 Output for stats.
StatsTimer statsTimer
 Timer for stats collection.
bool traceStdout
 Copy trace output to stdout.
bool traceFile
 Copy trace output to file.
TestCaseGroup defaultTests
TestCaseGroup extraTests

Static Protected Attributes

static bool runAll
 Run all test cases, including the extra tests.
static std::string runSingle
 Run only the test case of this name.

Private Member Functions

void testRandom (uint nUniqueKeys, uint nRows, uint scratchBufferSize)
void testMergeEntry (std::vector< LcsRid > const &ridValues, VectorOfUint const &nRidsPerBitmap, uint scratchBufferSize)
 Main test routine for exercising mergeEntry.
void newLbmEntry (std::vector< SharedLbmEntryInfo > &entryList, LcsRid startRid, SegPageLock &bufferLock)
PBuffer allocateBuf (SegPageLock &bufferLock)
bool compareExpected (LbmEntry &entry, std::vector< LcsRid > const &ridValues, uint &ridPos, bool testContains)
void recurseCombos (uint curr, uint nEntries, VectorOfUint &eTypes)
void generateBitmaps (EntryType etype, std::vector< LcsRid > &ridValues, VectorOfUint &nRidsPerBitmap)
void generateSingleBitmaps (std::vector< LcsRid > &ridValues, VectorOfUint &nRidsPerBitmap, LcsRid startRid, uint nRids)
void generateCompressedBitmaps (std::vector< LcsRid > &ridValues, VectorOfUint &nRidsPerBitmap, LcsRid startRid, uint nRids)
void testMergeSingleton (uint scratchBufferSize, const std::vector< LcsRid > &ridValues, uint nSingletons, bool split)
 Main test routine for merging arbitrary singleton entries.
void testMergeSingletonRandom (uint totalRids, uint ridRange)

Private Attributes

uint bitmapColSize
StandardTypeDescriptorFactory stdTypeFactory
TupleAttributeDescriptor attrDesc_bitmap
TupleAttributeDescriptor attrDesc_int64
TupleDescriptor entryTupleDesc
uint bufSize
uint bufUsed
PBuffer pBuf
TupleData entryTuple

Detailed Description

Testcase for LbmEntry class.

Definition at line 60 of file LbmEntryTest.cpp.


Member Enumeration Documentation

enum CacheTestBase::VictimPolicy [protected, inherited]

The available victim policy implementations.

Enumerator:
victimTwoQ 
victimLRU 
victimRandom 

Definition at line 44 of file CacheTestBase.h.

00044                       {
00045         victimTwoQ,
00046         victimLRU,
00047         victimRandom
00048     };


Constructor & Destructor Documentation

LbmEntryTest::LbmEntryTest (  )  [inline, explicit]

Definition at line 127 of file LbmEntryTest.cpp.

References testCombos(), testldb35(), testler5920(), testMergeSingletonAfterSplit(), testMergeSingletonCombine(), testMergeSingletonEndSegment(), testMergeSingletonInBetweenSegment(), testMergeSingletonInFront1(), testMergeSingletonInFront2(), testMergeSingletonMaxSeg(), testMergeSingletonMidSegment1(), testMergeSingletonMidSegment2(), testMergeSingletonMidSegment3(), testMergeSingletonMidSegment4(), testMergeSingletonRandom1(), testMergeSingletonRandom2(), testMergeSingletonSplitHalf(), testMergeSingletonSplitLast(), testMergeSingletonSplitLeft1(), testMergeSingletonSplitLeft2(), testMergeSingletonSplitMaxSegments(), testMergeSingletonSplitRight1(), testMergeSingletonSplitRight2(), testMergeSingletonStartSegment1(), testMergeSingletonStartSegment2(), testMergeSingletonWithSingleton1(), testMergeSingletonWithSingleton2(), testMergeSingletonZeros1(), testMergeSingletonZeros2(), testMergeSingletonZeros3(), testMergeSingletonZeros4(), testRandom1(), testRandom2(), testRandom3(), testRandom4(), testRandom5(), and testZeroBytes().

00128     {
00129         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testRandom1);
00130         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testRandom2);
00131         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testRandom3);
00132         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testRandom4);
00133         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testRandom5);
00134         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testCombos);
00135         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testldb35);
00136         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testler5920);
00137         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testZeroBytes);
00138 
00139         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonInFront1);
00140         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonInFront2);
00141         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonMidSegment1);
00142         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonMidSegment2);
00143         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonMidSegment3);
00144         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonMidSegment4);
00145         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonEndSegment);
00146         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonStartSegment1);
00147         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonStartSegment2);
00148         FENNEL_UNIT_TEST_CASE(
00149             LbmEntryTest, testMergeSingletonInBetweenSegment);
00150         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonSplitLeft1);
00151         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonSplitLeft2);
00152         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonSplitRight1);
00153         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonSplitRight2);
00154         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonSplitHalf);
00155         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonSplitLast);
00156         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonSplitMaxSegments);
00157         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonZeros1);
00158         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonZeros2);
00159         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonZeros3);
00160         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonZeros4);
00161         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonAfterSplit);
00162         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonCombine);
00163         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonMaxSeg);
00164         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonRandom1);
00165         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonRandom2);
00166         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonWithSingleton1);
00167         FENNEL_UNIT_TEST_CASE(LbmEntryTest, testMergeSingletonWithSingleton2);
00168     }


Member Function Documentation

void LbmEntryTest::testRandom ( uint  nUniqueKeys,
uint  nRows,
uint  scratchBufferSize 
) [private]

Definition at line 257 of file LbmEntryTest.cpp.

References testMergeEntry().

Referenced by testRandom1(), testRandom2(), testRandom3(), testRandom4(), and testRandom5().

00259 {
00260     std::vector<LcsRid> ridValues;
00261     VectorOfUint nRidsPerBitmap;
00262     uint totalRids = nRows / nUniqueKeys;
00263 
00264     assert(scratchBufferSize >= 8);
00265 
00266     // generate random rid values, ensuring that they are unique, then
00267     // sort them
00268     std::hash_set<uint64_t> ridsGenerated;
00269     for (uint i = 0; i < totalRids;) {
00270         uint64_t rid = rand() % nRows;
00271         if (ridsGenerated.find(rid) == ridsGenerated.end()) {
00272             ridValues.push_back(LcsRid(rid));
00273             ridsGenerated.insert(rid);
00274             i++;
00275         }
00276     }
00277     // sort the rid values
00278     std::sort(ridValues.begin(), ridValues.end());
00279 #if 0
00280     std::cout << "Rid Values After Sort" << std::endl;
00281     for (uint i = 0; i < ridValues.size(); i++) {
00282         std::cout << ridValues[i] << std::endl;
00283     }
00284 #endif
00285 
00286     // generate random values that will determine how many rids
00287     // there are per bitmap
00288     uint ridCount = 0;
00289     while (ridCount < totalRids) {
00290         // divide by 4 so we'll later merge roughly 2-4 bitmaps per
00291         // entry
00292         uint nRids = rand() % (scratchBufferSize / 4) + 1;
00293         if (nRids + ridCount < totalRids) {
00294             nRidsPerBitmap.push_back(nRids);
00295             ridCount += nRids;
00296         } else {
00297             nRidsPerBitmap.push_back(totalRids - ridCount);
00298             break;
00299         }
00300     }
00301 
00302     testMergeEntry(ridValues, nRidsPerBitmap, scratchBufferSize);
00303 }

void LbmEntryTest::testMergeEntry ( std::vector< LcsRid > const &  ridValues,
VectorOfUint const &  nRidsPerBitmap,
uint  scratchBufferSize 
) [private]

Main test routine for exercising mergeEntry.

Parameters:
ridValues vector of rid values to construct bitmaps for
nRidsPerBitmap vector of values indicating how many rids to include in each bitmap
scratchBufferSize size of scratch buffer used to construct bitmaps; size only indicates space to be used by bitmaps

Definition at line 305 of file LbmEntryTest.cpp.

References SegPageLock::accessSegment(), allocateBuf(), attrDesc_bitmap, attrDesc_int64, bitmapColSize, bufSize, bufUsed, compareExpected(), TupleData::compute(), entryTuple, entryTupleDesc, LbmEntry::getScratchBufferSize(), LbmEntry::init(), LbmEntry::mergeEntry(), StandardTypeDescriptorFactory::newDataType(), newLbmEntry(), NULL_PAGE_ID, CacheTestBase::pCache, SegmentAccessor::pSegment, SegStorageTestBase::pSegmentFactory, LbmEntry::setEntryTuple(), STANDARD_TYPE_INT_64, STANDARD_TYPE_VARBINARY, stdTypeFactory, and LbmEntry::toString().

Referenced by recurseCombos(), and testRandom().

00308 {
00309     std::vector<SharedLbmEntryInfo> entryList;
00310 
00311     // bitmap entries will be created without a leading key, so the
00312     // first column is the startRid
00313     // initialize scratch accessor for scratch buffers used to
00314     // construct bitmaps
00315     SegmentAccessor scratchAccessor =
00316         pSegmentFactory->newScratchSegment(pCache, 10);
00317     bufSize = scratchAccessor.pSegment->getUsablePageSize();
00318     SegPageLock bufferLock;
00319     bufferLock.accessSegment(scratchAccessor);
00320     bufUsed = bufSize;
00321 
00322     bitmapColSize = scratchBufferSize;
00323     attrDesc_bitmap =
00324         TupleAttributeDescriptor(
00325             stdTypeFactory.newDataType(STANDARD_TYPE_VARBINARY),
00326             true, bitmapColSize);
00327     attrDesc_int64 =
00328         TupleAttributeDescriptor(
00329             stdTypeFactory.newDataType(STANDARD_TYPE_INT_64));
00330 
00331     entryTupleDesc.push_back(attrDesc_int64);
00332     entryTupleDesc.push_back(attrDesc_bitmap);
00333     entryTupleDesc.push_back(attrDesc_bitmap);
00334     entryTuple.compute(entryTupleDesc);
00335     entryTuple[1].pData = NULL;
00336     entryTuple[2].pData = NULL;
00337 
00338     // Generate bitmaps using the list of rid values. The number of rids
00339     // in each bitmap is based on the list of nRidsPerBitmap.
00340 
00341     uint totalRids = ridValues.size();
00342     uint nRidPos = 0;
00343     for (uint i = 0; i < totalRids;) {
00344         newLbmEntry(entryList, ridValues[i], bufferLock);
00345         i++;
00346 
00347         for (uint j = 1; i < totalRids && j < nRidsPerBitmap[nRidPos];
00348             i++, j++)
00349         {
00350             if (!entryList.back()->entry.setRID(ridValues[i])) {
00351                 newLbmEntry(entryList, ridValues[i], bufferLock);
00352             }
00353         }
00354         nRidPos++;
00355     }
00356 
00357     // produce the tuples corresponding to each LbmEntry
00358     for (uint i = 0; i < entryList.size(); i++) {
00359         entryList[i]->entryTuple = entryList[i]->entry.produceEntryTuple();
00360     }
00361 
00362 #if 0
00363     std::cout << "Generated Entries Before Merge" << std::endl;
00364     for (uint i = 0; i < entryList.size(); i++) {
00365         std::cout << LbmEntry::toString(entryList[i]->entryTuple, true)
00366             << std::endl;
00367     }
00368 #endif
00369 
00370     // merge the entries constructed
00371     uint ridPos = 0;
00372 
00373     PBuffer mergeBuf = allocateBuf(bufferLock);
00374     LbmEntry mEntry;
00375     mEntry.init(
00376         mergeBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00377         entryTupleDesc);
00378     mEntry.setEntryTuple(entryList[0]->entryTuple);
00379     for (uint i = 1; i < entryList.size(); i++) {
00380         if (mEntry.mergeEntry(entryList[i]->entryTuple)) {
00381             continue;
00382         }
00383         // not able to merge, so need to produce entry and compare against
00384         // expected rids before starting to merge on the next entry
00385         bool rc = compareExpected(mEntry, ridValues, ridPos, true);
00386         BOOST_REQUIRE(rc);
00387         mEntry.setEntryTuple(entryList[i]->entryTuple);
00388     }
00389     // if this is the last remaining entry, compare it against
00390     // expected rid values
00391     if (ridPos < totalRids) {
00392         bool rc = compareExpected(mEntry, ridValues, ridPos, true);
00393         BOOST_REQUIRE(rc);
00394     }
00395 
00396     BOOST_REQUIRE(ridPos == totalRids);
00397 
00398     scratchAccessor.pSegment->deallocatePageRange(NULL_PAGE_ID, NULL_PAGE_ID);
00399 }

void LbmEntryTest::newLbmEntry ( std::vector< SharedLbmEntryInfo > &  entryList,
LcsRid  startRid,
SegPageLock bufferLock 
) [private]

Definition at line 401 of file LbmEntryTest.cpp.

References allocateBuf(), bitmapColSize, entryTuple, entryTupleDesc, and LbmEntry::getScratchBufferSize().

Referenced by testMergeEntry().

00404 {
00405     SharedLbmEntryInfo pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00406 
00407     pListElement->pBuf = allocateBuf(bufferLock);
00408     pListElement->entry.init(
00409         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00410         entryTupleDesc);
00411     entryList.push_back(pListElement);
00412     entryTuple[0].pData = (PConstBuffer) &startRid;
00413     entryList.back()->entry.setEntryTuple(entryTuple);
00414 }

PBuffer LbmEntryTest::allocateBuf ( SegPageLock bufferLock  )  [private]

Definition at line 416 of file LbmEntryTest.cpp.

References SegPageLock::allocatePage(), bitmapColSize, bufSize, bufUsed, SegPageLock::getPage(), LbmEntry::getScratchBufferSize(), CachePage::getWritableData(), pBuf, and SegPageLock::unlock().

Referenced by newLbmEntry(), testldb35(), testler5920(), testMergeEntry(), and testZeroBytes().

00417 {
00418     // allocate a new scratch page if not enough space is left on
00419     // the current
00420     uint scratchBufSize = LbmEntry::getScratchBufferSize(bitmapColSize);
00421     if (bufUsed + scratchBufSize > bufSize) {
00422         bufferLock.allocatePage();
00423         pBuf = bufferLock.getPage().getWritableData();
00424         bufferLock.unlock();
00425         bufUsed = 0;
00426     }
00427     PBuffer retBuf = pBuf + bufUsed;
00428     bufUsed += scratchBufSize;
00429     return retBuf;
00430 }

bool LbmEntryTest::compareExpected ( LbmEntry entry,
std::vector< LcsRid > const &  ridValues,
uint ridPos,
bool  testContains 
) [private]

Definition at line 432 of file LbmEntryTest.cpp.

References LbmEntry::containsRid(), LbmEntry::generateRIDs(), LbmEntry::getRowCount(), LbmEntry::produceEntryTuple(), LbmSegment::roundToByteBoundary(), and LbmEntry::toString().

Referenced by testldb35(), testler5920(), testMergeEntry(), testMergeSingleton(), and testZeroBytes().

00435 {
00436     TupleData const &generatedTuple = generatedEntry.produceEntryTuple();
00437     std::vector<LcsRid> actualRids;
00438     LbmEntry::generateRIDs(generatedTuple, actualRids);
00439 
00440     LcsRid endRid;
00441     uint rowCount = generatedEntry.getRowCount();
00442     if (rowCount == 1) {
00443         // singleton
00444         endRid = expectedRids[ridPos] + 1;
00445     } else {
00446         endRid =
00447             LbmSegment::roundToByteBoundary(expectedRids[ridPos]) + rowCount;
00448     }
00449 
00450     uint i;
00451     for (i = 0;
00452         ridPos < expectedRids.size() && expectedRids[ridPos] < endRid &&
00453             i < actualRids.size();
00454         i++, ridPos++)
00455     {
00456         if (expectedRids[ridPos] != actualRids[i]) {
00457             break;
00458         }
00459         // the two if blocks below are redundant but are there to test the
00460         // containsRid() method; the first tests the positive case and the
00461         // second the negative
00462         if (!generatedEntry.containsRid(expectedRids[ridPos])) {
00463             std::cout << "Positive containsRid check failed on rid = " <<
00464                 expectedRids[ridPos] << std::endl;
00465             return false;
00466         }
00467         // search for the rids in between the current and next; these should
00468         // not be set in the entry
00469         if (testContains) {
00470             if (ridPos + 1 < expectedRids.size()) {
00471                 for (LcsRid nextRid = expectedRids[ridPos] + 1;
00472                     nextRid < expectedRids[ridPos + 1]; nextRid++)
00473                 {
00474                     if (generatedEntry.containsRid(nextRid)) {
00475                         std::cout << "Negative containsRid check failed" <<
00476                            " on rid = " << nextRid << std::endl;
00477                         return false;
00478                     }
00479                 }
00480             }
00481         }
00482     }
00483 #if 0
00484     std::cout << "Generated Entry:" << LbmEntry::toString(generatedTuple, true)
00485         << std::endl;
00486 #endif
00487     if (i < actualRids.size()) {
00488         std::cout << "Mismatch in rid.  Actual = " << actualRids[i] <<
00489             ", Expected = " << expectedRids[ridPos] << std::endl;
00490         return false;
00491     }
00492     return true;
00493 }

void LbmEntryTest::recurseCombos ( uint  curr,
uint  nEntries,
VectorOfUint eTypes 
) [private]

Definition at line 924 of file LbmEntryTest.cpp.

References entryTuple, entryTupleDesc, generateBitmaps(), and testMergeEntry().

Referenced by testCombos().

00926 {
00927     std::vector<LcsRid> ridValues;
00928     VectorOfUint nRidsPerBitmap;
00929 
00930     uint nETypes = (curr == 0) ? 3 : 9;
00931     for (uint i = 0; i < nETypes; i++) {
00932         eTypes[curr] = i;
00933         if (curr < nEntries - 1) {
00934             recurseCombos(curr + 1, nEntries, eTypes);
00935         } else {
00936             // generate the "nEntries" bitmaps
00937             for (uint n = 0; n < nEntries; n++) {
00938                 generateBitmaps(
00939                     EntryType(eTypes[n]), ridValues, nRidsPerBitmap);
00940             }
00941 
00942             // generate the last entry
00943             ridValues.push_back(ridValues.back() + 16);
00944             nRidsPerBitmap.push_back(1);
00945 
00946             // merge them
00947             testMergeEntry(ridValues, nRidsPerBitmap, nEntries * 24);
00948 
00949             ridValues.clear();
00950             nRidsPerBitmap.clear();
00951             entryTupleDesc.clear();
00952             entryTuple.clear();
00953         }
00954     }
00955 }

void LbmEntryTest::generateBitmaps ( EntryType  etype,
std::vector< LcsRid > &  ridValues,
VectorOfUint nRidsPerBitmap 
) [private]

Definition at line 957 of file LbmEntryTest.cpp.

References CMP_ADJ, CMP_NADJ, CMP_OVLP, generateCompressedBitmaps(), generateSingleBitmaps(), LbmSegment::LbmOneByteSize, SBM_ADJ, SBM_NADJ, SBM_OVLP, SGT_ADJ, SGT_NADJ, and SGT_OVLP.

Referenced by recurseCombos().

00960 {
00961     LcsRid prev;
00962 
00963     if (ridValues.size() == 0) {
00964         prev = LcsRid(1);
00965     } else {
00966         prev = ridValues.back();
00967     }
00968 
00969     switch (etype) {
00970     case SBM_ADJ:
00971         generateSingleBitmaps(
00972             ridValues, nRidsPerBitmap, prev + LbmSegment::LbmOneByteSize, 4);
00973         break;
00974     case SBM_NADJ:
00975         generateSingleBitmaps(
00976             ridValues, nRidsPerBitmap, prev + LbmSegment::LbmOneByteSize*2, 4);
00977         break;
00978     case SBM_OVLP:
00979         generateSingleBitmaps(ridValues, nRidsPerBitmap, prev + 2, 4);
00980         break;
00981     case SGT_ADJ:
00982         generateSingleBitmaps(
00983             ridValues, nRidsPerBitmap, prev + LbmSegment::LbmOneByteSize, 1);
00984         break;
00985     case SGT_NADJ:
00986         generateSingleBitmaps(
00987             ridValues, nRidsPerBitmap, prev + LbmSegment::LbmOneByteSize*2, 1);
00988         break;
00989     case SGT_OVLP:
00990         generateSingleBitmaps(ridValues, nRidsPerBitmap, prev + 2, 1);
00991         break;
00992     case CMP_ADJ:
00993         generateCompressedBitmaps(
00994             ridValues, nRidsPerBitmap, prev + LbmSegment::LbmOneByteSize, 10);
00995         break;
00996     case CMP_NADJ:
00997         generateCompressedBitmaps(
00998             ridValues, nRidsPerBitmap, prev + LbmSegment::LbmOneByteSize*2, 10);
00999         break;
01000     case CMP_OVLP:
01001         generateCompressedBitmaps(ridValues, nRidsPerBitmap, prev + 2, 10);
01002         break;
01003     }
01004 }

void LbmEntryTest::generateSingleBitmaps ( std::vector< LcsRid > &  ridValues,
VectorOfUint nRidsPerBitmap,
LcsRid  startRid,
uint  nRids 
) [private]

Definition at line 1006 of file LbmEntryTest.cpp.

References LbmSegment::LbmOneByteSize.

Referenced by generateBitmaps().

01009 {
01010     for (uint i = 0;  i < nRids; i++) {
01011         ridValues.push_back(startRid);
01012         startRid += LbmSegment::LbmOneByteSize;
01013     }
01014     nRidsPerBitmap.push_back(nRids);
01015 }

void LbmEntryTest::generateCompressedBitmaps ( std::vector< LcsRid > &  ridValues,
VectorOfUint nRidsPerBitmap,
LcsRid  startRid,
uint  nRids 
) [private]

Definition at line 1017 of file LbmEntryTest.cpp.

References LbmSegment::LbmOneByteSize.

Referenced by generateBitmaps().

01020 {
01021     for (uint i = 0; i < nRids; i++) {
01022         ridValues.push_back(startRid);
01023         startRid += LbmSegment::LbmOneByteSize*2;
01024     }
01025     nRidsPerBitmap.push_back(nRids);
01026 }

void LbmEntryTest::testMergeSingleton ( uint  scratchBufferSize,
const std::vector< LcsRid > &  ridValues,
uint  nSingletons,
bool  split 
) [private]

Main test routine for merging arbitrary singleton entries.

Parameters:
scratchBufferSize size of scratch buffer used to merge entry
ridValues initial rid values followed by the singleton rids that will be merged
nSingletons number of singleton entries to be merged
split true if splits are allowed during merges

Definition at line 1028 of file LbmEntryTest.cpp.

References attrDesc_bitmap, attrDesc_int64, bitmapColSize, compareExpected(), TupleData::compute(), entryTuple, entryTupleDesc, FixedBuffer, LbmEntry::init(), LbmEntry::mergeEntry(), StandardTypeDescriptorFactory::newDataType(), LbmEntry::setEntryTuple(), LbmEntry::setRID(), STANDARD_TYPE_INT_64, STANDARD_TYPE_VARBINARY, and stdTypeFactory.

Referenced by testMergeSingletonAfterSplit(), testMergeSingletonCombine(), testMergeSingletonEndSegment(), testMergeSingletonInBetweenSegment(), testMergeSingletonInFront1(), testMergeSingletonInFront2(), testMergeSingletonMaxSeg(), testMergeSingletonMidSegment1(), testMergeSingletonMidSegment2(), testMergeSingletonMidSegment3(), testMergeSingletonMidSegment4(), testMergeSingletonRandom(), testMergeSingletonSplitHalf(), testMergeSingletonSplitLast(), testMergeSingletonSplitLeft1(), testMergeSingletonSplitLeft2(), testMergeSingletonSplitMaxSegments(), testMergeSingletonSplitRight1(), testMergeSingletonSplitRight2(), testMergeSingletonStartSegment1(), testMergeSingletonStartSegment2(), testMergeSingletonWithSingleton1(), testMergeSingletonWithSingleton2(), testMergeSingletonZeros1(), testMergeSingletonZeros2(), testMergeSingletonZeros3(), and testMergeSingletonZeros4().

01031 {
01032     // bitmap entries will be created without a leading key, so the
01033     // first column is the startRid
01034 
01035     bitmapColSize = scratchBufferSize;
01036     attrDesc_bitmap =
01037         TupleAttributeDescriptor(
01038             stdTypeFactory.newDataType(STANDARD_TYPE_VARBINARY),
01039             true, bitmapColSize);
01040     attrDesc_int64 =
01041         TupleAttributeDescriptor(
01042             stdTypeFactory.newDataType(STANDARD_TYPE_INT_64));
01043 
01044     entryTupleDesc.push_back(attrDesc_int64);
01045     entryTupleDesc.push_back(attrDesc_bitmap);
01046     entryTupleDesc.push_back(attrDesc_bitmap);
01047     entryTuple.compute(entryTupleDesc);
01048     entryTuple[1].pData = NULL;
01049     entryTuple[2].pData = NULL;
01050 
01051     // generate the entry that the singleton will splice into
01052     LbmEntry lbmEntry;
01053     boost::scoped_array<FixedBuffer> buf, buf2;
01054     buf.reset(new FixedBuffer[scratchBufferSize]);
01055     buf2.reset(new FixedBuffer[scratchBufferSize]);
01056     lbmEntry.init(buf.get(), buf2.get(), scratchBufferSize, entryTupleDesc);
01057     entryTuple[0].pData = (PConstBuffer) &(ridValues[0]);
01058     lbmEntry.setEntryTuple(entryTuple);
01059 
01060     uint totalRids = ridValues.size();
01061     for (uint i = 1; i < totalRids - nSingletons; i++) {
01062         bool rc = lbmEntry.setRID(ridValues[i]);
01063         // make sure there is enough space to fit the initial set of rids
01064         BOOST_REQUIRE(rc);
01065     }
01066 
01067     std::vector<LcsRid> sortedRids;
01068     sortedRids.assign(ridValues.begin(), ridValues.end());
01069     std::sort(sortedRids.begin(), sortedRids.end());
01070 #if 0
01071     std::cout << "Sorted Rid Values" << std::endl;
01072     for (uint i = 0; i < sortedRids.size(); i++) {
01073         std::cout << sortedRids[i] << std::endl;
01074     }
01075 #endif
01076 
01077     // merge in the singletons and compare against the sorted original list
01078     // as entries fill up
01079     uint ridPos = 0;
01080     bool splitOccurred = false;
01081     for (uint i = 0; i < nSingletons; i++) {
01082         entryTuple[0].pData =
01083             (PConstBuffer) &(ridValues[totalRids - nSingletons + i]);
01084         entryTuple[1].pData = NULL;
01085         entryTuple[1].cbData = 0;
01086         entryTuple[2].pData = NULL;
01087         entryTuple[1].cbData = 0;
01088         if (!lbmEntry.mergeEntry(entryTuple)) {
01089             BOOST_REQUIRE(split);
01090             bool rc = compareExpected(lbmEntry, sortedRids, ridPos, true);
01091             BOOST_REQUIRE(rc);
01092             lbmEntry.setEntryTuple(entryTuple);
01093             splitOccurred = true;
01094         }
01095     }
01096 
01097     // compare the rids in the last entry
01098     if (ridPos < totalRids) {
01099         bool rc = compareExpected(lbmEntry, sortedRids, ridPos, true);
01100         BOOST_REQUIRE(rc);
01101     }
01102 
01103     BOOST_REQUIRE(ridPos == totalRids);
01104 
01105     BOOST_REQUIRE(!(split && !splitOccurred));
01106 }

void LbmEntryTest::testMergeSingletonRandom ( uint  totalRids,
uint  ridRange 
) [private]

Definition at line 1510 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by testMergeSingletonRandom1(), and testMergeSingletonRandom2().

01511 {
01512     std::vector<LcsRid> ridValues;
01513 
01514     // generate random rid values, ensuring that they are unique
01515     LcsRid rid = LcsRid(rand() % ridRange);
01516     ridValues.push_back(rid);
01517     for (uint i = 1; i < totalRids;) {
01518         rid = LcsRid(rand() % ridRange);
01519         uint j;
01520         for (j = 0; j < i; j++) {
01521             if (rid == ridValues[j]) {
01522                 break;
01523             }
01524         }
01525         if (j >= i) {
01526             ridValues.push_back(rid);
01527             i++;
01528             continue;
01529         }
01530     }
01531 
01532 #if 0
01533     std::cout << "Original Rid Values" << std::endl;
01534     for (uint i = 0; i < ridValues.size(); i++) {
01535         std::cout << ridValues[i] << std::endl;
01536     }
01537 #endif
01538 
01539     // the first rid becomes the initial entry and the rest are the singleton
01540     // rids
01541     uint scratchBufferSize = totalRids * 5 + 8;
01542     testMergeSingleton(scratchBufferSize, ridValues, totalRids - 1, false);
01543 }

void LbmEntryTest::testCaseSetUp (  )  [virtual]

Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked.

Default is no-op.

Reimplemented from TestBase.

Definition at line 1576 of file LbmEntryTest.cpp.

References DeviceMode::createNew, and SegStorageTestBase::openStorage().

01577 {
01578     openStorage(DeviceMode::createNew);
01579 }

void LbmEntryTest::testCaseTearDown (  )  [virtual]

Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked.

Default is no-op.

Reimplemented from CacheTestBase.

Definition at line 1581 of file LbmEntryTest.cpp.

References entryTupleDesc, and CacheTestBase::testCaseTearDown().

01582 {
01583     SegStorageTestBase::testCaseTearDown();
01584     entryTupleDesc.clear();
01585 }

void LbmEntryTest::testRandom1 (  ) 

Definition at line 212 of file LbmEntryTest.cpp.

References testRandom().

Referenced by LbmEntryTest().

00213 {
00214     uint nUniqueKeys = 10;
00215     uint nRows = 1000;
00216     uint scratchBufferSize = 40;
00217 
00218     testRandom(nUniqueKeys, nRows, scratchBufferSize);
00219 }

void LbmEntryTest::testRandom2 (  ) 

Definition at line 221 of file LbmEntryTest.cpp.

References testRandom().

Referenced by LbmEntryTest().

00222 {
00223     uint nUniqueKeys = 30;
00224     uint nRows = 2000;
00225     uint scratchBufferSize = 50;
00226 
00227     testRandom(nUniqueKeys, nRows, scratchBufferSize);
00228 }

void LbmEntryTest::testRandom3 (  ) 

Definition at line 230 of file LbmEntryTest.cpp.

References testRandom().

Referenced by LbmEntryTest().

00231 {
00232     uint nUniqueKeys = 25;
00233     uint nRows = 1500;
00234     uint scratchBufferSize = 30;
00235 
00236     testRandom(nUniqueKeys, nRows, scratchBufferSize);
00237 }

void LbmEntryTest::testRandom4 (  ) 

Definition at line 239 of file LbmEntryTest.cpp.

References testRandom().

Referenced by LbmEntryTest().

00240 {
00241     uint nUniqueKeys = 20;
00242     uint nRows = 2500;
00243     uint scratchBufferSize = 35;
00244 
00245     testRandom(nUniqueKeys, nRows, scratchBufferSize);
00246 }

void LbmEntryTest::testRandom5 (  ) 

Definition at line 248 of file LbmEntryTest.cpp.

References testRandom().

Referenced by LbmEntryTest().

00249 {
00250     uint nUniqueKeys = 15;
00251     uint nRows = 3000;
00252     uint scratchBufferSize = 45;
00253 
00254     testRandom(nUniqueKeys, nRows, scratchBufferSize);
00255 }

void LbmEntryTest::testCombos (  ) 

Definition at line 913 of file LbmEntryTest.cpp.

References recurseCombos().

Referenced by LbmEntryTest().

00914 {
00915     uint nEntries = 5;
00916     VectorOfUint eTypes;
00917 
00918     for (uint i = 0; i < nEntries; i++) {
00919         eTypes.push_back(0);
00920     }
00921     recurseCombos(0, nEntries, eTypes);
00922 }

void LbmEntryTest::testldb35 (  ) 

Definition at line 495 of file LbmEntryTest.cpp.

References SegPageLock::accessSegment(), allocateBuf(), attrDesc_bitmap, attrDesc_int64, bitmapColSize, bufSize, bufUsed, compareExpected(), TupleData::compute(), entryTuple, entryTupleDesc, LbmEntry::getScratchBufferSize(), LbmEntry::init(), LbmSegment::LbmOneByteSize, LbmEntry::mergeEntry(), StandardTypeDescriptorFactory::newDataType(), NULL_PAGE_ID, opaqueToInt(), CacheTestBase::pCache, SegmentAccessor::pSegment, SegStorageTestBase::pSegmentFactory, LbmSegment::roundToByteBoundary(), LbmEntry::setEntryTuple(), STANDARD_TYPE_INT_64, STANDARD_TYPE_VARBINARY, and stdTypeFactory.

Referenced by LbmEntryTest().

00496 {
00497     std::vector<SharedLbmEntryInfo> entryList;
00498     std::vector<LcsRid> ridValues;
00499 
00500     // bitmap entries will be created without a leading key, so the
00501     // first column is the startRid
00502     // initialize scratch accessor for scratch buffers used to
00503     // construct bitmaps
00504     SegmentAccessor scratchAccessor =
00505         pSegmentFactory->newScratchSegment(pCache, 10);
00506     bufSize = scratchAccessor.pSegment->getUsablePageSize();
00507     SegPageLock bufferLock;
00508     bufferLock.accessSegment(scratchAccessor);
00509     bufUsed = bufSize;
00510 
00511     bitmapColSize = 16;
00512     attrDesc_bitmap =
00513         TupleAttributeDescriptor(
00514             stdTypeFactory.newDataType(STANDARD_TYPE_VARBINARY),
00515             true, bitmapColSize);
00516     attrDesc_int64 =
00517         TupleAttributeDescriptor(
00518             stdTypeFactory.newDataType(STANDARD_TYPE_INT_64));
00519 
00520     entryTupleDesc.push_back(attrDesc_int64);
00521     entryTupleDesc.push_back(attrDesc_bitmap);
00522     entryTupleDesc.push_back(attrDesc_bitmap);
00523     entryTuple.compute(entryTupleDesc);
00524 
00525     SharedLbmEntryInfo pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00526 
00527     // first entry -- single bitmap with rid 98601
00528 
00529     pListElement->pBuf = allocateBuf(bufferLock);
00530     pListElement->entry.init(
00531         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00532         entryTupleDesc);
00533     entryList.push_back(pListElement);
00534     LcsRid rid = LcsRid(98061);
00535     ridValues.push_back(rid);
00536     LcsRid roundedRid = LbmSegment::roundToByteBoundary(rid);
00537     entryTuple[0].pData = (PConstBuffer) &roundedRid;
00538     entryTuple[1].pData = NULL;
00539     uint8_t byte =
00540         (uint8_t) (1 << (opaqueToInt(rid) % LbmSegment::LbmOneByteSize));
00541     entryTuple[2].pData = &byte;
00542     entryTuple[2].cbData = 1;
00543     entryList.back()->entry.setEntryTuple(entryTuple);
00544 
00545     // second entry -- compressed bitmap with only rid 98070 set
00546 
00547     pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00548     pListElement->pBuf = allocateBuf(bufferLock);
00549     pListElement->entry.init(
00550         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00551         entryTupleDesc);
00552     entryList.push_back(pListElement);
00553     rid = LcsRid(98070);
00554     ridValues.push_back(rid);
00555     roundedRid = LbmSegment::roundToByteBoundary(rid);
00556     entryTuple[0].pData = (PConstBuffer) &roundedRid;
00557     uint8_t twoBytes[2];
00558     twoBytes[0] = 0xd;
00559     twoBytes[1] = 0xf0;
00560     entryTuple[1].pData = twoBytes;
00561     entryTuple[1].cbData = 2;
00562     byte = (uint8_t) (1 << (opaqueToInt(rid) % LbmSegment::LbmOneByteSize));
00563     entryTuple[2].pData = &byte;
00564     entryTuple[2].cbData = 1;
00565     entryList.back()->entry.setEntryTuple(entryTuple);
00566 
00567     // third entry -- compressed bitmap with only rid 99992 set
00568 
00569     pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00570     pListElement->pBuf = allocateBuf(bufferLock);
00571     pListElement->entry.init(
00572         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00573         entryTupleDesc);
00574     entryList.push_back(pListElement);
00575     rid = LcsRid(99992);
00576     ridValues.push_back(rid);
00577     roundedRid = LbmSegment::roundToByteBoundary(rid);
00578     entryTuple[0].pData = (PConstBuffer) &roundedRid;
00579     twoBytes[0] = 0xd;
00580     twoBytes[1] = 0x10;
00581     entryTuple[1].pData = twoBytes;
00582     entryTuple[1].cbData = 2;
00583     byte = (uint8_t) (1 << (opaqueToInt(rid) % LbmSegment::LbmOneByteSize));
00584     entryTuple[2].pData = &byte;
00585     entryTuple[2].cbData = 1;
00586     entryList.back()->entry.setEntryTuple(entryTuple);
00587 
00588     // fourth entry -- singleton with rid 100133
00589 
00590     pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00591     pListElement->pBuf = allocateBuf(bufferLock);
00592     pListElement->entry.init(
00593         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00594         entryTupleDesc);
00595     entryList.push_back(pListElement);
00596     rid = LcsRid(100133);
00597     ridValues.push_back(rid);
00598     entryTuple[0].pData = (PConstBuffer) &rid;
00599     entryTuple[1].pData = NULL;
00600     entryTuple[2].pData = NULL;
00601     entryList.back()->entry.setEntryTuple(entryTuple);
00602 
00603     // fifth entry -- singleton with rid 100792
00604 
00605     pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00606     pListElement->pBuf = allocateBuf(bufferLock);
00607     pListElement->entry.init(
00608         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00609         entryTupleDesc);
00610     entryList.push_back(pListElement);
00611     rid = LcsRid(100792);
00612     ridValues.push_back(rid);
00613     entryTuple[0].pData = (PConstBuffer) &rid;
00614     entryTuple[1].pData = NULL;
00615     entryTuple[2].pData = NULL;
00616     entryList.back()->entry.setEntryTuple(entryTuple);
00617 
00618     // produce the tuples corresponding to each LbmEntry
00619     for (uint i = 0; i < entryList.size(); i++) {
00620         entryList[i]->entryTuple = entryList[i]->entry.produceEntryTuple();
00621     }
00622 
00623     uint ridPos = 0;
00624     PBuffer mergeBuf = allocateBuf(bufferLock);
00625     LbmEntry mEntry;
00626     mEntry.init(
00627         mergeBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00628         entryTupleDesc);
00629 
00630     mEntry.setEntryTuple(entryList[0]->entryTuple);
00631     for (uint i = 1; i < entryList.size(); i++) {
00632         if (mEntry.mergeEntry(entryList[i]->entryTuple)) {
00633             continue;
00634         }
00635         // not able to merge, so need to produce entry and compare against
00636         // expected rids before starting to merge on the next entry
00637         bool rc = compareExpected(mEntry, ridValues, ridPos, true);
00638         BOOST_REQUIRE(rc);
00639         mEntry.setEntryTuple(entryList[i]->entryTuple);
00640     }
00641     // if this is the last remaining entry, compare it against
00642     // expected rid values
00643     if (ridPos < ridValues.size()) {
00644         bool rc = compareExpected(mEntry, ridValues, ridPos, true);
00645         BOOST_REQUIRE(rc);
00646     }
00647 
00648     BOOST_REQUIRE(ridPos == ridValues.size());
00649 
00650     scratchAccessor.pSegment->deallocatePageRange(NULL_PAGE_ID, NULL_PAGE_ID);
00651 }

void LbmEntryTest::testler5920 (  ) 

Definition at line 653 of file LbmEntryTest.cpp.

References SegPageLock::accessSegment(), allocateBuf(), attrDesc_bitmap, attrDesc_int64, bitmapColSize, bufSize, bufUsed, compareExpected(), TupleData::compute(), entryTuple, entryTupleDesc, LbmEntry::getScratchBufferSize(), LbmEntry::init(), LbmSegment::LbmOneByteSize, LbmEntry::mergeEntry(), StandardTypeDescriptorFactory::newDataType(), NULL_PAGE_ID, opaqueToInt(), CacheTestBase::pCache, SegmentAccessor::pSegment, SegStorageTestBase::pSegmentFactory, LbmEntry::setEntryTuple(), STANDARD_TYPE_INT_64, STANDARD_TYPE_VARBINARY, and stdTypeFactory.

Referenced by LbmEntryTest().

00654 {
00655     std::vector<SharedLbmEntryInfo> entryList;
00656     std::vector<LcsRid> ridValues;
00657 
00658     // bitmap entries will be created without a leading key, so the
00659     // first column is the startRid
00660     // initialize scratch accessor for scratch buffers used to
00661     // construct bitmaps
00662     SegmentAccessor scratchAccessor =
00663         pSegmentFactory->newScratchSegment(pCache, 10);
00664     bufSize = scratchAccessor.pSegment->getUsablePageSize();
00665     SegPageLock bufferLock;
00666     bufferLock.accessSegment(scratchAccessor);
00667     bufUsed = bufSize;
00668 
00669     bitmapColSize = 16;
00670     attrDesc_bitmap =
00671         TupleAttributeDescriptor(
00672             stdTypeFactory.newDataType(STANDARD_TYPE_VARBINARY),
00673             true, bitmapColSize);
00674     attrDesc_int64 =
00675         TupleAttributeDescriptor(
00676             stdTypeFactory.newDataType(STANDARD_TYPE_INT_64));
00677 
00678     entryTupleDesc.push_back(attrDesc_int64);
00679     entryTupleDesc.push_back(attrDesc_bitmap);
00680     entryTupleDesc.push_back(attrDesc_bitmap);
00681     entryTuple.compute(entryTupleDesc);
00682 
00683     SharedLbmEntryInfo pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00684 
00685     // first entry -- full bitmap
00686 
00687     pListElement->pBuf = allocateBuf(bufferLock);
00688     pListElement->entry.init(
00689         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00690         entryTupleDesc);
00691     entryList.push_back(pListElement);
00692     LcsRid rid = LcsRid(0);
00693     ridValues.push_back(rid);
00694     entryTuple[0].pData = (PConstBuffer) &rid;
00695     entryTuple[1].cbData = 0;
00696     entryTuple[1].pData = NULL;
00697     entryTuple[2].cbData = 0;
00698     entryTuple[2].pData = NULL;
00699     entryList.back()->entry.setEntryTuple(entryTuple);
00700     for (uint i = 0; i < bitmapColSize - 2; i++) {
00701         rid = LcsRid((i + 1) * 8);
00702         entryList.back()->entry.setRID(rid);
00703         ridValues.push_back(rid);
00704     }
00705     LcsRid overlapStartRid = LcsRid((bitmapColSize - 2) * 8);
00706 
00707     // second entry -- compressed bitmap that overlaps the last byte of the
00708     // first entry
00709 
00710     pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00711     pListElement->pBuf = allocateBuf(bufferLock);
00712     pListElement->entry.init(
00713         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00714         entryTupleDesc);
00715     entryList.push_back(pListElement);
00716     entryTuple[0].pData = (PConstBuffer) &overlapStartRid;
00717     entryTuple[1].pData = NULL;
00718     entryTuple[1].cbData = 0;
00719     rid = LcsRid(overlapStartRid + 4);
00720     ridValues.push_back(rid);
00721     uint8_t byte =
00722         (uint8_t) (1 << (opaqueToInt(rid) % LbmSegment::LbmOneByteSize));
00723     rid = LcsRid(overlapStartRid + 5);
00724     ridValues.push_back(rid);
00725     byte |= (uint8_t) (1 << (opaqueToInt(rid) % LbmSegment::LbmOneByteSize));
00726     entryTuple[2].pData = &byte;
00727     entryTuple[2].cbData = 1;
00728     entryList.back()->entry.setEntryTuple(entryTuple);
00729 
00730     // third entry -- singleton
00731 
00732     pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00733     pListElement->pBuf = allocateBuf(bufferLock);
00734     pListElement->entry.init(
00735         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00736         entryTupleDesc);
00737     entryList.push_back(pListElement);
00738     rid = LcsRid(overlapStartRid + 8 + 2);
00739     ridValues.push_back(rid);
00740     entryTuple[0].pData = (PConstBuffer) &rid;
00741     entryTuple[1].pData = NULL;
00742     entryTuple[1].cbData = 0;
00743     entryTuple[2].pData = NULL;
00744     entryTuple[2].cbData = 0;
00745     entryList.back()->entry.setEntryTuple(entryTuple);
00746 
00747     // produce the tuples corresponding to each LbmEntry
00748     for (uint i = 0; i < entryList.size(); i++) {
00749         entryList[i]->entryTuple = entryList[i]->entry.produceEntryTuple();
00750     }
00751 
00752     uint ridPos = 0;
00753     PBuffer mergeBuf = allocateBuf(bufferLock);
00754     LbmEntry mEntry;
00755     mEntry.init(
00756         mergeBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00757         entryTupleDesc);
00758 
00759     mEntry.setEntryTuple(entryList[0]->entryTuple);
00760 
00761     // merge the the overlapping byte; mergeEntry should return true
00762     bool rc = mEntry.mergeEntry(entryList[1]->entryTuple);
00763     BOOST_REQUIRE(rc);
00764 
00765     // this merge should overflow the currentEntry
00766     rc = mEntry.mergeEntry(entryList[2]->entryTuple);
00767     BOOST_REQUIRE(!rc);
00768     rc = compareExpected(mEntry, ridValues, ridPos, true);
00769     BOOST_REQUIRE(rc);
00770 
00771     // make sure the previous merge didn't add any extra rids
00772     mEntry.setEntryTuple(entryList[2]->entryTuple);
00773     rc = compareExpected(mEntry, ridValues, ridPos, true);
00774     BOOST_REQUIRE(rc);
00775 
00776     scratchAccessor.pSegment->deallocatePageRange(NULL_PAGE_ID, NULL_PAGE_ID);
00777 }

void LbmEntryTest::testZeroBytes (  ) 

Definition at line 779 of file LbmEntryTest.cpp.

References SegPageLock::accessSegment(), allocateBuf(), attrDesc_bitmap, attrDesc_int64, bitmapColSize, bufSize, bufUsed, compareExpected(), TupleData::compute(), entryTuple, entryTupleDesc, LbmEntry::getScratchBufferSize(), LbmEntry::init(), LbmSegment::LbmOneByteSize, LbmEntry::mergeEntry(), StandardTypeDescriptorFactory::newDataType(), NULL_PAGE_ID, opaqueToInt(), CacheTestBase::pCache, SegmentAccessor::pSegment, SegStorageTestBase::pSegmentFactory, LbmSegment::roundToByteBoundary(), LbmEntry::setEntryTuple(), STANDARD_TYPE_INT_64, STANDARD_TYPE_VARBINARY, and stdTypeFactory.

Referenced by LbmEntryTest().

00780 {
00781     // Exercise creating bitmaps that contain zero bytes requiring various
00782     // lengths to encode.
00783 
00784     std::vector<SharedLbmEntryInfo> entryList;
00785     std::vector<LcsRid> ridValues;
00786 
00787     SegmentAccessor scratchAccessor =
00788         pSegmentFactory->newScratchSegment(pCache, 10);
00789     bufSize = scratchAccessor.pSegment->getUsablePageSize();
00790     SegPageLock bufferLock;
00791     bufferLock.accessSegment(scratchAccessor);
00792     bufUsed = bufSize;
00793 
00794     bitmapColSize = 16;
00795     attrDesc_bitmap =
00796         TupleAttributeDescriptor(
00797             stdTypeFactory.newDataType(STANDARD_TYPE_VARBINARY),
00798             true, bitmapColSize);
00799     attrDesc_int64 =
00800         TupleAttributeDescriptor(
00801             stdTypeFactory.newDataType(STANDARD_TYPE_INT_64));
00802 
00803     entryTupleDesc.push_back(attrDesc_int64);
00804     entryTupleDesc.push_back(attrDesc_bitmap);
00805     entryTupleDesc.push_back(attrDesc_bitmap);
00806     entryTuple.compute(entryTupleDesc);
00807 
00808     SharedLbmEntryInfo pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00809 
00810     // 1st entry -- start with rid 1
00811 
00812     pListElement->pBuf = allocateBuf(bufferLock);
00813     pListElement->entry.init(
00814         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00815         entryTupleDesc);
00816     entryList.push_back(pListElement);
00817     LcsRid rid = LcsRid(1);
00818     ridValues.push_back(rid);
00819     LcsRid roundedRid = LbmSegment::roundToByteBoundary(rid);
00820     entryTuple[0].pData = (PConstBuffer) &roundedRid;
00821     entryTuple[1].pData = NULL;
00822     uint8_t byte =
00823         (uint8_t) (1 << (opaqueToInt(rid) % LbmSegment::LbmOneByteSize));
00824     entryTuple[2].pData = &byte;
00825     entryTuple[2].cbData = 1;
00826     entryList.back()->entry.setEntryTuple(entryTuple);
00827 
00828     // 2nd entry -- previous rid + 2^16*8.  This will require 2 bytes to store
00829     // the zero bytes in between this rid and the previous.
00830 
00831     pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00832     pListElement->pBuf = allocateBuf(bufferLock);
00833     pListElement->entry.init(
00834         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00835         entryTupleDesc);
00836     entryList.push_back(pListElement);
00837     rid = LcsRid(rid + (int64_t) pow(2.0,16.0)*8);
00838     ridValues.push_back(rid);
00839     entryTuple[0].pData = (PConstBuffer) &rid;
00840     entryTuple[1].pData = NULL;
00841     entryTuple[2].pData = NULL;
00842     entryList.back()->entry.setEntryTuple(entryTuple);
00843 
00844     // 3rd entry -- previous rid + 2^24*8.  This will require 3 bytes to
00845     // store the zero bytes in between this rid and the previous.
00846 
00847     pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00848     pListElement->pBuf = allocateBuf(bufferLock);
00849     pListElement->entry.init(
00850         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00851         entryTupleDesc);
00852     entryList.push_back(pListElement);
00853     rid = LcsRid(rid + (int64_t) pow(2.0,24.0)*8);
00854     ridValues.push_back(rid);
00855     entryTuple[0].pData = (PConstBuffer) &rid;
00856     entryTuple[1].pData = NULL;
00857     entryTuple[2].pData = NULL;
00858     entryList.back()->entry.setEntryTuple(entryTuple);
00859 
00860     // 4th entry -- previous rid + ((2^24)+1)*8.  The zero bytes in this case
00861     // cannot be encoded in 3 bytes, so a new bitmap entry will be created.
00862 
00863     pListElement = SharedLbmEntryInfo(new LbmEntryInfo());
00864     pListElement->pBuf = allocateBuf(bufferLock);
00865     pListElement->entry.init(
00866         pListElement->pBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00867         entryTupleDesc);
00868     entryList.push_back(pListElement);
00869     rid = LcsRid(rid + (int64_t) (pow(2.0,24.0)+1)*8);
00870     ridValues.push_back(rid);
00871     entryTuple[0].pData = (PConstBuffer) &rid;
00872     entryTuple[1].pData = NULL;
00873     entryTuple[2].pData = NULL;
00874     entryList.back()->entry.setEntryTuple(entryTuple);
00875 
00876     // produce the tuples corresponding to each LbmEntry
00877     for (uint i = 0; i < entryList.size(); i++) {
00878         entryList[i]->entryTuple = entryList[i]->entry.produceEntryTuple();
00879     }
00880 
00881     uint ridPos = 0;
00882     PBuffer mergeBuf = allocateBuf(bufferLock);
00883     LbmEntry mEntry;
00884     mEntry.init(
00885         mergeBuf, NULL, LbmEntry::getScratchBufferSize(bitmapColSize),
00886         entryTupleDesc);
00887 
00888     mEntry.setEntryTuple(entryList[0]->entryTuple);
00889     for (uint i = 1; i < entryList.size(); i++) {
00890         if (mEntry.mergeEntry(entryList[i]->entryTuple)) {
00891             continue;
00892         }
00893         // not able to merge, so need to produce entry and compare against
00894         // expected rids before starting to merge on the next entry; pass
00895         // in false for the testContains parameter to avoid excessive
00896         // containsRids() calls
00897         bool rc = compareExpected(mEntry, ridValues, ridPos, false);
00898         BOOST_REQUIRE(rc);
00899         mEntry.setEntryTuple(entryList[i]->entryTuple);
00900     }
00901     // if this is the last remaining entry, compare it against
00902     // expected rid values
00903     if (ridPos < ridValues.size()) {
00904         bool rc = compareExpected(mEntry, ridValues, ridPos, false);
00905         BOOST_REQUIRE(rc);
00906     }
00907 
00908     BOOST_REQUIRE(ridPos == ridValues.size());
00909 
00910     scratchAccessor.pSegment->deallocatePageRange(NULL_PAGE_ID, NULL_PAGE_ID);
00911 }

void LbmEntryTest::testMergeSingletonInFront1 (  ) 

Definition at line 1108 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01109 {
01110     std::vector<LcsRid> ridValues;
01111 
01112     ridValues.push_back(LcsRid(9));
01113     ridValues.push_back(LcsRid(18));
01114     ridValues.push_back(LcsRid(27));
01115     ridValues.push_back(LcsRid(60));
01116     ridValues.push_back(LcsRid(77));
01117 
01118     // singleton rid needs to be in a byte in front of the current entry
01119     ridValues.push_back(LcsRid(1));
01120     testMergeSingleton(24, ridValues, 1, false);
01121 }

void LbmEntryTest::testMergeSingletonInFront2 (  ) 

Definition at line 1123 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01124 {
01125     std::vector<LcsRid> ridValues;
01126 
01127     ridValues.push_back(LcsRid(20));
01128 
01129     // singleton rid needs to be in a byte in front of the current entry --
01130     // current entry is also a singleton
01131     ridValues.push_back(LcsRid(1));
01132     testMergeSingleton(24, ridValues, 1, false);
01133 }

void LbmEntryTest::testMergeSingletonMidSegment1 (  ) 

Definition at line 1135 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01136 {
01137     std::vector<LcsRid> ridValues;
01138 
01139     ridValues.push_back(LcsRid(9));
01140     ridValues.push_back(LcsRid(18));
01141     ridValues.push_back(LcsRid(27));
01142     ridValues.push_back(LcsRid(60));
01143     ridValues.push_back(LcsRid(77));
01144 
01145     // singleton rid will be set in an existing rid range -- first rid in
01146     // segment
01147     ridValues.push_back(LcsRid(8));
01148     testMergeSingleton(24, ridValues, 1, false);
01149 }

void LbmEntryTest::testMergeSingletonMidSegment2 (  ) 

Definition at line 1151 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01152 {
01153     std::vector<LcsRid> ridValues;
01154 
01155     ridValues.push_back(LcsRid(9));
01156     ridValues.push_back(LcsRid(18));
01157     ridValues.push_back(LcsRid(27));
01158     ridValues.push_back(LcsRid(60));
01159     ridValues.push_back(LcsRid(77));
01160 
01161     // singleton rid will be set in an existing rid range -- rid in the middle
01162     ridValues.push_back(LcsRid(17));
01163     testMergeSingleton(24, ridValues, 1, false);
01164 }

void LbmEntryTest::testMergeSingletonMidSegment3 (  ) 

Definition at line 1166 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01167 {
01168     std::vector<LcsRid> ridValues;
01169 
01170     ridValues.push_back(LcsRid(9));
01171     ridValues.push_back(LcsRid(18));
01172     ridValues.push_back(LcsRid(27));
01173     ridValues.push_back(LcsRid(60));
01174     ridValues.push_back(LcsRid(77));
01175 
01176     // singleton rid will be set in an existing rid range -- rid at the end
01177     ridValues.push_back(LcsRid(31));
01178     testMergeSingleton(24, ridValues, 1, false);
01179 }

void LbmEntryTest::testMergeSingletonMidSegment4 (  ) 

Definition at line 1181 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01182 {
01183     std::vector<LcsRid> ridValues;
01184 
01185     ridValues.push_back(LcsRid(9));
01186     ridValues.push_back(LcsRid(18));
01187     ridValues.push_back(LcsRid(27));
01188     ridValues.push_back(LcsRid(60));
01189     ridValues.push_back(LcsRid(77));
01190 
01191     // singleton rid will be set in an existing rid range -- rid in the 2nd
01192     // byte segment
01193     ridValues.push_back(LcsRid(56));
01194     testMergeSingleton(24, ridValues, 1, false);
01195 }

void LbmEntryTest::testMergeSingletonEndSegment (  ) 

Definition at line 1197 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01198 {
01199     std::vector<LcsRid> ridValues;
01200 
01201     ridValues.push_back(LcsRid(9));
01202     ridValues.push_back(LcsRid(18));
01203     ridValues.push_back(LcsRid(27));
01204     ridValues.push_back(LcsRid(60));
01205     ridValues.push_back(LcsRid(77));
01206 
01207     // singleton rid is in the byte adjacent to the last byte in a segment
01208     ridValues.push_back(LcsRid(33));
01209     testMergeSingleton(24, ridValues, 1, false);
01210 }

void LbmEntryTest::testMergeSingletonStartSegment1 (  ) 

Definition at line 1212 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01213 {
01214     std::vector<LcsRid> ridValues;
01215 
01216     ridValues.push_back(LcsRid(9));
01217     ridValues.push_back(LcsRid(18));
01218     ridValues.push_back(LcsRid(27));
01219     ridValues.push_back(LcsRid(60));
01220     ridValues.push_back(LcsRid(77));
01221 
01222     // singleton rid is in the byte in front of the first byte in a segment
01223     // that's not the first byte in an entry -- last bit in new segment
01224     ridValues.push_back(LcsRid(55));
01225     testMergeSingleton(24, ridValues, 1, false);
01226 }

void LbmEntryTest::testMergeSingletonStartSegment2 (  ) 

Definition at line 1228 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01229 {
01230     std::vector<LcsRid> ridValues;
01231 
01232     ridValues.push_back(LcsRid(9));
01233     ridValues.push_back(LcsRid(18));
01234     ridValues.push_back(LcsRid(27));
01235     ridValues.push_back(LcsRid(60));
01236     ridValues.push_back(LcsRid(77));
01237 
01238     // singleton rid is in the byte in front of the first byte in a segment
01239     // that's not the first byte in an entry -- first bit in new segment
01240     ridValues.push_back(LcsRid(64));
01241     testMergeSingleton(24, ridValues, 1, false);
01242 }

void LbmEntryTest::testMergeSingletonInBetweenSegment (  ) 

Definition at line 1244 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01245 {
01246     std::vector<LcsRid> ridValues;
01247 
01248     ridValues.push_back(LcsRid(9));
01249     ridValues.push_back(LcsRid(18));
01250     ridValues.push_back(LcsRid(27));
01251     ridValues.push_back(LcsRid(60));
01252     ridValues.push_back(LcsRid(77));
01253 
01254     // singleton rid is in a byte currently represented by trailing zeros, but
01255     // the new byte is not adjacent to an existing segment
01256     ridValues.push_back(LcsRid(40));
01257     testMergeSingleton(24, ridValues, 1, false);
01258 }

void LbmEntryTest::testMergeSingletonSplitLeft1 (  ) 

Definition at line 1260 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01261 {
01262     std::vector<LcsRid> ridValues;
01263 
01264     ridValues.push_back(LcsRid(9));
01265     ridValues.push_back(LcsRid(18));
01266     ridValues.push_back(LcsRid(27));
01267     ridValues.push_back(LcsRid(60));
01268     ridValues.push_back(LcsRid(77));
01269 
01270     // singleton rid goes to the left side of the split entry -- at the end
01271     // of the new split entry
01272     ridValues.push_back(LcsRid(39));
01273     testMergeSingleton(19, ridValues, 1, true);
01274 }

void LbmEntryTest::testMergeSingletonSplitLeft2 (  ) 

Definition at line 1276 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01277 {
01278     std::vector<LcsRid> ridValues;
01279 
01280     ridValues.push_back(LcsRid(9));
01281     ridValues.push_back(LcsRid(35));
01282     ridValues.push_back(LcsRid(60));
01283     ridValues.push_back(LcsRid(77));
01284 
01285     // singleton rid goes to the left side of the split entry -- move a
01286     // segment from the left to the right to minimize the space in the entry
01287     // that the new rid will be inserted into
01288     ridValues.push_back(LcsRid(18));
01289     testMergeSingleton(19, ridValues, 1, true);
01290 }

void LbmEntryTest::testMergeSingletonSplitRight1 (  ) 

Definition at line 1292 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01293 {
01294     std::vector<LcsRid> ridValues;
01295 
01296     ridValues.push_back(LcsRid(9));
01297     ridValues.push_back(LcsRid(18));
01298     ridValues.push_back(LcsRid(27));
01299     ridValues.push_back(LcsRid(60));
01300     ridValues.push_back(LcsRid(85));
01301 
01302     // singleton rid goes to the right side of the split entry -- in the middle
01303     // of the split entry
01304     ridValues.push_back(LcsRid(71));
01305     testMergeSingleton(19, ridValues, 1, true);
01306 }

void LbmEntryTest::testMergeSingletonSplitRight2 (  ) 

Definition at line 1308 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01309 {
01310     std::vector<LcsRid> ridValues;
01311 
01312     ridValues.push_back(LcsRid(544));
01313     ridValues.push_back(LcsRid(560));
01314     ridValues.push_back(LcsRid(576));
01315     ridValues.push_back(LcsRid(1088));
01316 
01317     // singleton rid goes to the right side of the split entry -- ensure
01318     // entry is split at the appropriate boundary; otherwise, there won't
01319     // be space in the split entry
01320     ridValues.push_back(LcsRid(832));
01321     testMergeSingleton(20, ridValues, 1, true);
01322 }

void LbmEntryTest::testMergeSingletonSplitHalf (  ) 

Definition at line 1324 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01325 {
01326     std::vector<LcsRid> ridValues;
01327 
01328     ridValues.push_back(LcsRid(9));
01329     ridValues.push_back(LcsRid(18));
01330     ridValues.push_back(LcsRid(27));
01331     ridValues.push_back(LcsRid(539));
01332 
01333     // only 2 segments with the left segment being bigger; ensure that the new
01334     // rid fits when merged into the left entry
01335     ridValues.push_back(LcsRid(283));
01336     testMergeSingleton(18, ridValues, 1, true);
01337 }

void LbmEntryTest::testMergeSingletonSplitLast (  ) 

Definition at line 1339 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01340 {
01341     std::vector<LcsRid> ridValues;
01342 
01343     ridValues.push_back(LcsRid(9));
01344     ridValues.push_back(LcsRid(18));
01345     ridValues.push_back(LcsRid(27));
01346     ridValues.push_back(LcsRid(48));
01347     ridValues.push_back(LcsRid(60));
01348     ridValues.push_back(LcsRid(64));
01349     ridValues.push_back(LcsRid(77));
01350     ridValues.push_back(LcsRid(87));
01351     ridValues.push_back(LcsRid(95));
01352     ridValues.push_back(LcsRid(96));
01353 
01354     // singleton rid goes to the left side of the split entry; only the last
01355     // segment in the original is split to the right
01356     ridValues.push_back(LcsRid(47));
01357     testMergeSingleton(23, ridValues, 1, true);
01358 }

void LbmEntryTest::testMergeSingletonSplitMaxSegments (  ) 

Definition at line 1360 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01361 {
01362     std::vector<LcsRid> ridValues;
01363 
01364     ridValues.push_back(LcsRid(0));
01365     // create several segments that max out at 16 bytes
01366     for (int i = 250; i < 600; i += 8) {
01367         ridValues.push_back(LcsRid(i));
01368     }
01369     ridValues.push_back(LcsRid(617));
01370 
01371     // inserting a new rid requires spltting in between two of the 16-byte
01372     // segments
01373     ridValues.push_back(LcsRid(125));
01374     testMergeSingleton(63, ridValues, 1, true);
01375 }

void LbmEntryTest::testMergeSingletonZeros1 (  ) 

Definition at line 1377 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01378 {
01379     std::vector<LcsRid> ridValues;
01380 
01381     ridValues.push_back(LcsRid(4));
01382     // (12+2)*8 = 112
01383     ridValues.push_back(LcsRid(114));
01384     ridValues.push_back(LcsRid(123));
01385 
01386     // singleton rid replaces a trailing zero byte, which results in the
01387     // number of trailing zero bytes decreasing by 1
01388     ridValues.push_back(LcsRid(47));
01389     testMergeSingleton(24, ridValues, 1, false);
01390 }

void LbmEntryTest::testMergeSingletonZeros2 (  ) 

Definition at line 1392 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01393 {
01394     std::vector<LcsRid> ridValues;
01395 
01396     ridValues.push_back(LcsRid(4));
01397     // ((2^16)+1)*8 = 524288 (3 bytes required to encode zero length)
01398     ridValues.push_back(LcsRid(524296));
01399     ridValues.push_back(LcsRid(524305));
01400 
01401     // singleton rid replaces a trailing zero byte, which results in the
01402     // number of trailing zero bytes decreasing by 1; new byte is adjacent
01403     // to first
01404     ridValues.push_back(LcsRid(13));
01405     testMergeSingleton(24, ridValues, 1, false);
01406 }

void LbmEntryTest::testMergeSingletonZeros3 (  ) 

Definition at line 1408 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01409 {
01410     std::vector<LcsRid> ridValues;
01411 
01412     ridValues.push_back(LcsRid(4));
01413     // (12+2)*8 = 112
01414     ridValues.push_back(LcsRid(114));
01415     ridValues.push_back(LcsRid(123));
01416 
01417     // singleton rid replaces a trailing zero byte, which results in the
01418     // number of trailing zero bytes decreasing by 1 but addition of new
01419     // segment requires a split of the current entry
01420     ridValues.push_back(LcsRid(60));
01421     testMergeSingleton(17, ridValues, 1, true);
01422 }

void LbmEntryTest::testMergeSingletonZeros4 (  ) 

Definition at line 1424 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01425 {
01426     std::vector<LcsRid> ridValues;
01427 
01428     ridValues.push_back(LcsRid(4));
01429     // (12+2)*8 = 112
01430     ridValues.push_back(LcsRid(114));
01431     ridValues.push_back(LcsRid(123));
01432 
01433     // current entry is currently at max size; adding a new singleton rid
01434     // requires a new segment but doing so does not require a split because
01435     // the new segment replaces the trailing zero byte
01436     ridValues.push_back(LcsRid(13));
01437     testMergeSingleton(17, ridValues, 1, false);
01438 }

void LbmEntryTest::testMergeSingletonAfterSplit (  ) 

Definition at line 1458 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01459 {
01460     std::vector<LcsRid> ridValues;
01461 
01462     ridValues.push_back(LcsRid(9));
01463     ridValues.push_back(LcsRid(18));
01464     ridValues.push_back(LcsRid(27));
01465     ridValues.push_back(LcsRid(48));
01466     ridValues.push_back(LcsRid(60));
01467     ridValues.push_back(LcsRid(64));
01468     ridValues.push_back(LcsRid(77));
01469     ridValues.push_back(LcsRid(87));
01470     ridValues.push_back(LcsRid(95));
01471     ridValues.push_back(LcsRid(96));
01472 
01473     // singleton rid goes to the left side of the split entry; only the last
01474     // segment in the original is split to the right; add another singleton
01475     // after the split
01476     ridValues.push_back(LcsRid(33));
01477     ridValues.push_back(LcsRid(47));
01478     testMergeSingleton(23, ridValues, 2, true);
01479 }

void LbmEntryTest::testMergeSingletonCombine (  ) 

Definition at line 1440 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01441 {
01442     std::vector<LcsRid> ridValues;
01443 
01444     ridValues.push_back(LcsRid(9));
01445     ridValues.push_back(LcsRid(18));
01446     ridValues.push_back(LcsRid(27));
01447     ridValues.push_back(LcsRid(60));
01448     ridValues.push_back(LcsRid(77));
01449     ridValues.push_back(LcsRid(86));
01450     ridValues.push_back(LcsRid(111));
01451 
01452     // singleton rid goes in the middle of 2 segments, which results in the 3
01453     // segments being combined into 1
01454     ridValues.push_back(LcsRid(71));
01455     testMergeSingleton(24, ridValues, 1, false);
01456 }

void LbmEntryTest::testMergeSingletonMaxSeg (  ) 

Definition at line 1481 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01482 {
01483     std::vector<LcsRid> ridValues;
01484 
01485     ridValues.push_back(LcsRid(0));
01486 
01487     ridValues.push_back(LcsRid(27));
01488     ridValues.push_back(LcsRid(36));
01489     ridValues.push_back(LcsRid(45));
01490     ridValues.push_back(LcsRid(54));
01491     ridValues.push_back(LcsRid(63));
01492     ridValues.push_back(LcsRid(64));
01493     ridValues.push_back(LcsRid(72));
01494     ridValues.push_back(LcsRid(81));
01495     ridValues.push_back(LcsRid(90));
01496     ridValues.push_back(LcsRid(99));
01497     ridValues.push_back(LcsRid(108));
01498     ridValues.push_back(LcsRid(117));
01499     ridValues.push_back(LcsRid(126));
01500     ridValues.push_back(LcsRid(135));
01501     ridValues.push_back(LcsRid(136));
01502     ridValues.push_back(LcsRid(145));
01503 
01504     // attempt to insert singleton rid in front of a segment that currently
01505     // has a segment length of 16
01506     ridValues.push_back(LcsRid(18));
01507     testMergeSingleton(32, ridValues, 1, false);
01508 }

void LbmEntryTest::testMergeSingletonRandom1 (  ) 

Definition at line 1545 of file LbmEntryTest.cpp.

References testMergeSingletonRandom().

Referenced by LbmEntryTest().

01546 {
01547     testMergeSingletonRandom(50, 1000);
01548 }

void LbmEntryTest::testMergeSingletonRandom2 (  ) 

Definition at line 1550 of file LbmEntryTest.cpp.

References testMergeSingletonRandom().

Referenced by LbmEntryTest().

01551 {
01552     testMergeSingletonRandom(100, 10000);
01553 }

void LbmEntryTest::testMergeSingletonWithSingleton1 (  ) 

Definition at line 1555 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01556 {
01557     std::vector<LcsRid> ridValues;
01558 
01559     ridValues.push_back(LcsRid(7));
01560 
01561     ridValues.push_back(LcsRid(1));
01562     testMergeSingleton(16, ridValues, 1, false);
01563 }

void LbmEntryTest::testMergeSingletonWithSingleton2 (  ) 

Definition at line 1565 of file LbmEntryTest.cpp.

References testMergeSingleton().

Referenced by LbmEntryTest().

01566 {
01567     std::vector<LcsRid> ridValues;
01568 
01569     ridValues.push_back(LcsRid(50));
01570 
01571     ridValues.push_back(LcsRid(1));
01572     // not enough space so the entries should get split into 2
01573     testMergeSingleton(10, ridValues, 1, true);
01574 }

void SegStorageTestBase::openStorage ( DeviceMode  openMode  )  [virtual, inherited]

Reimplemented from CacheTestBase.

Reimplemented in SegmentTestBase.

Definition at line 31 of file SegStorageTestBase.cpp.

References SegStorageTestBase::openSegmentStorage(), and CacheTestBase::openStorage().

Referenced by SegStorageTestBase::openRandomSegment(), SegmentTestBase::openStorage(), LhxHashTableTest::testCaseSetUp(), ExecStreamTestBase::testCaseSetUp(), BTreeTest::testCaseSetUp(), BTreeReadersTest::testCaseSetUp(), testCaseSetUp(), SegPageIterTest::testIter(), SegPageEntryIterTest::testIter(), SegStreamTest::testMarkReset(), SegStreamTest::testReadSeg(), LogicalTxnTest::testTxn(), SegStreamTest::testWriteSeg(), and SegStreamTest::testWriteSpillAndRead().

00032 {
00033     CacheTestBase::openStorage(openMode);
00034     openSegmentStorage(openMode);
00035 }

void SegStorageTestBase::openSegmentStorage ( DeviceMode  openMode  )  [virtual, inherited]

Reimplemented in LinearViewSegmentTest, SnapshotSegmentTestBase, and VersionedSegmentTest.

Definition at line 37 of file SegStorageTestBase.cpp.

References CacheTestBase::cbPageFull, DeviceMode::create, SegStorageTestBase::createLinearDeviceSegment(), CacheTestBase::dataDeviceId, SegStorageTestBase::pLinearSegment, and CacheTestBase::pRandomAccessDevice.

Referenced by VersionedSegmentTest::openSegmentStorage(), and SegStorageTestBase::openStorage().

00038 {
00039     pLinearSegment = createLinearDeviceSegment(
00040         dataDeviceId,
00041         openMode.create ? 0
00042         : pRandomAccessDevice->getSizeInBytes() / cbPageFull);
00043 }

void SegStorageTestBase::openRandomSegment (  )  [virtual, inherited]

Reimplemented in LcsClusterReplaceExecStreamTest.

Definition at line 45 of file SegStorageTestBase.cpp.

References SegStorageTestBase::closeStorage(), DeviceMode::load, SegStorageTestBase::openStorage(), SegStorageTestBase::pLinearSegment, SegStorageTestBase::pRandomSegment, and SegStorageTestBase::pSegmentFactory.

Referenced by RandomAllocationSegmentTest::testAllocateAndDeallocate(), LhxHashTableTest::testCaseSetUp(), ExecStreamUnitTestBase::testCaseSetUp(), BTreeTest::testCaseSetUp(), and BTreeReadersTest::testCaseSetUp().

00046 {
00047     // reopen will interpret pages as already allocated, which
00048     // is what RandomAllocationSegment expects
00049     closeStorage();
00050     openStorage(DeviceMode::load);
00051     pRandomSegment = pSegmentFactory->newRandomAllocationSegment(
00052         pLinearSegment, true);
00053     pLinearSegment.reset();
00054 }

SharedSegment SegStorageTestBase::createLinearDeviceSegment ( DeviceId  deviceId,
uint  nPages 
) [inherited]

Definition at line 56 of file SegStorageTestBase.cpp.

References LinearDeviceSegmentParams::firstBlockId, LinearDeviceSegmentParams::nPagesAllocated, LinearDeviceSegmentParams::nPagesMin, CacheTestBase::pCache, SegStorageTestBase::pSegmentFactory, CompoundId::setBlockNum(), and CompoundId::setDeviceId().

Referenced by VersionedSegmentTest::openSegmentStorage(), SnapshotSegmentTestBase::openSegmentStorage(), SegStorageTestBase::openSegmentStorage(), and LinearViewSegmentTest::openSegmentStorage().

00058 {
00059     BlockId blockId(0);
00060     CompoundId::setDeviceId(blockId,deviceId);
00061     CompoundId::setBlockNum(blockId,0);
00062     LinearDeviceSegmentParams deviceParams;
00063     deviceParams.firstBlockId = blockId;
00064     deviceParams.nPagesMin = nPages;
00065     deviceParams.nPagesAllocated = nPages;
00066     return pSegmentFactory->newLinearDeviceSegment(
00067         pCache,deviceParams);
00068 }

void SegStorageTestBase::closeLinearSegment (  )  [inherited]

Definition at line 70 of file SegStorageTestBase.cpp.

References SegStorageTestBase::pLinearSegment.

Referenced by VersionedSegmentTest::closeStorage(), SnapshotSegmentTestBase::closeStorage(), SegStorageTestBase::closeStorage(), and SnapshotSegmentTest::testUncommittedReads().

00071 {
00072     if (pLinearSegment) {
00073         assert(pLinearSegment.unique());
00074         pLinearSegment.reset();
00075     }
00076 }

void SegStorageTestBase::closeRandomSegment (  )  [inherited]

Definition at line 78 of file SegStorageTestBase.cpp.

References SegStorageTestBase::pRandomSegment.

Referenced by VersionedSegmentTest::closeStorage(), and SegStorageTestBase::closeStorage().

00079 {
00080     if (pRandomSegment) {
00081         assert(pRandomSegment.unique());
00082         pRandomSegment.reset();
00083     }
00084 }

void SegStorageTestBase::closeVersionedRandomSegment (  )  [inherited]

Definition at line 86 of file SegStorageTestBase.cpp.

References SegStorageTestBase::pVersionedRandomSegment.

Referenced by SnapshotSegmentTestBase::closeStorage(), and SegStorageTestBase::closeStorage().

00087 {
00088     if (pVersionedRandomSegment) {
00089         assert(pVersionedRandomSegment.unique());
00090         pVersionedRandomSegment.reset();
00091     }
00092 }

void SegStorageTestBase::closeSnapshotRandomSegment (  )  [inherited]

Definition at line 94 of file SegStorageTestBase.cpp.

References SegStorageTestBase::pSnapshotRandomSegment.

Referenced by SnapshotSegmentTestBase::closeStorage().

00095 {
00096     if (pSnapshotRandomSegment) {
00097         assert(pSnapshotRandomSegment.unique());
00098         pSnapshotRandomSegment.reset();
00099     }
00100 }

void SegStorageTestBase::closeStorage (  )  [virtual, inherited]

Reimplemented from CacheTestBase.

Reimplemented in SnapshotSegmentTestBase, and VersionedSegmentTest.

Definition at line 102 of file SegStorageTestBase.cpp.

References SegStorageTestBase::closeLinearSegment(), SegStorageTestBase::closeRandomSegment(), CacheTestBase::closeStorage(), and SegStorageTestBase::closeVersionedRandomSegment().

Referenced by VersionedSegmentTest::closeStorage(), SnapshotSegmentTestBase::closeStorage(), SegStorageTestBase::openRandomSegment(), SegPageIterTest::testIter(), SegPageEntryIterTest::testIter(), SegStreamTest::testMarkReset(), SegStreamTest::testReadSeg(), SegmentTestBase::testSingleThread(), SegStreamTest::testWriteSeg(), and SegStreamTest::testWriteSpillAndRead().

00103 {
00104     closeLinearSegment();
00105     closeRandomSegment();
00106     closeVersionedRandomSegment();
00107     // TODO:  assert pSegmentFactory.unique(), but not here
00108     CacheTestBase::closeStorage();
00109 }

Cache & CacheTestBase::getCache (  )  [inherited]

Definition at line 42 of file CacheTestBase.cpp.

References CacheTestBase::pCache.

Referenced by CacheTest::lockPage(), CacheTest::prefetchBatch(), SegmentTestBase::prefetchPage(), CacheTest::prefetchPage(), PagingTestBase::testCacheResize(), PagingTestBase::testCheckpoint(), PagingTestBase::testOp(), PagingTestBase::testScratch(), SegmentTestBase::unlockPage(), and CacheTest::unlockPage().

00043 {
00044     return *pCache;
00045 }

SharedCache CacheTestBase::newCache (  )  [virtual, inherited]

Definition at line 66 of file CacheTestBase.cpp.

References CacheTestBase::cacheParams, Cache::newCache(), CacheTestBase::victimLRU, CacheTestBase::victimPolicy, CacheTestBase::victimRandom, and CacheTestBase::victimTwoQ.

Referenced by CacheTestBase::openStorage().

00067 {
00068     switch (victimPolicy) {
00069     case victimRandom:
00070         return SharedCache(
00071             new RandomCache(cacheParams),
00072             ClosableObjectDestructor());
00073     case victimLRU:
00074         return SharedCache(
00075             new LRUCache(cacheParams),
00076             ClosableObjectDestructor());
00077     case victimTwoQ:
00078         return Cache::newCache(cacheParams);
00079     default:
00080         permAssert(false);
00081     }
00082 }

SharedRandomAccessDevice CacheTestBase::openDevice ( std::string  devName,
DeviceMode  openMode,
uint  nDevicePages,
DeviceId  deviceId 
) [inherited]

Definition at line 84 of file CacheTestBase.cpp.

References CacheTestBase::cbPageFull, DeviceMode::create, CacheTestBase::pCache, and FileSystem::remove().

Referenced by VersionedSegmentTest::openSegmentStorage(), SnapshotSegmentTestBase::openSegmentStorage(), and CacheTestBase::openStorage().

00087 {
00088     if (openMode.create) {
00089         FileSystem::remove(devName.c_str());
00090     }
00091     SharedRandomAccessDevice pDevice(
00092         new RandomAccessFileDevice(devName,openMode));
00093     if (openMode.create) {
00094         pDevice->setSizeInBytes(nDevicePages*cbPageFull);
00095     }
00096     pCache->registerDevice(deviceId,pDevice);
00097     return pDevice;
00098 }

void CacheTestBase::closeDevice ( DeviceId  deviceId,
SharedRandomAccessDevice pDevice 
) [inherited]

Definition at line 130 of file CacheTestBase.cpp.

References CHECKPOINT_FLUSH_AND_UNMAP, and CacheTestBase::pCache.

Referenced by VersionedSegmentTest::closeStorage(), SnapshotSegmentTestBase::closeStorage(), and CacheTestBase::closeStorage().

00132 {
00133     if (!pDevice) {
00134         return;
00135     }
00136     DeviceIdPagePredicate pagePredicate(deviceId);
00137     pCache->checkpointPages(pagePredicate,CHECKPOINT_FLUSH_AND_UNMAP);
00138     pCache->unregisterDevice(deviceId);
00139     assert(pDevice.unique());
00140     pDevice.reset();
00141 }

void TestBase::snooze ( uint  nSeconds  )  [protected, inherited]

Definition at line 263 of file TestBase.cpp.

Referenced by DatabaseTest::executeForceTxn(), ThreadedTestBase::runThreadedTestCase(), PagingTestBase::testCacheResize(), BTreeTxnTest::testCheckpoint(), PagingTestBase::testCheckpointGuarded(), PagingTestBase::testPrefetch(), and PagingTestBase::testPrefetchBatch().

00264 {
00265 #ifdef __MSVC__
00266     ::_sleep(nSeconds*1000);
00267 #else
00268     ::sleep(nSeconds);
00269 #endif
00270 }

void TestBase::readParams ( int  argc,
char **  argv 
) [static, inherited]

Parses the command line.

format: [-v] [-t TEST | -all] {param=val}* [CONFIGFILE | -] Normally, the test program runs the default test cases. With the option "-all", runs the extra test cases as well. With the option "-t TEST", runs only the single test case named TEST. CONFIGFILE is read to load configuration parameters. Configuration parameters can also be set ad hoc, from the command line, as pairs name=val. These take precedence.

Definition at line 108 of file TestBase.cpp.

References TestBase::configMap, ConfigMap::dumpParams(), ConfigMap::isParamSet(), ConfigMap::mergeFrom(), TestBase::paramDictionaryFileName, ConfigMap::readParams(), TestBase::runAll, TestBase::runSingle, ConfigMap::setStringParam(), and verbose.

00109 {
00110     bool verbose = false;
00111     ConfigMap adhocMap;
00112 
00113     for (int i = 1; i < argc; ++i) {
00114         std::string arg = argv[i];
00115         if (argv[i][0] == '-') {
00116             if (arg == "-v") {
00117                 verbose = true;
00118             } else if (arg == "-") {
00119                 configMap.readParams(std::cin);
00120             } else if (arg == "-all") {
00121                 runAll = true;
00122             } else if (arg == "-t") {   // -t TEST
00123                 permAssert(i + 1 < argc);
00124                 runSingle = argv[++i];
00125             } else if (arg[1] == 't') { // allow -tTEST
00126                 runSingle = arg.substr(2);
00127             }
00128         } else {
00129             int i = arg.find("=");
00130             if ((0 < i) && (i < arg.size())) {
00131                 // an ad hoc parameter
00132                 std::string key = arg.substr(0,i);
00133                 std::string val = arg.substr(i + 1);
00134                 adhocMap.setStringParam(key,val);
00135             } else {
00136                 // a config file name
00137                 std::ifstream configFile(arg.c_str());
00138                 assert(configFile.good());
00139                 configMap.readParams(configFile);
00140             }
00141         }
00142     }
00143     configMap.mergeFrom(adhocMap);
00144 
00145     // set a default dictionary file location for use by tests that need a
00146     // small non-random sorted data set
00147     if (!configMap.isParamSet(paramDictionaryFileName)) {
00148         std::string dictFileName = "dictWords";
00149         configMap.setStringParam(paramDictionaryFileName,dictFileName);
00150     }
00151 
00152     if (verbose) {
00153         configMap.dumpParams(std::cout);
00154     }
00155 }

TestSuite * TestBase::releaseTestSuite (  )  [inherited]

Definition at line 157 of file TestBase.cpp.

References TestBase::TestCaseGroup::addAllToTestSuite(), TestBase::defaultTests, TestBase::extraTests, TestBase::TestCaseGroup::findTest(), TestBase::pTestObj, TestBase::pTestSuite, TestBase::runAll, TestBase::runSingle, and TestBase::testName.

00158 {
00159     assert(pTestObj);
00160     assert(pTestObj.use_count() > 1);
00161 
00162     // release self-reference now that all test cases have been registered
00163     pTestObj.reset();
00164 
00165     TestSuite* pTestSuite = BOOST_TEST_SUITE(testName.c_str());
00166 
00167     if (runSingle.size()) {
00168         test_unit *p =  defaultTests.findTest(runSingle);
00169         if (!p) {
00170             p = extraTests.findTest(runSingle);
00171         }
00172         if (!p) {
00173             std::cerr << "test " << runSingle << " not found\n";
00174             exit(2);
00175         }
00176         pTestSuite->add(p);
00177     } else {
00178         defaultTests.addAllToTestSuite(pTestSuite);
00179         if (runAll) {
00180             extraTests.addAllToTestSuite(pTestSuite);
00181         }
00182     }
00183     return pTestSuite;
00184 }

void TestBase::beforeTestCase ( std::string  testCaseName  )  [inherited]

Definition at line 214 of file TestBase.cpp.

References TestBase::configMap, TraceSource::initTraceSource(), AutoBacktrace::install(), TestBase::notifyTrace(), AutoBacktrace::setOutputStream(), AutoBacktrace::setTraceTarget(), TestBase::testName, and TRACE_INFO.

00215 {
00216     notifyTrace(testName,TRACE_INFO,"ENTER:  " + testCaseName);
00217 
00218     // Install the AutoBacktrace signal handler now, after
00219     // boost::execution_monitor::catch_signals() has installed its own, so that
00220     // on SIGABRT AutoBacktrace goes first, prints the backtrace, then chains
00221     // to boost, which handles the error.
00222     AutoBacktrace::setOutputStream();
00223     AutoBacktrace::setTraceTarget(shared_from_this());
00224     AutoBacktrace::install();
00225     configMap.initTraceSource(shared_from_this(), "testConfig");
00226 }

void TestBase::afterTestCase ( std::string  testCaseName  )  [inherited]

Definition at line 228 of file TestBase.cpp.

References TestBase::configMap, TraceSource::disableTracing(), TestBase::notifyTrace(), AutoBacktrace::setTraceTarget(), TestBase::testName, and TRACE_INFO.

00229 {
00230     AutoBacktrace::setTraceTarget();
00231     configMap.disableTracing();
00232     notifyTrace(testName,TRACE_INFO,"LEAVE:  " + testCaseName);
00233 }

void TestBase::notifyTrace ( std::string  source,
TraceLevel  level,
std::string  message 
) [virtual, inherited]

Receives notification when a trace event occurs.

Parameters:
source the facility from which the message originated
level the trace event severity level
message the text of the message

Implements TraceTarget.

Definition at line 243 of file TestBase.cpp.

References TestBase::traceFile, TestBase::traceMutex, TestBase::traceStdout, and TestBase::traceStream.

Referenced by TestBase::afterTestCase(), and TestBase::beforeTestCase().

00244 {
00245     if (traceFile || traceStdout) {
00246         StrictMutexGuard traceMutexGuard(traceMutex);
00247         if (traceFile) {
00248             traceStream << "[" << source << "] " << message << std::endl;
00249             traceStream.flush();
00250         }
00251         if (traceStdout) {
00252             std::cout << "[" << source << "] " << message << std::endl;
00253             std::cout.flush();
00254         }
00255     }
00256 }

TraceLevel TestBase::getSourceTraceLevel ( std::string  source  )  [virtual, inherited]

Gets the level at which a particular source should be traced.

Parameters:
source name of source to be traced
Returns:
minimum severity level which should be traced

Implements TraceTarget.

Definition at line 258 of file TestBase.cpp.

References TestBase::traceLevel.

Referenced by LbmExecStreamTestBase::generateBitmaps().

00259 {
00260     return traceLevel;
00261 }


Member Data Documentation

uint LbmEntryTest::bitmapColSize [private]

Definition at line 62 of file LbmEntryTest.cpp.

Referenced by allocateBuf(), newLbmEntry(), testldb35(), testler5920(), testMergeEntry(), testMergeSingleton(), and testZeroBytes().

StandardTypeDescriptorFactory LbmEntryTest::stdTypeFactory [private]

Definition at line 63 of file LbmEntryTest.cpp.

Referenced by testldb35(), testler5920(), testMergeEntry(), testMergeSingleton(), and testZeroBytes().

TupleAttributeDescriptor LbmEntryTest::attrDesc_bitmap [private]

Definition at line 64 of file LbmEntryTest.cpp.

Referenced by testldb35(), testler5920(), testMergeEntry(), testMergeSingleton(), and testZeroBytes().

TupleAttributeDescriptor LbmEntryTest::attrDesc_int64 [private]

Definition at line 65 of file LbmEntryTest.cpp.

Referenced by testldb35(), testler5920(), testMergeEntry(), testMergeSingleton(), and testZeroBytes().

TupleDescriptor LbmEntryTest::entryTupleDesc [private]

Definition at line 66 of file LbmEntryTest.cpp.

Referenced by newLbmEntry(), recurseCombos(), testCaseTearDown(), testldb35(), testler5920(), testMergeEntry(), testMergeSingleton(), and testZeroBytes().

uint LbmEntryTest::bufSize [private]

Definition at line 67 of file LbmEntryTest.cpp.

Referenced by allocateBuf(), testldb35(), testler5920(), testMergeEntry(), and testZeroBytes().

uint LbmEntryTest::bufUsed [private]

Definition at line 68 of file LbmEntryTest.cpp.

Referenced by allocateBuf(), testldb35(), testler5920(), testMergeEntry(), and testZeroBytes().

PBuffer LbmEntryTest::pBuf [private]

Definition at line 69 of file LbmEntryTest.cpp.

Referenced by allocateBuf().

TupleData LbmEntryTest::entryTuple [private]

Definition at line 70 of file LbmEntryTest.cpp.

Referenced by newLbmEntry(), recurseCombos(), testldb35(), testler5920(), testMergeEntry(), testMergeSingleton(), and testZeroBytes().

SharedSegmentFactory SegStorageTestBase::pSegmentFactory [protected, inherited]

Definition at line 40 of file SegStorageTestBase.h.

Referenced by BackupRestoreTest::backup(), SegStorageTestBase::createLinearDeviceSegment(), LogicalTxnTest::createRecoveryLog(), LbmSearchTest::initBTreeExecStreamParam(), LbmLoadBitmapTest::initBTreeExecStreamParam(), LcsClusterReplaceExecStreamTest::initClusterAppendParams(), LbmExecStreamTestBase::initSorterExecStream(), LcsMultiClusterAppendTest::loadClusters(), LcsRowScanExecStreamTest::loadOneCluster(), LbmSearchTest::loadTableAndIndex(), LbmMinusExecStreamTest::newMinusStream(), ExecStreamTestBase::newStreamGraphEmbryo(), SegStorageTestBase::openRandomSegment(), VersionedSegmentTest::openSegmentStorage(), SnapshotSegmentTestBase::openSegmentStorage(), LinearViewSegmentTest::openSegmentStorage(), BackupRestoreTest::restore(), SegStorageTestBase::SegStorageTestBase(), LbmSplicerExecStreamTest::spliceInput(), ExecStreamTestSuite::testBTreeInsertExecStream(), LhxHashTableTest::testCaseSetUp(), LcsClusterReplaceExecStreamTest::testClusterReplace(), LhxAggExecStreamTest::testCountImpl(), ExecStreamTestSuite::testDoubleBufferExecStream(), ExecStreamGovernorTest::testGovernor(), LhxAggExecStreamTest::testGroupCountImpl(), LhxJoinExecStreamTest::testImpl(), ExternalSortExecStreamTest::testImpl(), BTreeTest::testInserts(), LbmIntersectExecStreamTest::testIntersect(), testldb35(), testler5920(), LbmLoadBitmapTest::testLoad(), LcsClusterAppendExecStreamTest::testLoadMultiCol(), LcsClusterAppendExecStreamTest::testLoadSingleCol(), testMergeEntry(), BTreeTest::testMultiKeySearches(), BTreeTest::testScan(), ExecStreamTestSuite::testScratchBufferExecStream(), LhxAggExecStreamTest::testSingleValueImpl(), FlatFileExecStreamTest::testStream(), LhxAggExecStreamTest::testSumImpl(), LogicalTxnTest::testTxn(), SnapshotSegmentTest::testUncommittedReads(), LbmUnionExecStreamTest::testUnion(), SegStreamTest::testWriteSpillAndRead(), and testZeroBytes().

SharedSegment SegStorageTestBase::pLinearSegment [protected, inherited]

Segment supporting linear page allocation.

Definition at line 45 of file SegStorageTestBase.h.

Referenced by SegStorageTestBase::closeLinearSegment(), LogicalTxnTest::createRecoveryLog(), SegmentTestBase::lockPage(), SegStorageTestBase::openRandomSegment(), VersionedSegmentTest::openSegmentStorage(), SnapshotSegmentTestBase::openSegmentStorage(), SegStorageTestBase::openSegmentStorage(), LinearViewSegmentTest::openSegmentStorage(), SegmentTestBase::openStorage(), SegmentTestBase::prefetchPage(), SnapshotSegmentTestBase::testAllocateAll(), LinearViewSegmentTest::testAllocateAll(), VersionedSegmentTest::testCheckpoint(), SegmentTestBase::testCheckpoint(), SegPageIterTest::testIter(), SegPageEntryIterTest::testIter(), SegStreamTest::testMarkReset(), SegStreamTest::testReadSeg(), VersionedSegmentTest::testRecovery(), LogicalTxnTest::testTxn(), SnapshotSegmentTest::testUncommittedReads(), SegStreamTest::testWriteSeg(), and VersionedSegmentTest::verifyPage().

SharedSegment SegStorageTestBase::pRandomSegment [protected, inherited]

(Optional) segment supporting random page allocation.

Definition at line 50 of file SegStorageTestBase.h.

Referenced by SegStorageTestBase::closeRandomSegment(), SnapshotSegmentTestBase::closeStorage(), LbmSplicerExecStreamTest::createBTree(), LbmSplicerExecStreamTest::initBTreeParam(), LbmSearchTest::initBTreeParam(), LbmLoadBitmapTest::initBTreeParam(), LbmLoadBitmapTest::initBTreeTupleDesc(), LcsClusterReplaceExecStreamTest::initClusterAppendParams(), LbmExecStreamTestBase::initSorterExecStream(), LcsClusterReplaceExecStreamTest::loadCluster(), LcsMultiClusterAppendTest::loadClusters(), LcsRowScanExecStreamTest::loadOneCluster(), LbmSearchTest::loadTableAndIndex(), SegStorageTestBase::openRandomSegment(), SnapshotSegmentTestBase::openSegmentStorage(), LinearViewSegmentTest::openSegmentStorage(), SegmentTestBase::openStorage(), SegmentTestBase::testAllocate(), RandomAllocationSegmentTest::testAllocateAndDeallocate(), ExecStreamTestSuite::testBTreeInsertExecStream(), BTreeTest::testBulkLoad(), LhxHashTableTest::testCaseSetUp(), BTreeTest::testCaseSetUp(), BTreeReadersTest::testCaseSetUp(), LcsRowScanExecStreamTest::testCaseSetUp(), LcsMultiClusterAppendTest::testCaseSetUp(), LcsClusterReplaceExecStreamTest::testCaseSetUp(), LcsClusterAppendExecStreamTest::testCaseSetUp(), LbmExecStreamTestBase::testCaseSetUp(), LcsClusterReplaceExecStreamTest::testClusterReplace(), LhxAggExecStreamTest::testCountImpl(), SegmentTestBase::testDeallocate(), LhxAggExecStreamTest::testGroupCountImpl(), LhxJoinExecStreamTest::testImpl(), ExternalSortExecStreamTest::testImpl(), BTreeTest::testInserts(), LbmLoadBitmapTest::testLoad(), LcsClusterAppendExecStreamTest::testLoadMultiCol(), LcsClusterAppendExecStreamTest::testLoadSingleCol(), ExecStreamTestSuite::testMergeImplicitPullInputs(), BTreeTest::testMultiKeySearches(), BTreeReadersTest::testReaders(), LcsRowScanExecStreamTest::testScanOnEmptyCluster(), ExecStreamTestSuite::testSegBufferExecStream(), ExecStreamTestSuite::testSegBufferReaderWriterExecStream(), LhxAggExecStreamTest::testSingleValueImpl(), LhxAggExecStreamTest::testSumImpl(), and LbmUnionExecStreamTest::testUnion().

SharedSegment SegStorageTestBase::pVersionedRandomSegment [protected, inherited]

(Optional) segment supporting versioned random page allocation.

Definition at line 55 of file SegStorageTestBase.h.

Referenced by BackupRestoreTest::backup(), SnapshotSegmentTestBase::closeStorage(), SegStorageTestBase::closeVersionedRandomSegment(), SnapshotSegmentTest::deallocateOldPages(), SnapshotSegmentTestBase::openSegmentStorage(), BackupRestoreTest::restore(), LcsClusterReplaceExecStreamTest::testClusterReplace(), SnapshotSegmentTest::testRollback(), and SnapshotSegmentTest::testUncommittedReads().

SharedSegment SegStorageTestBase::pSnapshotRandomSegment [protected, inherited]

(Optional) segment supporting snapshot random page allocation.

Definition at line 60 of file SegStorageTestBase.h.

Referenced by SegStorageTestBase::closeSnapshotRandomSegment(), SnapshotSegmentTestBase::commitChanges(), SnapshotSegmentTestBase::openSegmentStorage(), LcsClusterReplaceExecStreamTest::testClusterReplace(), and SnapshotSegmentTest::testDeallocateOld().

VictimPolicy CacheTestBase::victimPolicy [protected, inherited]

VictimPolicy to instantiate.

Definition at line 53 of file CacheTestBase.h.

Referenced by CacheTestBase::CacheTestBase(), and CacheTestBase::newCache().

CacheParams CacheTestBase::cacheParams [protected, inherited]

Parameters for cache initialization.

Definition at line 58 of file CacheTestBase.h.

Referenced by CacheTestBase::CacheTestBase(), CacheTestBase::newCache(), BackupRestoreTest::testBackupCleanup(), BackupRestoreTest::testHeaderBackupRestore(), and SegPageEntryIterTest::testIter().

SharedCache CacheTestBase::pCache [protected, inherited]

Cache instance being tested.

Definition at line 63 of file CacheTestBase.h.

Referenced by BackupRestoreTest::backup(), CacheTestBase::closeDevice(), CacheTestBase::closeStorage(), LbmSplicerExecStreamTest::createBTree(), SegStorageTestBase::createLinearDeviceSegment(), LogicalTxnTest::createRecoveryLog(), BackupRestoreTest::createSnapshotData(), BackupRestoreTest::executeSnapshotTxn(), CacheTestBase::getCache(), LbmSearchTest::initBTreeExecStreamParam(), LbmLoadBitmapTest::initBTreeExecStreamParam(), LbmSearchTest::initBTreeParam(), LbmLoadBitmapTest::initBTreeParam(), LcsClusterReplaceExecStreamTest::initClusterAppendParams(), LbmExecStreamTestBase::initSorterExecStream(), LcsClusterReplaceExecStreamTest::loadCluster(), LcsMultiClusterAppendTest::loadClusters(), LcsRowScanExecStreamTest::loadOneCluster(), LbmSearchTest::loadTableAndIndex(), SegmentTestBase::lockPage(), LbmMinusExecStreamTest::newMinusStream(), ExecStreamTestBase::newStreamGraphEmbryo(), CacheTestBase::openDevice(), CacheTestBase::openStorage(), LcsClusterReplaceExecStreamTest::replaceCluster(), BackupRestoreTest::restore(), LbmSplicerExecStreamTest::spliceInput(), SegmentTestBase::testAllocate(), RandomAllocationSegmentTest::testAllocateAndDeallocate(), BackupRestoreTest::testBackupCleanup(), ExecStreamTestSuite::testBTreeInsertExecStream(), BTreeTest::testBulkLoad(), LhxHashTableTest::testCaseSetUp(), ExecStreamUnitTestBase::testCaseSetUp(), BTreeTest::testCaseSetUp(), BTreeReadersTest::testCaseSetUp(), LhxAggExecStreamTest::testCountImpl(), SegmentTestBase::testDeallocate(), SnapshotSegmentTest::testDeallocateOld(), ExecStreamTestSuite::testDoubleBufferExecStream(), ExecStreamGovernorTest::testGovernor(), LhxAggExecStreamTest::testGroupCountImpl(), BackupRestoreTest::testHeaderBackupRestore(), LhxJoinExecStreamTest::testImpl(), ExternalSortExecStreamTest::testImpl(), BTreeTest::testInserts(), LbmIntersectExecStreamTest::testIntersect(), SegPageIterTest::testIter(), SegPageEntryIterTest::testIter(), CacheTest::testLargeCacheInit(), CacheTest::testLargeCacheRequest(), testldb35(), testler5920(), LbmLoadBitmapTest::testLoad(), LcsClusterAppendExecStreamTest::testLoadMultiCol(), LcsClusterAppendExecStreamTest::testLoadSingleCol(), SegStreamTest::testMarkReset(), testMergeEntry(), BTreeTest::testMultiKeySearches(), CacheTest::testQuotaCacheAccessor(), BTreeReadersTest::testReaders(), SegStreamTest::testReadSeg(), BTreeTest::testScan(), LcsRowScanExecStreamTest::testScanOnEmptyCluster(), ExecStreamTestSuite::testScratchBufferExecStream(), LhxAggExecStreamTest::testSingleValueImpl(), FlatFileExecStreamTest::testStream(), LhxAggExecStreamTest::testSumImpl(), LogicalTxnTest::testTxn(), LogicalTxnTest::testTxnIdSequence(), LbmUnionExecStreamTest::testUnion(), SegStreamTest::testWriteSeg(), SegStreamTest::testWriteSpillAndRead(), testZeroBytes(), and BackupRestoreTest::verifySnapshotData().

SharedRandomAccessDevice CacheTestBase::pRandomAccessDevice [protected, inherited]

The default cached device.

Definition at line 68 of file CacheTestBase.h.

Referenced by BackupRestoreTest::backup(), CacheTestBase::closeStorage(), SegStorageTestBase::openSegmentStorage(), CacheTestBase::openStorage(), and BackupRestoreTest::restore().

uint CacheTestBase::nMemPages [protected, inherited]

Size of cache in memory pages.

Definition at line 73 of file CacheTestBase.h.

Referenced by CacheTestBase::CacheTestBase(), PagingTestBase::testCacheResize(), and ExecStreamTestBase::testCaseSetUp().

uint CacheTestBase::nDiskPages [protected, inherited]

Size of device in disk pages.

Definition at line 78 of file CacheTestBase.h.

Referenced by CacheTestBase::CacheTestBase(), LinearViewSegmentTest::LinearViewSegmentTest(), CacheTest::makeBlockId(), VersionedSegmentTest::openSegmentStorage(), SnapshotSegmentTestBase::openSegmentStorage(), LinearViewSegmentTest::openSegmentStorage(), CacheTestBase::openStorage(), SegStreamTest::SegStreamTest(), SnapshotSegmentTestBase::SnapshotSegmentTestBase(), SnapshotSegmentTest::testDeallocateOld(), PagingTestBase::testPrefetch(), PagingTestBase::testPrefetchBatch(), PagingTestBase::testRandomOp(), SnapshotSegmentTest::testRollback(), PagingTestBase::testSequentialOp(), and PagingTestBase::testSkipOp().

uint CacheTestBase::cbPageFull [protected, inherited]

Disk page size.

Definition at line 83 of file CacheTestBase.h.

Referenced by CacheTest::CacheTest(), CacheTestBase::CacheTestBase(), CacheTestBase::openDevice(), and SegStorageTestBase::openSegmentStorage().

DeviceId CacheTestBase::dataDeviceId [protected, inherited]

Fixed ID to assign to data device.

Definition at line 88 of file CacheTestBase.h.

Referenced by CacheTestBase::CacheTestBase(), CacheTestBase::closeStorage(), CacheTest::makeBlockId(), SnapshotSegmentTestBase::openSegmentStorage(), SegStorageTestBase::openSegmentStorage(), LinearViewSegmentTest::openSegmentStorage(), CacheTestBase::openStorage(), and PagingTestBase::testCheckpoint().

TestSuite* TestBase::pTestSuite [protected, inherited]

Boost test suite.

Definition at line 59 of file TestBase.h.

Referenced by TestBase::releaseTestSuite().

boost::shared_ptr<TestBase> TestBase::pTestObj [protected, inherited]

Definition at line 61 of file TestBase.h.

Referenced by TestBase::releaseTestSuite(), and TestBase::TestBase().

std::ofstream TestBase::traceStream [protected, inherited]

Output file stream for tracing.

Definition at line 66 of file TestBase.h.

Referenced by TestBase::notifyTrace(), TestBase::TestBase(), and TestBase::~TestBase().

StrictMutex TestBase::traceMutex [protected, inherited]

Protects traceStream.

Definition at line 71 of file TestBase.h.

Referenced by TestBase::notifyTrace().

std::string TestBase::testName [protected, inherited]

Name of test.

Definition at line 76 of file TestBase.h.

Referenced by TestBase::afterTestCase(), TestBase::beforeTestCase(), TestBase::releaseTestSuite(), TestBase::TestBase(), LhxHashTableTest::testInsert1Ka(), and LhxHashTableTest::testInsert1Kb().

TraceLevel TestBase::traceLevel [protected, inherited]

Level at which to trace test execution.

Definition at line 81 of file TestBase.h.

Referenced by TestBase::getSourceTraceLevel(), and TestBase::TestBase().

FileStatsTarget TestBase::statsTarget [protected, inherited]

Output for stats.

Definition at line 86 of file TestBase.h.

StatsTimer TestBase::statsTimer [protected, inherited]

Timer for stats collection.

Definition at line 91 of file TestBase.h.

Referenced by CacheTestBase::closeStorage(), CacheTestBase::openStorage(), BTreeTxnTest::testCaseSetUp(), BTreeTxnTest::testCaseTearDown(), and BTreeTxnTest::testTxns().

bool TestBase::traceStdout [protected, inherited]

Copy trace output to stdout.

Definition at line 99 of file TestBase.h.

Referenced by TestBase::notifyTrace(), and TestBase::TestBase().

bool TestBase::traceFile [protected, inherited]

Copy trace output to file.

Definition at line 104 of file TestBase.h.

Referenced by TestBase::notifyTrace(), and TestBase::TestBase().

bool TestBase::runAll [static, protected, inherited]

Run all test cases, including the extra tests.

(static, since set by readParams())

Definition at line 110 of file TestBase.h.

Referenced by TestBase::readParams(), and TestBase::releaseTestSuite().

std::string TestBase::runSingle [static, protected, inherited]

Run only the test case of this name.

(static, since set by readParams())

Definition at line 116 of file TestBase.h.

Referenced by TestBase::readParams(), and TestBase::releaseTestSuite().

TestCaseGroup TestBase::defaultTests [protected, inherited]

Definition at line 139 of file TestBase.h.

Referenced by TestBase::releaseTestSuite().

TestCaseGroup TestBase::extraTests [protected, inherited]

Definition at line 140 of file TestBase.h.

Referenced by TestBase::releaseTestSuite().

ParamName TestBase::paramTestSuiteName [static, inherited]

Definition at line 143 of file TestBase.h.

Referenced by TestBase::TestBase().

ParamName TestBase::paramTraceFileName [static, inherited]

Definition at line 144 of file TestBase.h.

Referenced by TestBase::TestBase().

ParamName TestBase::paramDictionaryFileName [static, inherited]

Definition at line 145 of file TestBase.h.

Referenced by TestBase::readParams(), SegStreamTest::testRead(), and SegStreamTest::testWrite().

ParamName TestBase::paramTraceLevel [static, inherited]

Definition at line 146 of file TestBase.h.

Referenced by TestBase::TestBase().

ParamName TestBase::paramStatsFileName [static, inherited]

Definition at line 147 of file TestBase.h.

ParamName TestBase::paramTraceStdout [static, inherited]

Definition at line 148 of file TestBase.h.

Referenced by TestBase::TestBase().

ParamName TestBase::paramDegreeOfParallelism [static, inherited]

Definition at line 149 of file TestBase.h.

Referenced by ParallelExecStreamSchedulerTest::ParallelExecStreamSchedulerTest().

ConfigMap TestBase::configMap [static, inherited]

Configuration parameters.

The reason this is static is so that no constructor parameters (which burden virtual bases) are needed.

Definition at line 155 of file TestBase.h.

Referenced by TestBase::afterTestCase(), TestBase::beforeTestCase(), BTreeTxnTest::BTreeTxnTest(), CacheTestBase::CacheTestBase(), BackupRestoreTest::createSnapshotData(), DatabaseTest::DatabaseTest(), TestOptionsTest::extra(), DatabaseTest::loadDatabase(), SparseBitmapTest::openStorage(), PagingTestBase::PagingTestBase(), ParallelExecStreamSchedulerTest::ParallelExecStreamSchedulerTest(), RandomAccessFileDeviceTest::RandomAccessFileDeviceTest(), TestBase::readParams(), SegStorageTestBase::SegStorageTestBase(), TestOptionsTest::test1(), TestOptionsTest::test2(), BackupRestoreTest::testBackupCleanup(), TestBase::TestBase(), BTreeTxnTest::testCaseSetUp(), BTreeTxnTest::testCheckpoint(), DatabaseTest::testCreateEmpty(), DatabaseTest::testForceTxns(), BackupRestoreTest::testHeaderBackupRestore(), SegPageEntryIterTest::testIter(), SegStreamTest::testRead(), BTreeTxnTest::testTxns(), SegStreamTest::testWrite(), ThreadedTestBase::ThreadedTestBase(), and TestBase::~TestBase().


The documentation for this class was generated from the following file:
Generated on Mon Jun 22 04:00:34 2009 for Fennel by  doxygen 1.5.1