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/bitmap/LbmRidReader.h"
00024 #include "fennel/lucidera/bitmap/LbmTupleReader.h"
00025 #include "fennel/lucidera/test/LbmExecStreamTestBase.h"
00026
00027 #include <boost/test/test_tools.hpp>
00028
00029 using namespace fennel;
00030
00034 class LbmReaderTest : public LbmExecStreamTestBase
00035 {
00036 public:
00037 explicit LbmReaderTest()
00038 {
00039 FENNEL_UNIT_TEST_CASE(LbmReaderTest, testSingleTupleReader);
00040 }
00041
00042 void testSingleTupleReader();
00043 };
00044
00045 void LbmReaderTest::testSingleTupleReader()
00046 {
00047 LcsRid rid = LcsRid(123);
00048 bitmapTupleData[0].pData = (PConstBuffer) &rid;
00049
00050 LbmSingleTupleReader tupleReader;
00051 tupleReader.init(bitmapTupleData);
00052
00053 uint nRows = 0;
00054 while (true) {
00055 TupleData *pTuple;
00056 ExecStreamResult rc = tupleReader.read(pTuple);
00057 if (rc == EXECRC_EOS) {
00058 break;
00059 }
00060 BOOST_CHECK_EQUAL(rc, EXECRC_YIELD);
00061 int cmp = bitmapTupleDesc.compareTuples(bitmapTupleData, *pTuple);
00062 BOOST_CHECK_EQUAL(cmp, 0);
00063 nRows++;
00064 }
00065 BOOST_CHECK_EQUAL(nRows, 1);
00066
00067 LbmTupleRidReader ridReader;
00068 ridReader.init(bitmapTupleData);
00069 BOOST_CHECK_EQUAL(ridReader.hasNext(), true);
00070 BOOST_CHECK_EQUAL(ridReader.peek(), LcsRid(123));
00071 ridReader.advance();
00072 BOOST_CHECK_EQUAL(ridReader.hasNext(), false);
00073
00074 ridReader.init(bitmapTupleData);
00075 BOOST_CHECK_EQUAL(ridReader.hasNext(), true);
00076 BOOST_CHECK_EQUAL(ridReader.getNext(), LcsRid(123));
00077 BOOST_CHECK_EQUAL(ridReader.hasNext(), false);
00078 }
00079
00080 FENNEL_UNIT_TEST_SUITE(LbmReaderTest);
00081
00082