14#include "arcane/utils/IOException.h"
15#include "arcane/utils/Array.h"
16#include "arcane/utils/TraceInfo.h"
17#include "arcane/utils/IDataCompressor.h"
19#include "arcane/core/FactoryService.h"
20#include "arcane/core/AbstractService.h"
21#include "arcane/core/IDeflateService.h"
37class Bzip2DeflateService
58 compressed_values.
resize(compressed_init_size);
61 char* dest = (
char*)compressed_values.
data();
62 unsigned int dest_len = (
unsigned int)compressed_init_size;
64 char* source = (
char*)values.
data();
65 unsigned int source_len = (
unsigned int)input_size;
67 int blockSize100k = 9;
72 info() <<
"CHECK COMPRESS dest=" << (
void*)dest
73 <<
" dest_len=" << dest_len
74 <<
" source=" << (
void*)source
75 <<
" source_len=" << source_len;
78 int r = BZ2_bzBuffToBuffCompress(dest,
86 throw IOException(A_FUNCINFO, String::format(
"io error during compression r={0}", r));
90 ratio = ((double)dest_len * 100.0) / (
double)source_len;
91 info() <<
"Bzip2 compress r=" << r <<
" source_len=" << source_len
92 <<
" dest_len=" << dest_len <<
" ratio=" << ratio;
93 compressed_values.
resize(dest_len);
98 char* dest = (
char*)values.
data();
99 unsigned int dest_len = (
unsigned int)values.
size();
101 char* source = (
char*)compressed_values.
data();
102 unsigned int source_len = (
unsigned int)compressed_values.
size();
108 int r = BZ2_bzBuffToBuffDecompress(dest, &dest_len,
111 info() <<
"Bzip2 decompress r=" << r <<
" source_len=" << source_len
112 <<
" dest_len=" << dest_len;
124class Bzip2DataCompressor
147 compressed_values.
resize(compressed_init_size);
149 char* dest =
reinterpret_cast<char*
>(compressed_values.
data());
150 unsigned int dest_len = _toUInt(compressed_init_size);
152 char* source =
const_cast<char*
>(
reinterpret_cast<const char*
>(values.
data()));
153 unsigned int source_len = _toUInt(input_size);
155 int blockSize100k = 9;
159 int r = BZ2_bzBuffToBuffCompress(dest,
172 ratio = ((double)dest_len * 100.0) / (
double)source_len;
173 info() <<
"Bzip2 compress r=" << r <<
" source_len=" << source_len
174 <<
" dest_len=" << dest_len <<
" ratio=" << ratio;
175 compressed_values.
resize(dest_len);
180 char* dest =
reinterpret_cast<char*
>(values.
data());
181 unsigned int dest_len = _toUInt(values.
size());
183 char* source =
const_cast<char*
>(
reinterpret_cast<const char*
>(compressed_values.
data()));
184 unsigned int source_len = _toUInt(compressed_values.
size());
190 int r = BZ2_bzBuffToBuffDecompress(dest, &dest_len,
193 info(5) <<
"Bzip2 decompress r=" << r <<
" source_len=" << source_len
194 <<
" dest_len=" << dest_len;
205 unsigned int _toUInt(
Int64 vsize)
208 Int64 max_uint_size = std::numeric_limits<unsigned int>::max();
209 if (vsize > max_uint_size)
211 vsize, max_uint_size);
212 return static_cast<unsigned int>(vsize);
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro to declare an interface when registering a service.
AbstractService(const ServiceBuildInfo &)
Constructor from a ServiceBuildInfo.
constexpr const_pointer data() const noexcept
Pointer to the start of the view.
constexpr Integer size() const noexcept
Returns the size of the array.
Base class for 1D data vectors.
void resize(Int64 s)
Changes the number of elements in the array to s.
const T * data() const
Access to the root of the array without any protection.
Compression service using the 'Bzip2' library.
Int64 minCompressSize() const override
Minimum array size below which compression is not useful.
void decompress(Span< const std::byte > compressed_values, Span< std::byte > values) override
Decompresses the data compressed_values and stores it in values.
String name() const override
Algorithm name.
void build() override
Build-level construction of the service.
void compress(Span< const std::byte > values, Array< std::byte > &compressed_values) override
Compresses the data values and stores it in compressed_values.
Compression service using the 'Bzip2' library.
void build() override
Build-level construction of the service.
void compress(ByteConstArrayView values, ByteArray &compressed_values) override
Compresses the data values and stores it in compressed_values.
void decompress(ByteConstArrayView compressed_values, ByteArrayView values) override
Decompresses the data compressed_values and stores it in values.
constexpr const_pointer data() const noexcept
Pointer to the allocated memory.
constexpr Integer size() const noexcept
Number of elements in the array.
Interface of a service for compressing/decompressing data.
Interface of a service allowing compression/decompression of data.
Exception when an input/output error is detected.
virtual String localName() const =0
Local part of the service name.
Structure containing the information to create a service.
IServiceInfo * serviceInfo() const
Access to the associated IServiceInfo.
Service creation properties.
constexpr __host__ __device__ pointer data() const noexcept
Pointer to the start of the view.
constexpr __host__ __device__ SizeType size() const noexcept
Returns the size of the array.
View of an array of elements of type T.
Unicode character string.
TraceMessage info() const
Flow for an information message.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro for registering a service.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
ArrayView< Byte > ByteArrayView
C equivalent of a 1D array of characters.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
Array< Byte > ByteArray
Dynamic one-dimensional array of characters.
@ ST_Application
The service is used at the application level.
@ ST_CaseOption
The service is used at the dataset level.
double Real
Type representing a real number.
ConstArrayView< Byte > ByteConstArrayView
C equivalent of a 1D array of characters.