protected void checkAutoFlush() throws StreamingIOFailure {
    if (!autoFlush) {
      return;
    }
    if (lowMemoryCanary != null) {
      if (lowMemoryCanary.get() && ingestSizeBytes > ingestSizeThreshold) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Low memory canary is set and ingestion size (buffered) threshold '{}' exceeded. " +
            "Flushing all record updaters..", LlapUtil.humanReadableByteCount(ingestSizeThreshold));
        }
        flush();
        conn.getConnectionStats().incrementAutoFlushCount();
        lowMemoryCanary.set(false);
      }
    } else {
      if (ingestSizeBytes > ingestSizeThreshold) {
        MemoryMXBean mxBean = ManagementFactory.getMemoryMXBean();
        MemoryUsage heapUsage = mxBean.getHeapMemoryUsage();
        float memUsedFraction = ((float) heapUsage.getUsed() / (float) heapUsage.getMax());
        if (memUsedFraction > memoryUsageThreshold) {
          if (LOG.isDebugEnabled()) {
            LOG.info("Memory usage threshold '{}' and ingestion size (buffered) threshold '{}' exceeded. " +
              "Flushing all record updaters..", memUsedFraction, LlapUtil.humanReadableByteCount(ingestSizeThreshold));
          }
          flush();
          conn.getConnectionStats().incrementAutoFlushCount();
        }
      }
    }
  }
Encode a record as an Object that Hive can read with the ObjectInspector associated with the
serde returned by {@link #createSerde}.  This is public so that test frameworks can use it.

@param record record to be deserialized
@return deserialized record as an Object
@throws SerializationError - any error during serialization or deserialization of record
streaming/src/java/org/apache/hive/streaming/AbstractRecordWriter.java