Search in sources :

Example 16 with TextConversionContext

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

the class JsonNodeToByteCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL");
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec = (JsonNodeToByteCodec) codecFactory.<JsonNode, Byte>createConvertingCodec(DataTypes.TINYINT, 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) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 17 with TextConversionContext

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

the class JsonNodeToDoubleCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL");
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec = (JsonNodeToDoubleCodec) codecFactory.<JsonNode, Double>createConvertingCodec(DataTypes.DOUBLE, 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) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 18 with TextConversionContext

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

the class JsonNodeToFloatCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL");
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec = (JsonNodeToFloatCodec) codecFactory.<JsonNode, Float>createConvertingCodec(DataTypes.FLOAT, 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) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 19 with TextConversionContext

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

the class JsonNodeToInstantCodecTest 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 = (JsonNodeToInstantCodec) new ConvertingCodecFactory(context1).<JsonNode, Instant>createConvertingCodec(DataTypes.TIMESTAMP, JSON_NODE_TYPE, true);
    codec2 = (JsonNodeToInstantCodec) new ConvertingCodecFactory(context2).<JsonNode, Instant>createConvertingCodec(DataTypes.TIMESTAMP, JSON_NODE_TYPE, true);
    codec3 = (JsonNodeToInstantCodec) new ConvertingCodecFactory(context3).<JsonNode, Instant>createConvertingCodec(DataTypes.TIMESTAMP, JSON_NODE_TYPE, true);
    codec4 = (JsonNodeToInstantCodec) new ConvertingCodecFactory(context4).<JsonNode, Instant>createConvertingCodec(DataTypes.TIMESTAMP, 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) Instant(java.time.Instant) JsonNode(com.fasterxml.jackson.databind.JsonNode) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 20 with TextConversionContext

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

the class JsonNodeToIntegerCodecTest method setUp.

@BeforeEach
void setUp() {
    ConversionContext context = new TextConversionContext().setNullStrings("NULL").setFormatNumbers(true);
    ConvertingCodecFactory codecFactory = new ConvertingCodecFactory(context);
    codec = (JsonNodeToIntegerCodec) codecFactory.<JsonNode, Integer>createConvertingCodec(DataTypes.INT, 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) 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