Search in sources :

Example 6 with TextConversionContext

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

the class StringToFloatCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL").setFormatNumbers(true).setRoundingMode(HALF_EVEN);
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec = (StringToFloatCodec) codecFactory.<String, Float>createConvertingCodec(DataTypes.FLOAT, 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 7 with TextConversionContext

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

the class StringToInstantCodecTest method setUpCodec1.

@BeforeEach
void setUpCodec1() {
    ConversionContext context1 = new TextConversionContext().setNullStrings("NULL");
    ConversionContext context2 = new TextConversionContext().setNullStrings("NULL").setTimestampFormat("yyyyMMddHHmmss");
    ConversionContext context3 = new TextConversionContext().setNullStrings("NULL").setTimeUnit(MINUTES).setEpoch(ZonedDateTime.parse("2000-01-01T00:00:00Z"));
    ConversionContext context4 = new TextConversionContext().setNullStrings("NULL").setTimeUnit(MINUTES).setEpoch(ZonedDateTime.parse("2000-01-01T00:00:00Z")).setTimestampFormat("UNITS_SINCE_EPOCH");
    codec1 = (StringToInstantCodec) new ConvertingCodecFactory(context1).<String, Instant>createConvertingCodec(DataTypes.TIMESTAMP, GenericType.STRING, true);
    codec2 = (StringToInstantCodec) new ConvertingCodecFactory(context2).<String, Instant>createConvertingCodec(DataTypes.TIMESTAMP, GenericType.STRING, true);
    codec3 = (StringToInstantCodec) new ConvertingCodecFactory(context3).<String, Instant>createConvertingCodec(DataTypes.TIMESTAMP, GenericType.STRING, true);
    codec4 = (StringToInstantCodec) new ConvertingCodecFactory(context4).<String, Instant>createConvertingCodec(DataTypes.TIMESTAMP, 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) Instant(java.time.Instant) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with TextConversionContext

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

the class StringToIntegerCodecTest method setUpCodec1.

@BeforeEach
void setUpCodec1() {
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(new TextConversionContext());
    codec1 = (StringToIntegerCodec) codecFactory.<String, Integer>createConvertingCodec(DataTypes.INT, GenericType.STRING, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with TextConversionContext

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

the class StringToMapCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL").setFormatNumbers(true);
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec = (StringToMapCodec<Double, List<String>>) codecFactory.<String, Map<Double, List<String>>>createConvertingCodec(DataTypes.mapOf(DataTypes.DOUBLE, DataTypes.listOf(DataTypes.TEXT)), 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) List(java.util.List) ImmutableMap(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with TextConversionContext

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

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