00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "fennel/common/CommonPreamble.h"
00023 #include "fennel/lucidera/test/LbmExecStreamTestBase.h"
00024 #include "fennel/lucidera/bitmap/LbmIntersectExecStream.h"
00025 #include <stdarg.h>
00026
00027 #include <boost/test/test_tools.hpp>
00028
00029 using namespace fennel;
00030
00034 class LbmIntersectExecStreamTest : public LbmExecStreamTestBase
00035 {
00036 void testIntersect(
00037 uint nInputs, uint nRows, std::vector<InputData> const &inputData);
00038
00039 public:
00040 explicit LbmIntersectExecStreamTest()
00041 {
00042 FENNEL_UNIT_TEST_CASE(LbmIntersectExecStreamTest, test2Inputs);
00043 FENNEL_UNIT_TEST_CASE(LbmIntersectExecStreamTest, test3Inputs);
00044 FENNEL_UNIT_TEST_CASE(LbmIntersectExecStreamTest, testGaps);
00045 FENNEL_UNIT_TEST_CASE(LbmIntersectExecStreamTest, testLargeOutput);
00046 FENNEL_UNIT_TEST_CASE(LbmIntersectExecStreamTest, testLargeInputs);
00047 FENNEL_UNIT_TEST_CASE(LbmIntersectExecStreamTest, testSingleBitmaps);
00048 FENNEL_UNIT_TEST_CASE(LbmIntersectExecStreamTest, testEmptyResult);
00049 FENNEL_UNIT_TEST_CASE(LbmIntersectExecStreamTest, testZeros);
00050 }
00051
00052 void test2Inputs();
00053 void test3Inputs();
00054 void testGaps();
00055 void testLargeOutput();
00056 void testLargeInputs();
00057 void testSingleBitmaps();
00058 void testEmptyResult();
00059 void testZeros();
00060 };
00061
00062 void LbmIntersectExecStreamTest::test2Inputs()
00063 {
00064 uint nInputs = 2;
00065 uint nRows = 1000;
00066 std::vector<InputData> inputData;
00067 InputData input;
00068
00069
00070 input.bitmapSize = 4;
00071 input.startRid = LcsRid(10);
00072 input.skipRows = 1;
00073 inputData.push_back(input);
00074
00075
00076 input.bitmapSize = 8;
00077 input.startRid = LcsRid(0);
00078 input.skipRows = 2;
00079 inputData.push_back(input);
00080
00081
00082 input.bitmapSize = resultBitmapSize(10, nRows);
00083 input.startRid = LcsRid(10);
00084 input.skipRows = 2;
00085 inputData.push_back(input);
00086
00087 testIntersect(nInputs, nRows, inputData);
00088 }
00089
00090 void LbmIntersectExecStreamTest::test3Inputs()
00091 {
00092 uint nInputs = 3;
00093 uint nRows = 1000;
00094 std::vector<InputData> inputData;
00095 InputData input;
00096
00097
00098 input.bitmapSize = 9;
00099 input.startRid = LcsRid(22);
00100 input.skipRows = 2;
00101 inputData.push_back(input);
00102
00103
00104 input.bitmapSize = 8;
00105 input.startRid = LcsRid(30);
00106 input.skipRows = 3;
00107 inputData.push_back(input);
00108
00109
00110 input.bitmapSize = 10;
00111 input.startRid = LcsRid(35);
00112 input.skipRows = 1;
00113 inputData.push_back(input);
00114
00115
00116 input.bitmapSize = resultBitmapSize(36, nRows);
00117 input.startRid = LcsRid(36);
00118 input.skipRows = 2*3;
00119 inputData.push_back(input);
00120
00121 testIntersect(nInputs, nRows, inputData);
00122 }
00123
00130 void LbmIntersectExecStreamTest::testGaps()
00131 {
00132 uint nInputs = 3;
00133
00134 uint nRows = 3*11*19*8;
00135 std::vector<InputData> inputData;
00136 InputData input;
00137
00138
00139 input.bitmapSize = 11;
00140 input.startRid = LcsRid(3);
00141 input.skipRows = 3;
00142 inputData.push_back(input);
00143
00144
00145 input.bitmapSize = 12;
00146 input.startRid = LcsRid(11);
00147 input.skipRows = 11;
00148 inputData.push_back(input);
00149
00150
00151 input.bitmapSize = 13;
00152 input.startRid = LcsRid(19);
00153 input.skipRows = 19;
00154 inputData.push_back(input);
00155
00156
00157 input.bitmapSize = resultBitmapSize(3*11*19, nRows);
00158 input.startRid = LcsRid(3*11*19);
00159 input.skipRows = 3*11*19;
00160 inputData.push_back(input);
00161
00162 testIntersect(nInputs, nRows, inputData);
00163 }
00164
00169 void LbmIntersectExecStreamTest::testLargeOutput()
00170 {
00171 uint nInputs = 2;
00172 uint nRows = 100000;
00173 std::vector<InputData> inputData;
00174 InputData input;
00175
00176
00177 input.bitmapSize = 1;
00178 input.startRid = LcsRid(0);
00179 input.skipRows = 1;
00180 inputData.push_back(input);
00181
00182
00183 input.bitmapSize = 1;
00184 input.startRid = LcsRid(0);
00185 input.skipRows = 16;
00186 inputData.push_back(input);
00187
00188
00189 input.bitmapSize = resultBitmapSize(0, nRows);
00190 input.startRid = LcsRid(0);
00191 input.skipRows = 16;
00192 inputData.push_back(input);
00193
00194 testIntersect(nInputs, nRows, inputData);
00195 }
00196
00200 void LbmIntersectExecStreamTest::testLargeInputs()
00201 {
00202 uint nInputs = 2;
00203 uint nRows = 15*8*24*5;
00204 std::vector<InputData> inputData;
00205 InputData input;
00206
00207
00208 input.bitmapSize = 15*8*3;
00209 input.startRid = LcsRid(0);
00210 input.skipRows = 8;
00211 inputData.push_back(input);
00212
00213
00214 input.bitmapSize = 15*8*3;
00215 input.startRid = LcsRid(0);
00216 input.skipRows = 15;
00217 inputData.push_back(input);
00218
00219
00220 input.bitmapSize = resultBitmapSize(0, nRows);
00221 input.startRid = LcsRid(0);
00222 input.skipRows = 8*15;
00223 inputData.push_back(input);
00224
00225 testIntersect(nInputs, nRows, inputData);
00226 }
00227
00231 void LbmIntersectExecStreamTest::testSingleBitmaps()
00232 {
00233 uint nInputs = 2;
00234 uint nRows = 20*8*5;
00235 std::vector<InputData> inputData;
00236 InputData input;
00237
00238
00239 input.bitmapSize = 20;
00240 input.startRid = LcsRid(0);
00241 input.skipRows = 2;
00242 inputData.push_back(input);
00243
00244
00245 input.bitmapSize = 20;
00246 input.startRid = LcsRid(0);
00247 input.skipRows = 4;
00248 inputData.push_back(input);
00249
00250
00251 input.bitmapSize = resultBitmapSize(0, nRows);
00252 input.startRid = LcsRid(0);
00253 input.skipRows = 4;
00254 inputData.push_back(input);
00255
00256 testIntersect(nInputs, nRows, inputData);
00257 }
00258
00262 void LbmIntersectExecStreamTest::testEmptyResult()
00263 {
00264 uint nInputs = 2;
00265 uint nRows = 80;
00266 std::vector<InputData> inputData;
00267 InputData input;
00268
00269
00270 input.bitmapSize = 10;
00271 input.startRid = LcsRid(0);
00272 input.skipRows = 2;
00273 inputData.push_back(input);
00274
00275
00276 input.bitmapSize = 10;
00277 input.startRid = LcsRid(1);
00278 input.skipRows = 2;
00279 inputData.push_back(input);
00280
00281
00282 input.bitmapSize = 0;
00283 input.startRid = LcsRid(0);
00284 input.skipRows = 1;
00285 inputData.push_back(input);
00286
00287 testIntersect(nInputs, nRows, inputData);
00288 }
00289
00294 void LbmIntersectExecStreamTest::testZeros()
00295 {
00296 uint nInputs = 2;
00297 uint nRows = 4000;
00298 std::vector<InputData> inputData;
00299 InputData input;
00300
00301
00302 input.bitmapSize = 9;
00303 input.startRid = LcsRid(3);
00304 input.skipRows = 3;
00305 inputData.push_back(input);
00306
00307
00308 input.bitmapSize = 9;
00309 input.startRid = LcsRid(4);
00310 input.skipRows = 4;
00311 inputData.push_back(input);
00312
00313
00314 input.bitmapSize = resultBitmapSize(12, nRows);
00315 input.startRid = LcsRid(12);
00316 input.skipRows = 12;
00317 inputData.push_back(input);
00318
00319 testIntersect(nInputs, nRows, inputData);
00320 }
00321
00322 void LbmIntersectExecStreamTest::testIntersect(
00323 uint nInputs, uint nRows, std::vector<InputData> const &inputData)
00324 {
00325 boost::scoped_array<BitmapInput> bmInputs;
00326 boost::scoped_array<ValuesExecStreamParams> valuesParams;
00327 std::vector<ExecStreamEmbryo> valuesStreamEmbryoList;
00328 ExecStreamEmbryo valuesStreamEmbryo;
00329
00330
00331 assert(inputData.size() == nInputs + 1);
00332
00333 bmInputs.reset(new BitmapInput[nInputs + 1]);
00334 valuesParams.reset(new ValuesExecStreamParams[nInputs]);
00335
00336
00337 for (uint i = 0; i < nInputs; i++) {
00338 initBitmapInput(bmInputs[i], nRows, inputData[i]);
00339 initValuesExecStream(
00340 i, valuesParams[i], valuesStreamEmbryo, bmInputs[i]);
00341 valuesStreamEmbryoList.push_back(valuesStreamEmbryo);
00342 }
00343
00344 if (inputData[nInputs].bitmapSize > 0) {
00345 initBitmapInput(bmInputs[nInputs], nRows, inputData[nInputs]);
00346 } else {
00347 bmInputs[nInputs].bufArray.reset();
00348 bmInputs[nInputs].nBitmaps = 0;
00349 }
00350
00351 LbmIntersectExecStreamParams intersectParams;
00352 intersectParams.rowLimitParamId = DynamicParamId(1);
00353 intersectParams.startRidParamId = DynamicParamId(2);
00354 intersectParams.outputTupleDesc = bitmapTupleDesc;
00355 intersectParams.scratchAccessor =
00356 pSegmentFactory->newScratchSegment(pCache, 10);
00357
00358 ExecStreamEmbryo intersectEmbryo;
00359 intersectEmbryo.init(new LbmIntersectExecStream(), intersectParams);
00360 intersectEmbryo.getStream()->setName("IntersectExecStream");
00361
00362 SharedExecStream pOutputStream = prepareConfluenceGraph(
00363 valuesStreamEmbryoList, intersectEmbryo);
00364
00365 verifyBufferedOutput(
00366 *pOutputStream, bitmapTupleDesc, bmInputs[nInputs].nBitmaps,
00367 bmInputs[nInputs].bufArray.get());
00368 }
00369
00370 FENNEL_UNIT_TEST_SUITE(LbmIntersectExecStreamTest);
00371
00372
00373