Search in sources :

Example 11 with TextConversionContext

use of com.datastax.oss.dsbulk.codecs.text.TextConversionContext in project dsbulk by datastax.

the class StringToTupleCodecTest method setUp.

@BeforeEach
void setUp() {
    tupleType = DriverUtils.mockTupleType(DefaultProtocolVersion.V4, CodecRegistry.DEFAULT, DataTypes.TIMESTAMP, DataTypes.TEXT);
    ConversionContext context1 = new TextConversionContext().setNullStrings("NULL", "");
    ConversionContext context2 = new TextConversionContext().setAllowExtraFields(true);
    ConversionContext context3 = new TextConversionContext().setAllowMissingFields(true);
    codec1 = (StringToTupleCodec) new ConvertingCodecFactory(context1).<String, TupleValue>createConvertingCodec(tupleType, GenericType.STRING, true);
    codec2 = (StringToTupleCodec) new ConvertingCodecFactory(context2).<String, TupleValue>createConvertingCodec(tupleType, GenericType.STRING, true);
    codec3 = (StringToTupleCodec) new ConvertingCodecFactory(context3).<String, TupleValue>createConvertingCodec(tupleType, GenericType.STRING, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) ConversionContext(com.datastax.oss.dsbulk.codecs.api.ConversionContext) TupleValue(com.datastax.oss.driver.api.core.data.TupleValue) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with TextConversionContext

use of com.datastax.oss.dsbulk.codecs.text.TextConversionContext in project dsbulk by datastax.

the class StringToBigDecimalCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL").setFormatNumbers(true);
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec = (StringToBigDecimalCodec) codecFactory.<String, BigDecimal>createConvertingCodec(DataTypes.DECIMAL, GenericType.STRING, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) ConversionContext(com.datastax.oss.dsbulk.codecs.api.ConversionContext) BigDecimal(java.math.BigDecimal) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with TextConversionContext

use of com.datastax.oss.dsbulk.codecs.text.TextConversionContext in project dsbulk by datastax.

the class StringToBigIntegerCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL").setFormatNumbers(true);
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec = (StringToBigIntegerCodec) codecFactory.<String, BigInteger>createConvertingCodec(DataTypes.VARINT, GenericType.STRING, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) ConversionContext(com.datastax.oss.dsbulk.codecs.api.ConversionContext) BigInteger(java.math.BigInteger) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with TextConversionContext

use of com.datastax.oss.dsbulk.codecs.text.TextConversionContext in project dsbulk by datastax.

the class StringToByteCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL");
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec = (StringToByteCodec) codecFactory.<String, Byte>createConvertingCodec(DataTypes.TINYINT, GenericType.STRING, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) ConversionContext(com.datastax.oss.dsbulk.codecs.api.ConversionContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with TextConversionContext

use of com.datastax.oss.dsbulk.codecs.text.TextConversionContext in project dsbulk by datastax.

the class StringToDoubleCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL").setFormatNumbers(true).setRoundingMode(HALF_EVEN);
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec = (StringToDoubleCodec) codecFactory.<String, Double>createConvertingCodec(DataTypes.DOUBLE, GenericType.STRING, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) ConversionContext(com.datastax.oss.dsbulk.codecs.api.ConversionContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ConvertingCodecFactory (com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory)29 TextConversionContext (com.datastax.oss.dsbulk.codecs.text.TextConversionContext)29 BeforeEach (org.junit.jupiter.api.BeforeEach)29 ConversionContext (com.datastax.oss.dsbulk.codecs.api.ConversionContext)28 JsonNode (com.fasterxml.jackson.databind.JsonNode)14 List (java.util.List)4 Instant (java.time.Instant)3 TupleValue (com.datastax.oss.driver.api.core.data.TupleValue)2 UdtValue (com.datastax.oss.driver.api.core.data.UdtValue)2 ImmutableMap (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap)2 BigDecimal (java.math.BigDecimal)2 BigInteger (java.math.BigInteger)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 ImmutableList (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList)1