1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 ***************************************************************************/
16 #ifndef PREDICATE_IMPL_H
17 #define PREDICATE_IMPL_H
24 class PredicateImpl
:public Predicate
26 //Members set during initialization of the term
27 char fldName1
[IDENTIFIER_LENGTH
];
28 char fldName2
[IDENTIFIER_LENGTH
];
35 PredicateImpl
*parent
;
37 //Members set during execution
38 void *tuple
; //pointer to the tuple
41 //This will be set before calling evaluate
47 strcpy(fldName1
, ""); strcpy(fldName2
, "");
48 operand
= NULL
; operandPtr
= NULL
; lhs
= rhs
= NULL
;
49 tuple
= NULL
; table
= NULL
;
55 void setTerm(const char* fName1
, ComparisionOp op
, const char *fName2
);
57 //Operand should be of the same type of the field.This is must
58 void setTerm(const char* fName1
, ComparisionOp op
, void *opnd
);
60 void setTerm(const char* fName1
, ComparisionOp op
, void **opnd
);
63 void setTerm(Predicate
*p1
, LogicalOp op
, Predicate
*p2
= NULL
);
65 void* valPtrForIndexField(const char *name
);
66 ComparisionOp
opForIndexField(const char *name
);
68 DbRetVal
evaluate(bool &result
);
70 void setTable(Table
*tbl
);
71 void setTuple(void *tpl
);
72 void setProjectionList(List
*list
); //used by JoinTableImpl
75 bool isNotOrInvolved();
76 //check predicate, whether it has field name and == operator
77 //and does not have OR, NOT operator
78 // TODO:: expression like !(f1 !=100) wont be optimized for now
79 bool pointLookupInvolved(const char *fName
);
80 bool rangeQueryInvolved(const char *fName
);
81 bool isBetweenInvolved(const char *fname
);
82 PredicateImpl
*getTablePredicate();
83 PredicateImpl
*getJoinPredicate();
84 void removeIfNotNecessary();
85 bool isDummyPredicate();
86 PredicateImpl
* getIfOneSidedPredicate();
87 void setParent(PredicateImpl
*pImpl
);
88 char* getFldName1(){ return fldName1
; }
89 char* getFldName2(){ return fldName2
; }
90 void print(int space
);