Search in sources :

Example 6 with ConvertingCodecFactory

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

the class JsonNodeToTupleCodecTest 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 = (JsonNodeToTupleCodec) new ConvertingCodecFactory(context1).<JsonNode, TupleValue>createConvertingCodec(tupleType, JSON_NODE_TYPE, true);
    codec2 = (JsonNodeToTupleCodec) new ConvertingCodecFactory(context2).<JsonNode, TupleValue>createConvertingCodec(tupleType, JSON_NODE_TYPE, true);
    codec3 = (JsonNodeToTupleCodec) new ConvertingCodecFactory(context3).<JsonNode, TupleValue>createConvertingCodec(tupleType, JSON_NODE_TYPE, 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) JsonNode(com.fasterxml.jackson.databind.JsonNode) TupleValue(com.datastax.oss.driver.api.core.data.TupleValue) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with ConvertingCodecFactory

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

the class JsonNodeToUDTCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context1 = new TextConversionContext().setNullStrings("NULL", "");
    ConversionContext context2 = new TextConversionContext().setAllowExtraFields(true);
    ConversionContext context3 = new TextConversionContext().setAllowMissingFields(true);
    ConvertingCodecFactory codecFactory1 = new ConvertingCodecFactory(context1);
    ConvertingCodecFactory codecFactory2 = new ConvertingCodecFactory(context2);
    ConvertingCodecFactory codecFactory3 = new ConvertingCodecFactory(context3);
    udtCodec1 = (JsonNodeToUDTCodec) codecFactory1.<JsonNode, UdtValue>createConvertingCodec(udt1, JSON_NODE_TYPE, true);
    udtCodec2 = (JsonNodeToUDTCodec) codecFactory1.<JsonNode, UdtValue>createConvertingCodec(udt2, JSON_NODE_TYPE, true);
    udtCodec3 = (JsonNodeToUDTCodec) codecFactory2.<JsonNode, UdtValue>createConvertingCodec(udt3, JSON_NODE_TYPE, true);
    udtCodec4 = (JsonNodeToUDTCodec) codecFactory3.<JsonNode, UdtValue>createConvertingCodec(udt4, JSON_NODE_TYPE, true);
}
Also used : ConvertingCodecFactory(com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory) UdtValue(com.datastax.oss.driver.api.core.data.UdtValue) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) TextConversionContext(com.datastax.oss.dsbulk.codecs.text.TextConversionContext) ConversionContext(com.datastax.oss.dsbulk.codecs.api.ConversionContext) JsonNode(com.fasterxml.jackson.databind.JsonNode) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with ConvertingCodecFactory

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

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

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

Aggregations

ConvertingCodecFactory (com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory)37 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 Config (com.typesafe.config.Config)5 Test (org.junit.jupiter.api.Test)5 List (java.util.List)4 CodecSettings (com.datastax.oss.dsbulk.workflow.commons.settings.CodecSettings)3 DriverSettings (com.datastax.oss.dsbulk.workflow.commons.settings.DriverSettings)3 ExecutorSettings (com.datastax.oss.dsbulk.workflow.commons.settings.ExecutorSettings)3 LogSettings (com.datastax.oss.dsbulk.workflow.commons.settings.LogSettings)3 MonitoringSettings (com.datastax.oss.dsbulk.workflow.commons.settings.MonitoringSettings)3 SchemaSettings (com.datastax.oss.dsbulk.workflow.commons.settings.SchemaSettings)3 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 ConnectorSettings (com.datastax.oss.dsbulk.workflow.commons.settings.ConnectorSettings)2 EngineSettings (com.datastax.oss.dsbulk.workflow.commons.settings.EngineSettings)2