Class CsvParserContext

java.lang.Object
com.illumon.iris.importers.csv.parsers.CsvParserContext

public class CsvParserContext extends Object
Context class that holds the attributes and functionality common to all custom parsers
  • Constructor Details

    • CsvParserContext

      public CsvParserContext(@NotNull com.fishlib.io.logger.Logger log, @NotNull AtomicInteger errorCount, @NotNull String arrayDelimiter, int maxError, boolean strict, @NotNull ImportTableWriterFactory tableWriterFactory)
      Parameters:
      log - The passed-down logger
      arrayDelimiter - Delimiter used for array parsing
      strict - Whether to fail if a field fails conversion
      maxError - Maximum number of field conversion failures allowed
      errorCount - Holds the current error count across all parsers being used to import csv
      tableWriterFactory - This will be used to retrieve the appropriate partition value
  • Method Details

    • getLog

      public com.fishlib.io.logger.Logger getLog()
    • getErrorCount

      public AtomicInteger getErrorCount()
    • getArrayDelimiter

      public String getArrayDelimiter()
    • getMaxError

      public int getMaxError()
    • isStrict

      public boolean isStrict()
    • getComputedColumnPartitionValue

      public String getComputedColumnPartitionValue(@Nullable String partitionValue)
      Delegates to the underlying ImportTableWriterFactory.getComputedColumnPartition(String) method and returns the value.
      Parameters:
      partitionValue - the current partition value as read from the source file
      Returns:
      the value returned from underlying ImportTableWriterFactory.getComputedColumnPartition(String) method
      Throws:
      ImportException - if the returned value from factory call is null.
    • recordError

      public void recordError(@NotNull String errorMessage, boolean failDefault) throws io.deephaven.csv.util.CsvReaderException
      Adds the CsvReaderException to internal queue. The first exception in queue is thrown if maxError limit is breached.
      Parameters:
      errorMessage - The error message to be thrown in the exception
      failDefault - Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value fails
      Throws:
      io.deephaven.csv.util.CsvReaderException - thrown when strict flag is true and failDefault is false and there are exceptions in Import
    • isValueNullBlankOrNullString

      public boolean isValueNullBlankOrNullString(@Nullable String value)
      Convenience method to evaluate the default value extracted from the schema for the respective columns
      Parameters:
      value - the string value to evaluate
      Returns:
      true if value equals null, blank, or matches in a case-insensitive way to the string null