performance fixes for JDBC wisc benchmark
[csql.git] / include / PredicateImpl.h
blob48d27ae20f757883d9ef71c9d42d99517c724d65
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
4 * *
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. *
9 * *
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. *
14 * *
15 ***************************************************************************/
16 #ifndef PREDICATE_IMPL_H
17 #define PREDICATE_IMPL_H
18 #include<DataType.h>
19 #include<Predicate.h>
20 #include<ErrorType.h>
21 class TableImpl;
22 class Table;
23 class List;
24 class PredicateImpl:public Predicate
26 //Members set during initialization of the term
27 char fldName1[IDENTIFIER_LENGTH];
28 char fldName2[IDENTIFIER_LENGTH];
29 ComparisionOp compOp;
30 void *operand;
31 void **operandPtr;
32 LogicalOp logicalOp;
33 PredicateImpl *lhs;
34 PredicateImpl *rhs;
35 PredicateImpl *parent;
36 int offset1,offset2;
37 DataType type;
38 int length;
39 //Members set during execution
40 void *tuple; //pointer to the tuple
41 List *projList;
42 bool isPushedDown;
44 //This will be set before calling evaluate
45 TableImpl *table;
47 public:
48 PredicateImpl()
50 strcpy(fldName1, ""); strcpy(fldName2, "");
51 operand = NULL; operandPtr = NULL; lhs = rhs = NULL;
52 tuple = NULL; table = NULL;
53 projList = NULL;
54 parent = NULL;
55 offset1 = -1; offset2 =-1;
56 type = typeUnknown;
57 length = 0;
58 isPushedDown=false;
60 ~PredicateImpl(){}
62 void setTerm(const char* fName1, ComparisionOp op, const char *fName2);
64 //Operand should be of the same type of the field.This is must
65 void setTerm(const char* fName1, ComparisionOp op, void *opnd);
67 void setTerm(const char* fName1, ComparisionOp op, void **opnd);
70 void setTerm(Predicate *p1, LogicalOp op, Predicate *p2 = NULL);
72 void* valPtrForIndexField(const char *name);
73 ComparisionOp opForIndexField(const char *name);
75 DbRetVal evaluate(bool &result);
77 void setTable(Table *tbl);
78 void setTuple(void *tpl);
79 void setProjectionList(List *list); //used by JoinTableImpl
80 void setOffsetAndType();
81 bool isSingleTerm();
82 bool isNotOrInvolved();
83 //check predicate, whether it has field name and == operator
84 //and does not have OR, NOT operator
85 // TODO:: expression like !(f1 !=100) wont be optimized for now
86 bool pointLookupInvolved(const char *fName);
87 bool rangeQueryInvolved(const char *fName);
88 bool isBetweenInvolved(const char *fname);
89 PredicateImpl *getTablePredicate();
90 PredicateImpl *getJoinPredicate();
91 void removeIfNotNecessary();
92 bool isDummyPredicate();
93 PredicateImpl* getIfOneSidedPredicate();
94 void setParent(PredicateImpl *pImpl);
95 char* getFldName1(){ return fldName1; }
96 char* getFldName2(){ return fldName2; }
97 ComparisionOp getCompOp() {return compOp; }
98 void print(int space);
101 #endif