Search in sources :

Example 1 with AfterburnerModule

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

the class JacksonWithAfterburner method registerCBOR.

public static void registerCBOR(TestGroups groups) {
    ObjectMapper mapper = new ObjectMapper(new CBORFactory());
    mapper.registerModule(new AfterburnerModule());
    groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind<MediaContent>("cbor/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) CBORFactory(com.fasterxml.jackson.dataformat.cbor.CBORFactory) MediaContent(data.media.MediaContent) SerFeatures(serializers.SerFeatures) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 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 3 with AfterburnerModule

use of com.fasterxml.jackson.module.afterburner.AfterburnerModule in project apm-agent-java by elastic.

the class ApmServerReporterIntegrationTest method setUp.

@BeforeEach
void setUp() {
    handler = exchange -> {
        receivedHttpRequests.incrementAndGet();
        exchange.setStatusCode(200).endExchange();
    };
    receivedHttpRequests.set(0);
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new AfterburnerModule());
    final ConfigurationRegistry config = SpyConfiguration.createSpyConfig();
    reporterConfiguration = config.getConfig(ReporterConfiguration.class);
    when(reporterConfiguration.getFlushInterval()).thenReturn(-1);
    when(reporterConfiguration.getServerUrl()).thenReturn("http://localhost:" + port);
    payloadSender = new ApmServerHttpPayloadSender(new OkHttpClient(), new JacksonPayloadSerializer(objectMapper), reporterConfiguration);
    SystemInfo system = new SystemInfo("x64", "localhost", "platform");
    reporter = new ApmServerReporter(config, new Service(), new ProcessInfo("title"), system, payloadSender, false, reporterConfiguration);
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) OkHttpClient(okhttp3.OkHttpClient) SystemInfo(co.elastic.apm.impl.payload.SystemInfo) JacksonPayloadSerializer(co.elastic.apm.report.serialize.JacksonPayloadSerializer) ConfigurationRegistry(org.stagemonitor.configuration.ConfigurationRegistry) Service(co.elastic.apm.impl.payload.Service) ProcessInfo(co.elastic.apm.impl.payload.ProcessInfo) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with AfterburnerModule

use of com.fasterxml.jackson.module.afterburner.AfterburnerModule in project apm-agent-java by elastic.

the class ReporterFactory method createReporter.

public Reporter createReporter(ConfigurationRegistry configurationRegistry, @Nullable String frameworkName, @Nullable String frameworkVersion) {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new AfterburnerModule());
    final ReporterConfiguration reporterConfiguration = configurationRegistry.getConfig(ReporterConfiguration.class);
    return new ApmServerReporter(configurationRegistry, new ServiceFactory().createService(configurationRegistry.getConfig(CoreConfiguration.class), frameworkName, frameworkVersion), ProcessFactory.ForCurrentVM.INSTANCE.getProcessInformation(), SystemInfo.create(), new ApmServerHttpPayloadSender(getOkHttpClient(reporterConfiguration), new JacksonPayloadSerializer(objectMapper), reporterConfiguration), true, reporterConfiguration);
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) ServiceFactory(co.elastic.apm.impl.payload.ServiceFactory) JacksonPayloadSerializer(co.elastic.apm.report.serialize.JacksonPayloadSerializer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with AfterburnerModule

use of com.fasterxml.jackson.module.afterburner.AfterburnerModule in project apm-agent-java by elastic.

the class AbstractHttpJacksonReporterBenchmark method getPayloadSerializer.

@Override
protected PayloadSerializer getPayloadSerializer() {
    ObjectMapper objectMapper = getObjectMapper();
    objectMapper.registerModule(new AfterburnerModule());
    return new JacksonPayloadSerializer(objectMapper);
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) JacksonPayloadSerializer(co.elastic.apm.report.serialize.JacksonPayloadSerializer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)21 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)18 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)4 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)4 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)4 SchemaPath (org.apache.drill.common.expression.SchemaPath)4 Path (org.apache.hadoop.fs.Path)4 JacksonPayloadSerializer (co.elastic.apm.report.serialize.JacksonPayloadSerializer)3 JsonFactory (com.fasterxml.jackson.core.JsonFactory)3 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)3 MediaContent (data.media.MediaContent)3 IOException (java.io.IOException)3 SerFeatures (serializers.SerFeatures)3 XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)2 Stopwatch (com.google.common.base.Stopwatch)2 InputStream (java.io.InputStream)2 ParquetFileMetadata (org.apache.drill.exec.store.parquet.metadata.MetadataBase.ParquetFileMetadata)2 ColumnTypeMetadata_v4 (org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ColumnTypeMetadata_v4)2 FileMetadata (org.apache.drill.exec.store.parquet.metadata.Metadata_V4.FileMetadata)2 MetadataSummary (org.apache.drill.exec.store.parquet.metadata.Metadata_V4.MetadataSummary)2