nodes: 0, module; 1, function_definition; 2, function_name:run; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, comment:# count before filtering; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, comment:# apply filters; 15, expression_statement; 16, expression_statement; 17, comment:# apply sorts; 18, expression_statement; 19, comment:# add paging options; 20, expression_statement; 21, if_statement; 22, expression_statement; 23, comment:# add columns to query; 24, expression_statement; 25, comment:# fetch the result of the queries; 26, expression_statement; 27, expression_statement; 28, comment:"""Launch filtering, sorting and paging to output results."""; 29, assignment; 30, assignment; 31, call; 32, call; 33, call; 34, call; 35, assignment; 36, assignment; 37, assignment; 38, assignment; 39, comparison_operator:length >= 0; 40, block; 41, elif_clause; 42, else_clause; 43, assignment; 44, assignment; 45, assignment; 46, assignment; 47, identifier:query; 48, attribute; 49, attribute; 50, call; 51, attribute; 52, argument_list; 53, attribute; 54, argument_list; 55, attribute; 56, argument_list; 57, attribute; 58, argument_list; 59, identifier:query; 60, call; 61, attribute; 62, call; 63, identifier:query; 64, call; 65, identifier:length; 66, call; 67, identifier:length; 68, integer:0; 69, expression_statement; 70, comparison_operator:length == -1; 71, block; 72, block; 73, identifier:query; 74, call; 75, identifier:query; 76, call; 77, identifier:column_names; 78, list_comprehension; 79, attribute; 80, list_comprehension; 81, identifier:self; 82, identifier:query; 83, identifier:self; 84, identifier:cardinality; 85, attribute; 86, argument_list; 87, identifier:self; 88, identifier:_set_column_filter_expressions; 89, identifier:self; 90, identifier:_set_global_filter_expression; 91, identifier:self; 92, identifier:_set_sort_expressions; 93, identifier:self; 94, identifier:_set_yadcf_data; 95, identifier:query; 96, attribute; 97, argument_list; 98, identifier:self; 99, identifier:cardinality_filtered; 100, attribute; 101, argument_list; 102, attribute; 103, argument_list; 104, identifier:int; 105, argument_list; 106, assignment; 107, identifier:length; 108, unary_operator; 109, pass_statement; 110, raise_statement; 111, attribute; 112, argument_list; 113, attribute; 114, argument_list; 115, conditional_expression:col.mData if col.mData else str(i); 116, for_in_clause; 117, identifier:self; 118, identifier:results; 119, dictionary_comprehension; 120, for_in_clause; 121, call; 122, identifier:count; 123, identifier:query; 124, identifier:filter; 125, list_splat; 126, call; 127, identifier:count; 128, identifier:query; 129, identifier:order_by; 130, list_splat; 131, call; 132, identifier:query; 133, call; 134, integer:1; 135, parenthesized_expression; 136, identifier:query; 137, identifier:offset; 138, call; 139, identifier:query; 140, identifier:add_columns; 141, list_splat; 142, attribute; 143, attribute; 144, call; 145, pattern_list; 146, call; 147, pair; 148, for_in_clause; 149, identifier:row; 150, call; 151, attribute; 152, argument_list; 153, list_comprehension; 154, attribute; 155, argument_list; 156, list_comprehension; 157, attribute; 158, argument_list; 159, attribute; 160, argument_list; 161, call; 162, identifier:int; 163, argument_list; 164, list_comprehension; 165, identifier:col; 166, identifier:mData; 167, identifier:col; 168, identifier:mData; 169, identifier:str; 170, argument_list; 171, identifier:i; 172, identifier:col; 173, identifier:enumerate; 174, argument_list; 175, identifier:k; 176, identifier:v; 177, pattern_list; 178, call; 179, attribute; 180, argument_list; 181, identifier:query; 182, identifier:add_columns; 183, attribute; 184, identifier:e; 185, for_in_clause; 186, if_clause; 187, identifier:query; 188, identifier:add_columns; 189, attribute; 190, identifier:e; 191, for_in_clause; 192, if_clause; 193, attribute; 194, identifier:get; 195, string; 196, identifier:query; 197, identifier:limit; 198, identifier:length; 199, identifier:ValueError; 200, argument_list; 201, call; 202, attribute; 203, for_in_clause; 204, identifier:i; 205, attribute; 206, identifier:k; 207, identifier:v; 208, identifier:zip; 209, argument_list; 210, identifier:query; 211, identifier:all; 212, subscript; 213, identifier:sqla_expr; 214, identifier:e; 215, attribute; 216, comparison_operator:e is not None; 217, subscript; 218, identifier:sqla_expr; 219, identifier:e; 220, attribute; 221, comparison_operator:e is not None; 222, identifier:self; 223, identifier:params; 224, string_content:length; 225, string; 226, attribute; 227, argument_list; 228, identifier:c; 229, identifier:sqla_expr; 230, identifier:c; 231, attribute; 232, identifier:self; 233, identifier:columns; 234, identifier:column_names; 235, identifier:row; 236, attribute; 237, integer:0; 238, identifier:self; 239, identifier:filter_expressions; 240, identifier:e; 241, None; 242, attribute; 243, integer:0; 244, identifier:self; 245, identifier:sort_expressions; 246, identifier:e; 247, None; 248, string_content:Length should be a positive integer or -1 to disable; 249, attribute; 250, identifier:get; 251, string; 252, identifier:self; 253, identifier:columns; 254, identifier:self; 255, identifier:columns; 256, identifier:self; 257, identifier:columns; 258, identifier:self; 259, identifier:params; 260, string_content:start
code: def run(self):
          """Launch filtering, sorting and paging to output results."""
          query = self.query
  
          # count before filtering
          self.cardinality = query.add_columns(self.columns[0].sqla_expr).count()
  
          self._set_column_filter_expressions()
          self._set_global_filter_expression()
          self._set_sort_expressions()
          self._set_yadcf_data(query)
  
          # apply filters
          query = query.filter(
              *[e for e in self.filter_expressions if e is not None])
  
          self.cardinality_filtered = query.add_columns(
              self.columns[0].sqla_expr).count()
  
          # apply sorts
          query = query.order_by(
              *[e for e in self.sort_expressions if e is not None])
  
          # add paging options
          length = int(self.params.get('length'))
          if length >= 0:
              query = query.limit(length)
          elif length == -1:
              pass
          else:
              raise (ValueError(
                  'Length should be a positive integer or -1 to disable'))
          query = query.offset(int(self.params.get('start')))
  
          # add columns to query
          query = query.add_columns(*[c.sqla_expr for c in self.columns])
  
          # fetch the result of the queries
          column_names = [
              col.mData if col.mData else str(i)
              for i, col in enumerate(self.columns)
          ]
          self.results = [{k: v
                           for k, v in zip(column_names, row)}
                          for row in query.all()]