code: def count_matching(self, selector, offset=0):
          
  
          if selector.output:
              data = self.streaming_data
          elif selector.buffered:
              data = self.storage_data
          else:
              raise ArgumentError("You can only pass a buffered selector to count_matching", selector=selector)
  
          count = 0
          for i in range(offset, len(data)):
              reading = data[i]
  
              stream = DataStream.FromEncoded(reading.stream)
              if selector.matches(stream):
                  count += 1
  
          return count
docs: Count the number of readings matching selector.
  
          Args:
              selector (DataStreamSelector): The selector that we want to
                  count matching readings for.
              offset (int): The starting offset that we should begin counting at.
  
          Returns:
              int: The number of matching readings.