nodes: 0, module; 1, function_definition; 2, function_name:_collection_length; 3, parameters; 4, block; 5, identifier:self; 6, identifier:final_set; 7, expression_statement; 8, expression_statement; 9, comment:# we have a sorted set without need to sort, use zcard; 10, if_statement; 11, comment:# normal call; 12, return_statement; 13, comment:"""
          Return the length of the final collection, directly asking redis for the
          count without calling sort
          """; 14, assignment; 15, attribute; 16, block; 17, comment:# we have a stored collection, without other filter, use llen; 18, elif_clause; 19, call; 20, identifier:conn; 21, call; 22, identifier:self; 23, identifier:_has_sortedsets; 24, return_statement; 25, boolean_operator; 26, block; 27, attribute; 28, argument_list; 29, attribute; 30, argument_list; 31, call; 32, boolean_operator; 33, line_continuation:\; 34, comparison_operator:len(self._lazy_collection['intersects']) == 1; 35, return_statement; 36, call; 37, identifier:_collection_length; 38, identifier:final_set; 39, attribute; 40, identifier:get_connection; 41, attribute; 42, argument_list; 43, attribute; 44, not_operator; 45, call; 46, integer:1; 47, call; 48, identifier:super; 49, argument_list; 50, identifier:self; 51, identifier:cls; 52, identifier:conn; 53, identifier:zcard; 54, identifier:final_set; 55, identifier:self; 56, identifier:stored_key; 57, subscript; 58, identifier:len; 59, argument_list; 60, attribute; 61, argument_list; 62, identifier:ExtendedCollectionManager; 63, identifier:self; 64, attribute; 65, string; 66, subscript; 67, identifier:conn; 68, identifier:llen; 69, identifier:final_set; 70, identifier:self; 71, identifier:_lazy_collection; 72, string_content:sets; 73, attribute; 74, string; 75, identifier:self; 76, identifier:_lazy_collection; 77, string_content:intersects
code: def _collection_length(self, final_set):
          """
          Return the length of the final collection, directly asking redis for the
          count without calling sort
          """
          conn = self.cls.get_connection()
  
          # we have a sorted set without need to sort, use zcard
          if self._has_sortedsets:
              return conn.zcard(final_set)
  
          # we have a stored collection, without other filter, use llen
          elif self.stored_key and not self._lazy_collection['sets']\
                  and len(self._lazy_collection['intersects']) == 1:
  
              return conn.llen(final_set)
  
          # normal call
          return super(ExtendedCollectionManager, self)._collection_length(final_set)