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