def genTableName(self, node): if self.table_name != "": table = util.searchTable(self.table_name) if table is None and self.table_name in node.table_alias_dic.keys(): table = util.searchTable(node.table_alias_dic[self.table_name]) if table is None: # TODO error return print table.table_name, self.column_name self.column_type = table.getColumnByName(self.column_name).column_type return if self.column_name == "*": return col_list = util.searchColumn(self.column_name) for col in col_list: if col.table_schema.table_name in node.table_list: self.table_name = col.table_schema.table_name self.column_type = col.table_schema.getColumnByName(self.column_name).column_type return for key in node.table_alias_dic.keys(): if col.table_schema.table_name == self.table_alias_dic[key]: self.table_name = key self.column_type = col.table_schema.getColumnByName(self.column_name).column_type return
def genIndex(self, node): new_exp = None if self.column_name == "*": new_exp = copy.deepcopy(self) return new_exp if self.table_name != "": if self.table_name not in node.table_alias_dic.keys(): if self.table_name not in node.table_list: # TODO error pass tmp_table = util.searchTable(self.table_name) if tmp_table is None: return None index = tmp_table.getColumnIndexByName(self.column_name) new_exp = Column(self.table_name, index) new_exp.column_name = int(new_exp.column_name) new_exp.column_type = self.column_type else: tmp_column = util.searchColumn(self.column_name) tmp_table = None for tmp in tmp_column: if tmp.table_schema.table_name in node.table_list or tmp.table_schema.table_name in node.table_alias_dic.values(): tmp_table = searchTable(tmp.table_schema.table) break if tmp_table is None: return None index = tmp_table.getColumnIndexByName(self.column_name) new_exp = Column(tmp.table_schema.table_name, index) new_exp.column_name = int(new_exp.column_name) new_exp.column_name = self.column_type return new_exp
def __calTrouserAbias(self,I,J,L,M,N): print "Int(J)"+str(int(J)) rows = searchTable(self.table3,2,int(J)) print "len(rows):"+str(len(rows)) if len(rows)==1: locatedRow = rows[0] else: row1 = searchTable(self.table3,2,int(J)+1)[0] row2 = searchTable(self.table3,2,int(J)-1)[0] locatedRow = row1 if abs(row1[1]-I)<abs(row2[1]-I) else row2 P_,I_,J_,L_ ,M_,N_= locatedRow[:6] P1 = I-I_ P2 = J-J_ P4 = L-L_ P = P_ P5 = M-M_ P6 = N -N_ return (P1,P2,P4,P,P5,P6)