class AggregateMetadataHandler implements StepMetadataHandler {

    @Override
    public DynamicActionMetadata handle(DynamicActionMetadata metadata) {
        DataShape outputShape = metadata.outputShape();
        DataShape inputShape = metadata.inputShape();

        try {
            if (metadata.outputShape() != null) {
                outputShape = adaptOutputShape(new DataShape.Builder()
                        .createFrom(metadata.outputShape())
                        .decompress()
                        .build());
            }
        } catch (IOException e) {
            LOG.warn("Unable to read input data shape on dynamic meta data inspection", e);
            LOG.warn("Using original input shape as fallback");
        }

        try {
            if (metadata.inputShape() != null) {
                inputShape = adaptInputShape(new DataShape.Builder()
                                                        .createFrom(metadata.inputShape())
                                                        .decompress()
                                                        .build());
            }
        } catch (IOException e) {
            LOG.warn("Unable to read output data shape on dynamic meta data inspection", e);
            LOG.warn("Using original output shape as fallback");
        }

        return new DynamicActionMetadata.Builder()
                .createFrom(metadata)
                .inputShape(inputShape)
                .outputShape(outputShape)
                .build();
    }

}