Beispiel #1
0
 def _add_attribute(self, attribute_name, data_type, table=None):
     '''
     Add attribute
     '''
     att = Attribute(attribute_name, data_type, table)
     self._attribute_list.append(att)
     return self._attribute_list[-1]
Beispiel #2
0
 def __init__(self, operand, identifier_list, range_slide):
     GenericSeqOp.__init__(self, operand)
     # Copy operand attribute list because it will be changed
     self._attribute_list = operand.get_attribute_list()[:]
     # Bound and slide to build sequences
     self._bound, self._slide = range_slide
     # Identifier attributes
     self._identifier_attribute_list = []
     for parsed_att in identifier_list:
         att = self.find_attribute(parsed_att.get_name(),
                                   parsed_att.get_table())
         self._identifier_attribute_list.append(att)
     # record attributes are the attributes not present in
     # identifier attributes
     self._record_attribute_list = []
     for att in self._attribute_list:
         if att not in self._identifier_attribute_list:
             self._record_attribute_list.append(att)
     # Position attribute (always the last attribute)
     att = Attribute(POS_SYM, INTEGER_SYM)
     self._attribute_list.insert(0, att)
     self._operator_name = 'SEQ'
     self._operator_str = 'SEQ[{ran},{sli}]'\
         .format(ran=self._bound, sli=self._slide)
     # Sequences dictionary, each key has a list of sequences
     self._sequence_dict = {}
Beispiel #3
0
 def _build_attributes(self):
     '''
     Build the query attributes list
     '''
     # For each attribute in top plan operator
     for att in self._plan.get_attribute_list():
         # Use just attribute name (without table)
         attr = Attribute(att.get_name(), att.get_data_type())
         self._attribute_list.append(attr)
Beispiel #4
0
 def add_attribute(self, name, data_type):
     '''
     Add new attribute if it does not exist
     '''
     att = Attribute(name, data_type)
     if att not in self._attribute_list:
         self._attribute_list.append(att)
         return True
     else:
         return False
Beispiel #5
0
 def _map_to_query(self, record_list):
     '''
     Rename attributes using query attribute names
     '''
     result_list = []
     for rec in record_list:
         new_rec = {}
         for att in self._plan.get_attribute_list():
             query_att = Attribute(att.get_name(), att.get_data_type())
             new_rec[query_att] = rec[att]
         result_list.append(new_rec)
     return result_list
Beispiel #6
0
def _map_from_table(record_list, attribute_list):
    '''
    Copy a record from table e rename attributes using
    table operator name
    '''
    result_list = []
    for rec in record_list:
        new_rec = {}
        for att in attribute_list:
            table_att = Attribute(att.get_name(), att.get_data_type())
            new_rec[att] = rec[table_att]
        result_list.append(new_rec)
    return result_list
Beispiel #7
0
    def get_record_list(self):
        '''
        Get the list of full records

        Full records are position records added by
        identifier plus position attribute
        '''
        result_list = []
        # For each position
        for pos, rec in enumerate(self._position_list):
            new_rec = rec.copy()
            new_rec.update(self._identifier_record)
            pos_att = Attribute(POS_SYM, INTEGER_SYM)
            new_rec[pos_att] = pos + 1
            result_list.append(new_rec)
        return result_list