Search in sources :

Example 6 with AfterburnerModule

use of com.fasterxml.jackson.module.afterburner.AfterburnerModule in project drill by apache.

the class Metadata method readBlockMeta.

/**
   * Read the parquet metadata from a file
   *
   * @param path
   * @return
   * @throws IOException
   */
private void readBlockMeta(String path, boolean dirsOnly, MetadataContext metaContext) throws IOException {
    Stopwatch timer = Stopwatch.createStarted();
    Path p = new Path(path);
    // parent directory of the metadata file
    Path parentDir = p.getParent();
    ObjectMapper mapper = new ObjectMapper();
    final SimpleModule serialModule = new SimpleModule();
    serialModule.addDeserializer(SchemaPath.class, new SchemaPath.De());
    serialModule.addKeyDeserializer(ColumnTypeMetadata_v2.Key.class, new ColumnTypeMetadata_v2.Key.DeSerializer());
    serialModule.addKeyDeserializer(ColumnTypeMetadata_v3.Key.class, new ColumnTypeMetadata_v3.Key.DeSerializer());
    AfterburnerModule module = new AfterburnerModule();
    module.setUseOptimizedBeanDeserializer(true);
    mapper.registerModule(serialModule);
    mapper.registerModule(module);
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    FSDataInputStream is = fs.open(p);
    boolean alreadyCheckedModification = false;
    boolean newMetadata = false;
    if (metaContext != null) {
        alreadyCheckedModification = metaContext.getStatus(parentDir.toString());
    }
    if (dirsOnly) {
        parquetTableMetadataDirs = mapper.readValue(is, ParquetTableMetadataDirs.class);
        logger.info("Took {} ms to read directories from directory cache file", timer.elapsed(TimeUnit.MILLISECONDS));
        timer.stop();
        if (!alreadyCheckedModification && tableModified(parquetTableMetadataDirs.getDirectories(), p, parentDir, metaContext)) {
            parquetTableMetadataDirs = (createMetaFilesRecursively(Path.getPathWithoutSchemeAndAuthority(p.getParent()).toString())).getRight();
            newMetadata = true;
        }
    } else {
        parquetTableMetadata = mapper.readValue(is, ParquetTableMetadataBase.class);
        logger.info("Took {} ms to read metadata from cache file", timer.elapsed(TimeUnit.MILLISECONDS));
        timer.stop();
        if (!alreadyCheckedModification && tableModified(parquetTableMetadata.getDirectories(), p, parentDir, metaContext)) {
            parquetTableMetadata = (createMetaFilesRecursively(Path.getPathWithoutSchemeAndAuthority(p.getParent()).toString())).getLeft();
            newMetadata = true;
        }
        // DRILL-5009: Remove the RowGroup if it is empty
        List<? extends ParquetFileMetadata> files = parquetTableMetadata.getFiles();
        for (ParquetFileMetadata file : files) {
            List<? extends RowGroupMetadata> rowGroups = file.getRowGroups();
            for (Iterator<? extends RowGroupMetadata> iter = rowGroups.iterator(); iter.hasNext(); ) {
                RowGroupMetadata r = iter.next();
                if (r.getRowCount() == 0) {
                    iter.remove();
                }
            }
        }
    }
    if (newMetadata && metaContext != null) {
        // if new metadata files were created, invalidate the existing metadata context
        metaContext.clear();
    }
}
Also used : Path(org.apache.hadoop.fs.Path) SchemaPath(org.apache.drill.common.expression.SchemaPath) Stopwatch(com.google.common.base.Stopwatch) AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) SchemaPath(org.apache.drill.common.expression.SchemaPath) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule)

Example 7 with AfterburnerModule

use of com.fasterxml.jackson.module.afterburner.AfterburnerModule in project dropwizard by dropwizard.

the class Jackson method configure.

private static ObjectMapper configure(ObjectMapper mapper) {
    mapper.registerModule(new GuavaModule());
    mapper.registerModule(new LogbackModule());
    mapper.registerModule(new GuavaExtrasModule());
    mapper.registerModule(new JodaModule());
    mapper.registerModule(new AfterburnerModule());
    mapper.registerModule(new FuzzyEnumModule());
    mapper.registerModule(new ParameterNamesModule());
    mapper.registerModules(new Jdk8Module());
    mapper.registerModules(new JavaTimeModule());
    mapper.setPropertyNamingStrategy(new AnnotationSensitivePropertyNamingStrategy());
    mapper.setSubtypeResolver(new DiscoverableSubtypeResolver());
    return mapper;
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) ParameterNamesModule(com.fasterxml.jackson.module.paramnames.ParameterNamesModule) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) GuavaModule(com.fasterxml.jackson.datatype.guava.GuavaModule)

Example 8 with AfterburnerModule

use of com.fasterxml.jackson.module.afterburner.AfterburnerModule in project jvm-serializers by eishay.

the class JacksonWithAfterburner method registerJSON.

public static void registerJSON(TestGroups groups) {
    ObjectMapper mapper = new ObjectMapper(new JsonFactory());
    mapper.registerModule(new AfterburnerModule());
    groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind<MediaContent>("json/jackson+afterburner/databind", MediaContent.class, mapper), new SerFeatures(SerFormat.BINARY, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, STD_DESC));
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) JsonFactory(com.fasterxml.jackson.core.JsonFactory) MediaContent(data.media.MediaContent) SerFeatures(serializers.SerFeatures) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 9 with AfterburnerModule

use of com.fasterxml.jackson.module.afterburner.AfterburnerModule 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 10 with AfterburnerModule

use of com.fasterxml.jackson.module.afterburner.AfterburnerModule in project ninja by ninjaframework.

the class XmlMapperProvider method get.

@Override
public XmlMapper get() {
    JacksonXmlModule module = new JacksonXmlModule();
    // Check out: https://github.com/FasterXML/jackson-dataformat-xml
    // setDefaultUseWrapper produces more similar output to
    // the Json output. You can change that with annotations in your
    // models.
    module.setDefaultUseWrapper(false);
    XmlMapper xmlMapper = new XmlMapper(module);
    xmlMapper.registerModule(new AfterburnerModule());
    return xmlMapper;
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) JacksonXmlModule(com.fasterxml.jackson.dataformat.xml.JacksonXmlModule) XmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper)

Aggregations

AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)9 JsonFactory (com.fasterxml.jackson.core.JsonFactory)3 MediaContent (data.media.MediaContent)3 SerFeatures (serializers.SerFeatures)3 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 CBORFactory (com.fasterxml.jackson.dataformat.cbor.CBORFactory)1 SmileFactory (com.fasterxml.jackson.dataformat.smile.SmileFactory)1 JacksonXmlModule (com.fasterxml.jackson.dataformat.xml.JacksonXmlModule)1 XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)1 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)1 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)1 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)1 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)1 ParameterNamesModule (com.fasterxml.jackson.module.paramnames.ParameterNamesModule)1 Stopwatch (com.google.common.base.Stopwatch)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 SchemaPath (org.apache.drill.common.expression.SchemaPath)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1 Path (org.apache.hadoop.fs.Path)1