class_docstr: Handles preparing and sending data from the classifier function to Kinesis Firehose
docstr: Segment the records into batches that conform to Firehose restrictions
  
  This will log any single record that is too large to send, and skip it.
  
  Args:
      records (list): The original records list to be segmented
  
  Yields:
      list: Batches of JSON serialized records that conform to Firehose restrictions
docstr_tok: ["Segment","the","records","into","batches","that","conform","to","Firehose","restrictions","This","will","log","any","single","record","that","is","too","large","to","send",",","and","skip","it",".","Args",":","records","(","list",")",":","The","original","records","list","to","be","segmented","Yields",":","list",":","Batches","of","JSON","serialized","records","that","conform","to","Firehose","restrictions"]
code: def _record_batches(cls, records, function_name):
      """Segment the records into batches that conform to Firehose restrictions
  
      This will log any single record that is too large to send, and skip it.
  
      Args:
          records (list): The original records list to be segmented
  
      Yields:
          list: Batches of JSON serialized records that conform to Firehose restrictions
      """
      records_json = cls._records_to_json_list(records)
  
      current_batch_size = 0
      current_batch = []
      for record in records_json:
          line_len = len(record)
          # Check if the max size of the batch has been reached or if the current
          # record will exceed the max batch size and start a new batch
          if (
              (len(current_batch) == cls.MAX_BATCH_COUNT)
              or (current_batch_size + line_len > cls.MAX_BATCH_SIZE)
          ) and current_batch:
              yield current_batch[:]
              current_batch_size = 0
              del current_batch[:]
  
          if line_len > cls.MAX_RECORD_SIZE:
              LOGGER.error(
                  "Record too large (%d) to send to Firehose:\n%s",
                  line_len,
                  record,
              )
              cls._log_failed(1, function_name)
              continue
  
          # Add the record to the batch
          current_batch_size += line_len
          current_batch.append(record)
  
      # yield the result of the last batch (no need to copy via slicing)
      if current_batch:
          yield current_batch
  
imports: from collections import defaultdict
  import json
  import hashlib
  import re
  import backoff
  import boto3
  from botocore.exceptions import ClientError, HTTPClientError
  from botocore.exceptions import ConnectionError
  from streamalert.shared import CLASSIFIER_FUNCTION_NAME
  import streamalert.shared.helpers.boto
  from streamalert.shared.logger import get_logger
  from streamalert.shared.metrics import MetricLogger
  from streamalert.shared.backoff_handlers import backoff_handler, giveup_handler, success_handler
label_desc: Use image node_id 3 for calling the FirehoseClient obj's underlying member method code with example usage: obj._record_batches(cls, records, function_name) without return types