Search in sources :

Example 11 with ConversionContext

use of com.datastax.oss.dsbulk.codecs.api.ConversionContext in project dsbulk by datastax.

the class StringToSetCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL");
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec1 = (StringToSetCodec<Double>) codecFactory.<String, Set<Double>>createConvertingCodec(DataTypes.setOf(DataTypes.DOUBLE), GenericType.STRING, true);
    codec2 = (StringToSetCodec<String>) codecFactory.<String, Set<String>>createConvertingCodec(DataTypes.setOf(DataTypes.TEXT), GenericType.STRING, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) Set(java.util.Set) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) ConversionContext(com.datastax.oss.dsbulk.codecs.api.ConversionContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with ConversionContext

use of com.datastax.oss.dsbulk.codecs.api.ConversionContext 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 13 with ConversionContext

use of com.datastax.oss.dsbulk.codecs.api.ConversionContext 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 14 with ConversionContext

use of com.datastax.oss.dsbulk.codecs.api.ConversionContext 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 15 with ConversionContext

use of com.datastax.oss.dsbulk.codecs.api.ConversionContext 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)

Aggregations

ConversionContext (com.datastax.oss.dsbulk.codecs.api.ConversionContext)32 ConvertingCodecFactory (com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory)28 TextConversionContext (com.datastax.oss.dsbulk.codecs.text.TextConversionContext)28 BeforeEach (org.junit.jupiter.api.BeforeEach)28 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 List (java.util.List)5 Instant (java.time.Instant)4 ImmutableMap (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap)3 TupleValue (com.datastax.oss.driver.api.core.data.TupleValue)2 UdtValue (com.datastax.oss.driver.api.core.data.UdtValue)2 CustomType (com.datastax.oss.driver.api.core.type.CustomType)2 CodecNotFoundException (com.datastax.oss.driver.api.core.type.codec.CodecNotFoundException)2 CodecRegistry (com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry)2 ImmutableList (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList)2 ConvertingCodec (com.datastax.oss.dsbulk.codecs.api.ConvertingCodec)2 JdkCodecUtils.isUUID (com.datastax.oss.dsbulk.codecs.jdk.JdkCodecUtils.isUUID)2 NonNull (edu.umd.cs.findbugs.annotations.NonNull)2 Nullable (edu.umd.cs.findbugs.annotations.Nullable)2 BigDecimal (java.math.BigDecimal)2 BigInteger (java.math.BigInteger)2