Search in sources :

Example 16 with SmileFactory

use of com.fasterxml.jackson.dataformat.smile.SmileFactory in project druid by druid-io.

the class BrokerServerViewTest method getSmileMapper.

public ObjectMapper getSmileMapper() {
    final SmileFactory smileFactory = new SmileFactory();
    smileFactory.configure(SmileGenerator.Feature.ENCODE_BINARY_AS_7BIT, false);
    smileFactory.delegateToTextual(true);
    final ObjectMapper retVal = new DefaultObjectMapper(smileFactory);
    retVal.getFactory().setCodec(retVal);
    return retVal;
}
Also used : SmileFactory(com.fasterxml.jackson.dataformat.smile.SmileFactory) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 17 with SmileFactory

use of com.fasterxml.jackson.dataformat.smile.SmileFactory in project jvm-serializers by eishay.

the class JacksonWithAfterburner method registerSmile.

public static void registerSmile(TestGroups groups, boolean shareNames, boolean shareValues) {
    SmileFactory f = new SmileFactory();
    f.configure(SmileGenerator.Feature.CHECK_SHARED_NAMES, shareNames);
    f.configure(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES, shareValues);
    ObjectMapper smileMapper = new ObjectMapper(f);
    smileMapper.registerModule(new AfterburnerModule());
    groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind<MediaContent>("smile/jackson+afterburner/databind", MediaContent.class, smileMapper), new SerFeatures(SerFormat.BINARY, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, STD_DESC));
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) SmileFactory(com.fasterxml.jackson.dataformat.smile.SmileFactory) MediaContent(data.media.MediaContent) SerFeatures(serializers.SerFeatures) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 18 with SmileFactory

use of com.fasterxml.jackson.dataformat.smile.SmileFactory in project druid by druid-io.

the class JacksonModule method smileMapper.

@Provides
@LazySingleton
@Smile
public ObjectMapper smileMapper() {
    final SmileFactory smileFactory = new SmileFactory();
    smileFactory.configure(SmileGenerator.Feature.ENCODE_BINARY_AS_7BIT, false);
    smileFactory.delegateToTextual(true);
    final ObjectMapper retVal = new DefaultObjectMapper(smileFactory);
    retVal.getFactory().setCodec(retVal);
    return retVal;
}
Also used : SmileFactory(com.fasterxml.jackson.dataformat.smile.SmileFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LazySingleton(io.druid.guice.LazySingleton) Provides(com.google.inject.Provides) Smile(io.druid.guice.annotations.Smile)

Example 19 with SmileFactory

use of com.fasterxml.jackson.dataformat.smile.SmileFactory in project lucene-solr by apache.

the class SmileWriterTest method decodeSmile.

public static Object decodeSmile(InputStream is) throws IOException {
    final SmileFactory smileFactory = new SmileFactory();
    com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper(smileFactory);
    JsonNode jsonNode = mapper.readTree(is);
    return getVal(jsonNode);
}
Also used : SmileFactory(com.fasterxml.jackson.dataformat.smile.SmileFactory) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 20 with SmileFactory

use of com.fasterxml.jackson.dataformat.smile.SmileFactory in project airlift by airlift.

the class SmileMapper method writeTo.

@Override
public void writeTo(Object value, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream outputStream) throws IOException {
    JsonGenerator jsonGenerator = new SmileFactory().createGenerator(outputStream);
    // Important: we are NOT to close the underlying stream after
    // mapping, so we need to instruct generator:
    jsonGenerator.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
    // 04-Mar-2010, tatu: How about type we were given? (if any)
    JavaType rootType = null;
    if (genericType != null && value != null) {
        // generic.
        if (genericType.getClass() != Class.class) {
            // generic types are other implementations of 'java.lang.reflect.Type'
            // This is still not exactly right; should root type be further
            // specialized with 'value.getClass()'? Let's see how well this works before
            // trying to come up with more complete solution.
            rootType = objectMapper.getTypeFactory().constructType(genericType);
            // 
            if (rootType.getRawClass() == Object.class) {
                rootType = null;
            }
        }
    }
    if (rootType != null) {
        objectMapper.writerFor(rootType).writeValue(jsonGenerator, value);
    } else {
        objectMapper.writeValue(jsonGenerator, value);
    }
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) SmileFactory(com.fasterxml.jackson.dataformat.smile.SmileFactory) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator)

Aggregations

SmileFactory (com.fasterxml.jackson.dataformat.smile.SmileFactory)34 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)24 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)10 ByteBuffer (java.nio.ByteBuffer)8 DruidProcessingConfig (org.apache.druid.query.DruidProcessingConfig)6 GroupByStrategySelector (org.apache.druid.query.groupby.strategy.GroupByStrategySelector)6 GroupByStrategyV1 (org.apache.druid.query.groupby.strategy.GroupByStrategyV1)6 GroupByStrategyV2 (org.apache.druid.query.groupby.strategy.GroupByStrategyV2)6 Before (org.junit.Before)6 File (java.io.File)5 BasicAuthCommonCacheConfig (org.apache.druid.security.basic.BasicAuthCommonCacheConfig)5 Setup (org.openjdk.jmh.annotations.Setup)5 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)4 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)4 MetadataStorageTablesConfig (org.apache.druid.metadata.MetadataStorageTablesConfig)4 TestDerbyConnector (org.apache.druid.metadata.TestDerbyConnector)4 InputRow (io.druid.data.input.InputRow)3 DefaultBlockingPool (org.apache.druid.collections.DefaultBlockingPool)3 StupidPool (org.apache.druid.collections.StupidPool)3 BasicRoleBasedAuthorizer (org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer)3