RestartingMinusExecStreamGenerator Class Reference

Generates repeating tuples resulting from minus such as. More...

Inheritance diagram for RestartingMinusExecStreamGenerator:

MockProducerExecStreamGenerator List of all members.

Public Member Functions

 RestartingMinusExecStreamGenerator (uint nRows, std::vector< int > repeatSeqValues, uint subtrahendInterval)
virtual int64_t generateValue (uint iRow, uint iCol)
 Generates one data value.
uint getValueCount (uint nRows, uint iValue)
 Returns the number of times a value repeats over nRows.
uint getRowCount ()
 Returns the total number of rows the result set should have.

Protected Attributes

uint nKeys
std::vector< int > repeatSeqValues
uint subtrahendInterval
uint interval
boost::shared_array< uintchangeIndexes
uint current
uint lastRow

Detailed Description

Generates repeating tuples resulting from minus such as.

 0, 0, 0 [distinct row 0, repeats 12 times]
 0, 1, 1 [distinct row 1, repeats 11 times]
 0, 2, 2 [distinct row 1, repeats 12 times]
 ...
 

Definition at line 93 of file LbmMinusExecStreamTest.cpp.


Constructor & Destructor Documentation

RestartingMinusExecStreamGenerator::RestartingMinusExecStreamGenerator ( uint  nRows,
std::vector< int >  repeatSeqValues,
uint  subtrahendInterval 
) [inline]

Definition at line 106 of file LbmMinusExecStreamTest.cpp.

References changeIndexes, current, LbmExecStreamTestBase::getTupleInterval(), getValueCount(), interval, lastRow, and nKeys.

00108     {
00109         this->nKeys = repeatSeqValues.size();
00110         this->repeatSeqValues = repeatSeqValues;
00111         interval = LbmExecStreamTestBase::getTupleInterval(repeatSeqValues);
00112 
00113         // find the number of times each key value repeats
00114         boost::scoped_array<uint> valueCounts;
00115         valueCounts.reset(new uint[interval]);
00116         for (uint i = 0; i < interval; i++) {
00117             valueCounts[i] = getValueCount(nRows, i);
00118         }
00119         // account for subtrahend
00120         for (uint iRow = 0; iRow < nRows; iRow += subtrahendInterval) {
00121             valueCounts[iRow % interval]--;
00122         }
00123 
00124         // find indexes where the values change
00125         changeIndexes.reset(new uint[interval]);
00126         changeIndexes[0] = valueCounts[0];
00127         for (uint i = 1; i < interval; i++) {
00128             changeIndexes[i] = changeIndexes[i - 1] + valueCounts[i];
00129         }
00130         current = 0;
00131         lastRow = 0;
00132     }


Member Function Documentation

virtual int64_t RestartingMinusExecStreamGenerator::generateValue ( uint  iRow,
uint  iCol 
) [inline, virtual]

Generates one data value.

Parameters:
iRow 0-based row number to generate
iCol 0-based col number to generate

Implements MockProducerExecStreamGenerator.

Definition at line 134 of file LbmMinusExecStreamTest.cpp.

References changeIndexes, current, interval, lastRow, nKeys, and repeatSeqValues.

00135     {
00136         // must be generated in order
00137         assert (lastRow <= iRow);
00138         lastRow = iRow;
00139 
00140         if (iRow >= changeIndexes[current]) {
00141             current++;
00142             assert (current < interval);
00143         }
00144         assert (iCol < nKeys);
00145         return current % repeatSeqValues[iCol];
00146     }

uint RestartingMinusExecStreamGenerator::getValueCount ( uint  nRows,
uint  iValue 
) [inline]

Returns the number of times a value repeats over nRows.

Definition at line 151 of file LbmMinusExecStreamTest.cpp.

References interval.

Referenced by RestartingMinusExecStreamGenerator().

00152     {
00153         uint nCopies = nRows / interval;
00154         if (iValue < nRows % interval) {
00155             nCopies++;
00156         }
00157         return nCopies;
00158     }

uint RestartingMinusExecStreamGenerator::getRowCount (  )  [inline]

Returns the total number of rows the result set should have.

Definition at line 163 of file LbmMinusExecStreamTest.cpp.

References changeIndexes, and interval.

Referenced by LbmMinusExecStreamTest::testRestartingMinus().

00164     {
00165         return changeIndexes[interval - 1];
00166     }


Member Data Documentation

uint RestartingMinusExecStreamGenerator::nKeys [protected]

Definition at line 97 of file LbmMinusExecStreamTest.cpp.

Referenced by generateValue(), and RestartingMinusExecStreamGenerator().

std::vector<int> RestartingMinusExecStreamGenerator::repeatSeqValues [protected]

Definition at line 98 of file LbmMinusExecStreamTest.cpp.

Referenced by generateValue().

uint RestartingMinusExecStreamGenerator::subtrahendInterval [protected]

Definition at line 99 of file LbmMinusExecStreamTest.cpp.

uint RestartingMinusExecStreamGenerator::interval [protected]

Definition at line 100 of file LbmMinusExecStreamTest.cpp.

Referenced by generateValue(), getRowCount(), getValueCount(), and RestartingMinusExecStreamGenerator().

boost::shared_array<uint> RestartingMinusExecStreamGenerator::changeIndexes [protected]

Definition at line 101 of file LbmMinusExecStreamTest.cpp.

Referenced by generateValue(), getRowCount(), and RestartingMinusExecStreamGenerator().

uint RestartingMinusExecStreamGenerator::current [protected]

Definition at line 102 of file LbmMinusExecStreamTest.cpp.

Referenced by generateValue(), and RestartingMinusExecStreamGenerator().

uint RestartingMinusExecStreamGenerator::lastRow [protected]

Definition at line 103 of file LbmMinusExecStreamTest.cpp.

Referenced by generateValue(), and RestartingMinusExecStreamGenerator().


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