code: def Scan(self, fd,
             matcher):
      
      streamer = streaming.Streamer(
          chunk_size=self.CHUNK_SIZE, overlap_size=self.OVERLAP_SIZE)
  
      offset = self.params.start_offset
      amount = self.params.length
      for chunk in streamer.StreamFile(fd, offset=offset, amount=amount):
        for span in chunk.Scan(matcher):
          ctx_begin = max(span.begin - self.params.bytes_before, 0)
          ctx_end = min(span.end + self.params.bytes_after, len(chunk.data))
          ctx_data = chunk.data[ctx_begin:ctx_end]
  
          yield rdf_client.BufferReference(
              offset=chunk.offset + ctx_begin,
              length=len(ctx_data),
              data=ctx_data)
  
          if self.params.mode == self.params.Mode.FIRST_HIT:
            return
docs: Scans given file searching for occurrences of given pattern.
  
      Args:
        fd: A file descriptor of the file that needs to be searched.
        matcher: A matcher object specifying a pattern to search for.
  
      Yields:
        `BufferReference` objects pointing to file parts with matching content.