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;
}
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));
}
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;
}
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);
}
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);
}
}
Aggregations