public class CommonConversionContext extends ConversionContext
| Modifier and Type | Field and Description |
|---|---|
static String |
ALLOW_EXTRA_FIELDS |
static String |
ALLOW_MISSING_FIELDS |
static String |
BINARY_FORMAT |
static String |
BOOLEAN_INPUT_WORDS |
static String |
BOOLEAN_NUMBERS |
static String |
BOOLEAN_OUTPUT_WORDS |
static String |
DATE_PATTERN |
static String |
EPOCH |
static String |
FORMAT_NUMBERS |
static String |
GEO_FORMAT |
static String |
LOCAL_DATE_FORMAT |
static String |
LOCAL_TIME_FORMAT |
static String |
LOCALE |
static String |
NULL_STRINGS |
static String |
NUMBER_FORMAT |
static String |
NUMERIC_PATTERN |
static String |
OVERFLOW_STRATEGY |
static String |
ROUNDING_MODE |
static String |
TIME_PATTERN |
static String |
TIME_UNIT |
static String |
TIME_UUID_GENERATOR |
static String |
TIME_ZONE |
static String |
TIMESTAMP_FORMAT |
static String |
TIMESTAMP_PATTERN |
| Constructor and Description |
|---|
CommonConversionContext() |
| Modifier and Type | Method and Description |
|---|---|
CommonConversionContext |
setAllowExtraFields(boolean allowExtraFields) |
CommonConversionContext |
setAllowMissingFields(boolean allowMissingFields) |
CommonConversionContext |
setBinaryFormat(BinaryFormat binaryFormat)
The
BinaryFormat to use for conversions between String and CQL blob. |
CommonConversionContext |
setBooleanInputWords(Map<String,Boolean> inputWords)
Specify how strings map to
true and false. |
CommonConversionContext |
setBooleanNumbers(BigDecimal trueNumber,
BigDecimal falseNumber)
Sets how numbers are mapped to boolean values.
|
CommonConversionContext |
setBooleanOutputWords(Map<Boolean,String> outputWords)
Specify how
true and false map to strings. |
CommonConversionContext |
setDateFormat(String dateFormat)
The temporal pattern to use for
String to CQL date conversion. |
CommonConversionContext |
setEpoch(ZonedDateTime epoch)
This setting applies only to CQL
timestamp columns, and USING TIMESTAMP clauses
in queries. |
CommonConversionContext |
setFormatNumbers(boolean formatNumbers)
Whether or not to use the numeric pattern to format
numeric output.
|
CommonConversionContext |
setGeoFormat(GeoFormat binaryFormat)
The
GeoFormat to use for conversions between String and CQL blob. |
CommonConversionContext |
setLocale(Locale locale)
Sets the locale to use for locale-sensitive conversions.
|
CommonConversionContext |
setNullStrings(List<String> nullStrings)
Comma-separated list of case-sensitive strings that should be mapped to
null. |
CommonConversionContext |
setNullStrings(String... nullStrings)
Comma-separated list of case-sensitive strings that should be mapped to
null. |
CommonConversionContext |
setNumberFormat(String numberFormat)
The numeric pattern to use for conversions between
String and CQL numeric types. |
CommonConversionContext |
setOverflowStrategy(OverflowStrategy overflowStrategy)
The overflow strategy to apply.
|
CommonConversionContext |
setRoundingMode(RoundingMode roundingMode)
The rounding strategy to use for conversions from CQL numeric types to
String. |
CommonConversionContext |
setTimeFormat(String timeFormat)
The temporal pattern to use for
String to CQL time conversion.The default is
HH:mm:ss. |
CommonConversionContext |
setTimestampFormat(String timestampFormat)
The temporal pattern to use for
String to CQL timestamp conversion. |
CommonConversionContext |
setTimeUnit(TimeUnit unit)
This setting applies only to CQL
timestamp columns, and USING TIMESTAMP clauses
in queries. |
CommonConversionContext |
setTimeUUIDGenerator(TimeUUIDGenerator uuidGenerator)
Strategy to use when generating time-based (version 1) UUIDs from timestamps.
|
CommonConversionContext |
setTimeZone(ZoneId timeZone)
Sets the time zone to use for temporal conversions.
|
addAttribute, getAttributepublic static final String LOCALE
public static final String FORMAT_NUMBERS
public static final String NULL_STRINGS
public static final String NUMERIC_PATTERN
public static final String NUMBER_FORMAT
public static final String OVERFLOW_STRATEGY
public static final String ROUNDING_MODE
public static final String TIMESTAMP_PATTERN
public static final String DATE_PATTERN
public static final String TIME_PATTERN
public static final String TIMESTAMP_FORMAT
public static final String LOCAL_DATE_FORMAT
public static final String LOCAL_TIME_FORMAT
public static final String TIME_ZONE
public static final String TIME_UNIT
public static final String EPOCH
public static final String BOOLEAN_INPUT_WORDS
public static final String BOOLEAN_OUTPUT_WORDS
public static final String BOOLEAN_NUMBERS
public static final String TIME_UUID_GENERATOR
public static final String BINARY_FORMAT
public static final String GEO_FORMAT
public static final String ALLOW_EXTRA_FIELDS
public static final String ALLOW_MISSING_FIELDS
public CommonConversionContext setLocale(@NonNull Locale locale)
Locale.US.public CommonConversionContext setTimeZone(@NonNull ZoneId timeZone)
ZoneOffset.UTC.
When loading, the time zone will be used to obtain a timestamp from inputs that do not convey any explicit time zone information. When unloading, the time zone will be used to format all timestamps.
public CommonConversionContext setFormatNumbers(boolean formatNumbers)
false.
When set to true, numeric pattern will be
applied when formatting. This allows for nicely-formatted output, but may result in rounding or alteration of the original decimal's scale. When
set to false, numbers will be stringified using the toString() method, and will
never result in rounding or scale alteration. Only applicable when unloading, and only if the
connector in use requires stringification, because the connector, such as the CSV connector,
does not handle raw numeric data; ignored otherwise.
public CommonConversionContext setRoundingMode(@NonNull RoundingMode roundingMode)
String. The
default is RoundingMode.UNNECESSARY.
Only applicable when unloading, if setFormatNumbers(boolean) is true and if the
connector in use requires stringification, because the connector, such as the CSV connector,
does not handle raw numeric data; ignored otherwise.
public CommonConversionContext setOverflowStrategy(@NonNull OverflowStrategy overflowStrategy)
OverflowStrategy javadocs for overflow definitions.
The default is OverflowStrategy.REJECT.
Only applicable for loading, when parsing numeric inputs; it does not apply for unloading, since formatting never results in overflow.
public CommonConversionContext setTimeUnit(@NonNull TimeUnit unit)
timestamp columns, and USING TIMESTAMP clauses
in queries. If the input is a string containing only digits that cannot be parsed using the
timestamp format, the specified time unit is applied
to the parsed value.
The default is TimeUnit.MILLISECONDS.
public CommonConversionContext setEpoch(@NonNull ZonedDateTime epoch)
timestamp columns, and USING TIMESTAMP clauses
in queries. If the input is a string containing only digits that cannot be parsed using the
timestamp format, the specified epoch determines the
relative point in time used with the parsed value.
The default is Instant.EPOCH at ZoneOffset.UTC.
public CommonConversionContext setTimeUUIDGenerator(@NonNull TimeUUIDGenerator uuidGenerator)
TimeUUIDGenerator.RANDOM.public CommonConversionContext setNumberFormat(@NonNull String numberFormat)
String and CQL numeric types. The
default is #,###.##.
See DecimalFormat javadocs for details about the pattern syntax to use.
public CommonConversionContext setTimestampFormat(@NonNull String timestampFormat)
String to CQL timestamp conversion. The default
is CQL_TIMESTAMP.
Valid choices:
yyyy-MM-dd HH:mm:ss
ISO_ZONED_DATE_TIME or ISO_INSTANT. Any
public static field in DateTimeFormatter can be used.
CQL_TIMESTAMP, which is a special parser that accepts all
valid CQL literal formats for the timestamp type.When parsing, this format
recognizes all CQL temporal literals; if the input is a local date or date/time, the
timestamp is resolved using the time zone specified under timeZone. When
formatting, this format uses the ISO_OFFSET_DATE_TIME pattern, which is compliant
with both CQL and ISO-8601.
public CommonConversionContext setDateFormat(@NonNull String dateFormat)
String to CQL date conversion. The default is
yyyy-MM-dd.
Valid choices:
yyyy-MM-dd.
ISO_LOCAL_DATE. Any public static field in DateTimeFormatter can be used.
public CommonConversionContext setTimeFormat(@NonNull String timeFormat)
String to CQL time conversion.The default is
HH:mm:ss.
Valid choices:
HH:mm:ss.
ISO_LOCAL_TIME. Any public static field in
DateTimeFormatter can be used.
public CommonConversionContext setBooleanInputWords(@NonNull Map<String,Boolean> inputWords)
true and false.public CommonConversionContext setBooleanOutputWords(@NonNull Map<Boolean,String> outputWords)
true and false map to strings.public CommonConversionContext setNullStrings(@NonNull List<String> nullStrings)
null.
For loading, when a record field value exactly matches one of the specified strings, the
value is replaced with null before writing to DSE.
For unloading, this setting is only applicable for string-based connectors, such as the CSV
connector: the first string specified will be used to change a row cell containing null
to the specified string when written out.
For example, setting this to ["NULL"] will cause a field containing the word NULL to be mapped to null while loading, and a column containing null to be
converted to the word NULL while unloading.
The default value is [] (no strings are mapped to null). In the default
mode, DSBulk behaves as follows: when loading, if the target CQL type is textual (i.e. text,
varchar or ascii), the original field value is left untouched; for other types, if the value is
an empty string, it is converted to null; when unloading, all null values are
converted to an empty string.
Note that, regardless of this setting, DSBulk will always convert empty strings to null if the target CQL type is not textual (i.e. not text, varchar or ascii).
public CommonConversionContext setNullStrings(@NonNull String... nullStrings)
null.
For loading, when a record field value exactly matches one of the specified strings, the
value is replaced with null before writing to DSE.
For unloading, this setting is only applicable for string-based connectors, such as the CSV
connector: the first string specified will be used to change a row cell containing null
to the specified string when written out.
For example, setting this to ["NULL"] will cause a field containing the word NULL to be mapped to null while loading, and a column containing null to be
converted to the word NULL while unloading.
The default value is [] (no strings are mapped to null). In the default
mode, DSBulk behaves as follows: when loading, if the target CQL type is textual (i.e. text,
varchar or ascii), the original field value is left untouched; for other types, if the value is
an empty string, it is converted to null; when unloading, all null values are
converted to an empty string.
Note that, regardless of this setting, DSBulk will always convert empty strings to null if the target CQL type is not textual (i.e. not text, varchar or ascii).
public CommonConversionContext setBooleanNumbers(@NonNull BigDecimal trueNumber, BigDecimal falseNumber)
BigDecimal.ONE for true andBigDecimal.ZERO for false.public CommonConversionContext setAllowExtraFields(boolean allowExtraFields)
public CommonConversionContext setAllowMissingFields(boolean allowMissingFields)
public CommonConversionContext setBinaryFormat(@NonNull BinaryFormat binaryFormat)
BinaryFormat to use for conversions between String and CQL blob.public CommonConversionContext setGeoFormat(@NonNull GeoFormat binaryFormat)
GeoFormat to use for conversions between String and CQL blob.Copyright © 2017–2021 DataStax. All rights reserved.