Package com.illumon.iris.importers
Class BaseCsvFieldWriter
java.lang.Object
com.illumon.iris.importers.ImportFieldWriter
com.illumon.iris.importers.BaseCsvFieldWriter
- Direct Known Subclasses:
CsvFieldWriter
Encapsulates the functionality for custom setters that allow processing of
CustomSetterValue-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCreates BaseFieldWriter for passed ImporterColumnDefinitions -
Field Summary
FieldsFields inherited from class com.illumon.iris.importers.ImportFieldWriter
constantColumnValue, log -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseCsvFieldWriter(com.fishlib.io.logger.Logger log, String dbColumnName, String arrayDelimiter) -
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimalgetBigDecimal(String value, String columnName, com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, BigDecimal onEmpty) Reads a BigDecimal value from a CSVRecordstatic BooleangetBoolean(String value, String columnName, com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, Boolean onEmpty) Reads a Boolean value from a CSVRecord.static bytegetByte(String value, String columnName, com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, byte onEmpty) Reads a byte value from a CSVRecordstatic chargetChar(String value, String columnName, com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, char onEmpty) Reads a char value from a CSVRecordThe getter to retrieve the constantColumnValuestatic doublegetDouble(String value, String columnName, com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, double onEmpty) Reads a double value from a CSVRecordstatic floatgetFloat(String value, String columnName, com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, float onEmpty) Reads a float value from a CSVRecordstatic intgetInt(String value, String columnName, com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, int onEmpty) Reads an int value from a CSVRecordstatic longgetISONanos(String value, String columnName, com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, long onEmpty) Reads a ISO formatted date value from a CSVRecord and converts it to nanoseconds since the epoch.static LocalDategetLocalDate(String value, String columnName, com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, LocalDate onEmpty) Read a LocalDate value from a CSVRecord.static LocalTimegetLocalTime(String value, String columnName, com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, LocalTime onEmpty) Read a LocalTime value from a CSVRecord.static longgetLong(String value, String columnName, com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, long onEmpty) Reads a long value from a CSVRecordprotected CustomSetterValue<?>Returns a newCustomSetterValueinstance that is a copy of the setter present in the FieldWriter instance.The getter of the setter value.static shortgetShort(String value, String columnName, com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, short onEmpty) Reads a short value from a CSVRecordThe getter that returns the current single partition value if this is a single partition import For multi-partition the values should have been passed down in theprocessValues(Map, int, long)map parameterstatic StringgetTrimmedStringNull(String value, String columnName) Reads a String value from a CSVRecord.voidinitialize(CustomSetterValue<?> setterValue, Map<String, String> importProperties) initializes given Setter and Import PropertiesvoidprocessField(Map<String, Object> columnNameToValueMap) The method is invoked by the CustomSetter Column Parser by incorporating the values from all dependent columns If dependent columns are not provided then the map would contain values from all the columns Note no change for Constant Column values they need to be retrieved usingImportFieldWriter.getConstantColumnValue(String)processValues(Map<String, Object[]> columnNameToValueMap, int size, long destEnd) The method is invoked by the CustomSetter Column Parser by incorporating the values from all dependent columns If dependent columns are not provided then the map would contain values from all the columns Note no change for Constant Column values they need to be retrieved usingImportFieldWriter.getConstantColumnValue(String)voidsetConstantColumnValue(String constantColumnValue) The Constant Column Value as passed in from uivoidsetSinglePartitionValue(String singlePartitionValue) Set the value of SinglePartitionMethods inherited from class com.illumon.iris.importers.ImportFieldWriter
accountingDouble, accountingInt, accountingLong, dbDateTimeFromLong, dbDateTimeFromTimestamp, dbDateTimeFromTimestamp, getBigDecimalArray, getBigDecimalArray, getBigDecimalArray, getBigIntegerArray, getBigIntegerArray, getBigIntegerArray, getBooleanArray, getBooleanArray, getBooleanArray, getByteArray, getByteArray, getByteArray, getCharArray, getCharArray, getCharArray, getConstantColumnValue, getDBDateTimeArray, getDoubleArray, getDoubleArray, getDoubleArray, getEnumFormatter, getFloatArray, getFloatArray, getFloatArray, getIntArray, getIntArray, getIntArray, getLocalDateArray, getLocalDateArray, getLocalDateArray, getLocalTimeArray, getLocalTimeArray, getLocalTimeArray, getLongArray, getLongArray, getLongArray, getShortArray, getShortArray, getShortArray, getStringArray, getStringArray, localDateFromString, parseBoolean, processField, setImportProperties, stripFirstCharacter, toISONanos, updateWithConstantColumnValue
-
Field Details
-
ZERO_VALUE_ARRAY
-
-
Constructor Details
-
BaseCsvFieldWriter
-
-
Method Details
-
getSetterValue
The getter of the setter value.- Returns:
- Returns the setter which should be populated with the final value for the column
-
initialize
initializes given Setter and Import Properties- Parameters:
setterValue- the setter for this ColumnimportProperties- The custom properties map passed in import method
-
getConstantColumnValue
The getter to retrieve the constantColumnValue- Returns:
- the Constant Column Value
-
setConstantColumnValue
The Constant Column Value as passed in from ui- Parameters:
constantColumnValue- The value that represents the ConstantColumnValue
-
processValues
public List<CustomSetterValue<?>> processValues(@NotNull Map<String, Object[]> columnNameToValueMap, int size, long destEnd) throws RowProcessingExceptionThe method is invoked by the CustomSetter Column Parser by incorporating the values from all dependent columns If dependent columns are not provided then the map would contain values from all the columns Note no change for Constant Column values they need to be retrieved usingImportFieldWriter.getConstantColumnValue(String)- Parameters:
columnNameToValueMap- The column name to corresponding CustomValue array mapsize- The size of the chunk, which is the same as the size of CustomSetterValue array in the mapdestEnd- The exclusive end index of the destination range.- Returns:
- The processed custom setter column values for each row
- Throws:
RowProcessingException- Thrown if processing errors occur when parsing to create Csv records
-
getSetterCopy
Returns a newCustomSetterValueinstance that is a copy of the setter present in the FieldWriter instance.- Returns:
- new instance of
CustomSetterValuethat is identical to the existing setter
-
processField
The method is invoked by the CustomSetter Column Parser by incorporating the values from all dependent columns If dependent columns are not provided then the map would contain values from all the columns Note no change for Constant Column values they need to be retrieved usingImportFieldWriter.getConstantColumnValue(String)- Parameters:
columnNameToValueMap- The column name to corresponding CustomValue array map
-
getSinglePartitionValue
The getter that returns the current single partition value if this is a single partition import For multi-partition the values should have been passed down in theprocessValues(Map, int, long)map parameter- Returns:
- The current single partition value, for multi-partition import this should be null
-
setSinglePartitionValue
Set the value of SinglePartition- Parameters:
singlePartitionValue- the single partition value of import to set so the implementing CustomSetter has access to it
-
getShort
@DynamicUse public static short getShort(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, short onEmpty) Reads a short value from a CSVRecord- Parameters:
value- The value of the named column in the current row in the import filecolumnName- The column name from which the value should be readlog- The passed-down loggerstrict- Whether strict (true) or permissive (false) import rules are being usedfailDefault- Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value failsonEmpty- A default value that may be used if the source is empty or parsing fails- Returns:
- the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
-
getInt
@DynamicUse public static int getInt(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, int onEmpty) Reads an int value from a CSVRecord- Parameters:
value- The value of the named column in the current row in the import filecolumnName- The column name from which the value should be readlog- The passed-down loggerstrict- Whether strict (true) or permissive (false) import rules are being usedfailDefault- Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value failsonEmpty- A default value that may be used if the source is empty or parsing fails- Returns:
- the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
-
getLong
@DynamicUse public static long getLong(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, long onEmpty) Reads a long value from a CSVRecord- Parameters:
value- The value of the named column in the current row in the import filecolumnName- The column name from which the value should be readlog- The passed-down loggerstrict- Whether strict (true) or permissive (false) import rules are being usedfailDefault- Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value failsonEmpty- A default value that may be used if the source is empty or parsing fails- Returns:
- the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
-
getISONanos
@DynamicUse public static long getISONanos(@Nullable String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, long onEmpty) Reads a ISO formatted date value from a CSVRecord and converts it to nanoseconds since the epoch. This parser is a little less strict than ISO, in that it will accept time zone offsets without colons.- Parameters:
value- The value of the named column in the current row in the import filecolumnName- The column name from which the value should be readlog- The passed-down loggerstrict- Whether strict (true) or permissive (false) import rules are being usedfailDefault- Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value failsonEmpty- A default value that may be used if the source is empty or parsing fails- Returns:
- the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
-
getDouble
@DynamicUse public static double getDouble(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, double onEmpty) Reads a double value from a CSVRecord- Parameters:
value- The value of the named column in the current row in the import filecolumnName- The column name from which the value should be readlog- The passed-down loggerstrict- Whether strict (true) or permissive (false) import rules are being usedfailDefault- Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value failsonEmpty- A default value that may be used if the source is empty or parsing fails- Returns:
- the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
-
getBigDecimal
@DynamicUse public static BigDecimal getBigDecimal(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, @Nullable BigDecimal onEmpty) Reads a BigDecimal value from a CSVRecord- Parameters:
value- The value of the named column in the current row in the import filecolumnName- The column name from which the value should be readlog- The passed-down loggerstrict- Whether strict (true) or permissive (false) import rules are being usedfailDefault- Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value failsonEmpty- A default value that may be used if the source is empty or parsing fails- Returns:
- the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
-
getLocalDate
@DynamicUse public static LocalDate getLocalDate(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, @Nullable LocalDate onEmpty) Read a LocalDate value from a CSVRecord.- Parameters:
value- The value of the named column in the current row in the import filecolumnName- The column name from which the value should be readlog- The passed-down loggerstrict- Whether strict (true) or permissive (false) import rules are being usedfailDefault- Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value failsonEmpty- A default value that may be used if the source is empty or parsing fails- Returns:
- the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
-
getLocalTime
@DynamicUse public static LocalTime getLocalTime(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, @Nullable LocalTime onEmpty) Read a LocalTime value from a CSVRecord.- Parameters:
value- The value of the named column in the current row in the import filecolumnName- The column name from which the value should be readlog- The passed-down loggerstrict- Whether strict (true) or permissive (false) import rules are being usedfailDefault- Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value failsonEmpty- A default value that may be used if the source is empty or parsing fails- Returns:
- the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
-
getFloat
@DynamicUse public static float getFloat(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, float onEmpty) Reads a float value from a CSVRecord- Parameters:
value- The value of the named column in the current row in the import filecolumnName- The column name from which the value should be readlog- The passed-down loggerstrict- Whether strict (true) or permissive (false) import rules are being usedfailDefault- Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value failsonEmpty- A default value that may be used if the source is empty or parsing fails- Returns:
- the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
-
getChar
@DynamicUse public static char getChar(@Nullable String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, char onEmpty) Reads a char value from a CSVRecord- Parameters:
value- The value of the named column in the current row in the import filecolumnName- The column name from which the value should be readlog- The passed-down loggerstrict- Whether strict (true) or permissive (false) import rules are being usedfailDefault- Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value failsonEmpty- A default value that may be used if the source is empty or parsing fails- Returns:
- the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
-
getByte
@DynamicUse public static byte getByte(@Nullable String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, byte onEmpty) Reads a byte value from a CSVRecord- Parameters:
value- The value of the named column in the current row in the import filecolumnName- The column name from which the value should be readlog- The passed-down loggerstrict- Whether strict (true) or permissive (false) import rules are being usedfailDefault- Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value failsonEmpty- A default value that may be used if the source is empty or parsing fails- Returns:
- the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
-
getTrimmedStringNull
@DynamicUse public static String getTrimmedStringNull(@Nullable String value, @Nullable String columnName) Reads a String value from a CSVRecord. Trims white space, and handles the special case of the word null being returned as a null String.- Returns:
- the read value, or a null String if the field contains the keyword "null"
-
getBoolean
@DynamicUse public static Boolean getBoolean(@NotNull String value, @Nullable String columnName, @NotNull com.fishlib.io.logger.Logger log, boolean strict, boolean failDefault, Boolean onEmpty) Reads a Boolean value from a CSVRecord. parseBoolean handles interpretation of various text boolean expressions (true, false, 1, 0, T, F, etc).- Parameters:
value- The value of the named column in the current row in the import filecolumnName- The column name from which the value should be readlog- The passed-down loggerstrict- Whether strict (true) or permissive (false) import rules are being usedfailDefault- Whether (true) to use the default value (onEmpty) if parsing/conversion of the source value failsonEmpty- A default value that may be used if the source is empty or parsing fails- Returns:
- the converted value, or the onEmpty value, depending on strict, failDefault, and the source value itself
-