1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef SCAN_FILTER_HPP
#define SCAN_FILTER_HPP
class ScanFilter {
public:
#if 0
/**
* Create a scan filter for table tab
* colNo - column to filter on
* val - val to use when selecting valu to filter on
*
*/
ScanFilter(const NDBT_Table& tab,
int colNo,
int val);
#endif
ScanFilter(int records = 1000){};
virtual int filterOp(NdbOperation*) = 0;
virtual int verifyRecord(NDBT_ResultRow&) = 0;
private:
// const NDBT_Table& tab;
};
class LessThanFilter : public ScanFilter {
public:
LessThanFilter(int records){ compare_value = records / 100; };
private:
Uint32 compare_value;
int filterOp(NdbOperation* pOp);
int verifyRecord(NDBT_ResultRow&);
};
class EqualFilter : public ScanFilter {
static const Uint32 compare_value = 100;
int filterOp(NdbOperation* pOp);
int verifyRecord(NDBT_ResultRow&);
};
class NoFilter : public ScanFilter {
int filterOp(NdbOperation* pOp);
int verifyRecord(NDBT_ResultRow&);
};
int LessThanFilter::filterOp(NdbOperation* pOp){
if (pOp->load_const_u32(1, compare_value) != 0)
return NDBT_FAILED;
if (pOp->read_attr("KOL2", 2) != 0)
return NDBT_FAILED;
if (pOp->branch_lt(1, 2, 0) != 0)
return NDBT_FAILED;
if (pOp->interpret_exit_nok() != 0)
return NDBT_FAILED;
if (pOp->def_label(0) != 0)
return NDBT_FAILED;
if (pOp->interpret_exit_ok() != 0)
return NDBT_FAILED;
return NDBT_OK;
}
int LessThanFilter::verifyRecord(NDBT_ResultRow& row){
NdbRecAttr* rec = row.attributeStore(1);
if (rec->u_32_value() < compare_value)
return NDBT_OK;
return NDBT_FAILED;
}
int EqualFilter::filterOp(NdbOperation* pOp){
if (pOp->load_const_u32(1, compare_value) != 0)
return NDBT_FAILED;
if (pOp->read_attr("KOL2", 2) != 0)
return NDBT_FAILED;
if (pOp->branch_eq(1, 2, 0) != 0)
return NDBT_FAILED;
if (pOp->interpret_exit_nok() != 0)
return NDBT_FAILED;
if (pOp->def_label(0) != 0)
return NDBT_FAILED;
if (pOp->interpret_exit_ok() != 0)
return NDBT_FAILED;
return NDBT_OK;
}
int EqualFilter::verifyRecord(NDBT_ResultRow& row){
NdbRecAttr* rec = row.attributeStore(1);
if (rec->u_32_value() == compare_value)
return NDBT_OK;
return NDBT_FAILED;
}
int NoFilter::filterOp(NdbOperation* pOp){
return NDBT_OK;
}
int NoFilter::verifyRecord(NDBT_ResultRow& row){
// Check if this record should be in the result set or not
return NDBT_OK;
}
#endif
|