C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 2

compression_stream.h
1 /* file: compression_stream.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Implementation of the compression and decompression stream interface.
45 //--
46 */
47 
48 #ifndef __COMPRESSION_STREAM_H__
49 #define __COMPRESSION_STREAM_H__
50 
51 #include "services/base.h"
52 #include "data_management/compression/compression.h"
53 #include "data_management/data/data_block.h"
54 #include "services/collection.h"
55 
56 namespace daal
57 {
58 namespace data_management
59 {
67 typedef services::Collection<services::SharedPtr<DataBlock> > DataBlockCollection;
68 typedef services::SharedPtr<DataBlockCollection> DataBlockCollectionPtr;
69 
70 namespace interface1
71 {
81 class DAAL_EXPORT CompressionStream : public Base
82 {
83 public:
89  CompressionStream(CompressorImpl *compr, size_t minSize = 1024 * 64);
90  virtual ~CompressionStream();
91 
96  virtual void push_back(DataBlock *inBlock);
97 
102  virtual void operator << (DataBlock *inBlock)
103  {
104  push_back(inBlock);
105  }
110  virtual void operator << (DataBlock inBlock)
111  {
112  push_back(&inBlock);
113  }
118  virtual DataBlockCollectionPtr getCompressedBlocksCollection();
123  virtual size_t getCompressedDataSize();
130  virtual size_t copyCompressedArray(byte *outPtr, size_t outSize);
136  virtual size_t copyCompressedArray(DataBlock &outBlock)
137  {
138  return copyCompressedArray(outBlock.getPtr(), outBlock.getSize());
139  }
140 
141  services::SharedPtr<services::ErrorCollection> getErrors()
142  {
143  return _errors;
144  }
145 
146 private:
147  void *_blocks;
148 
149  CompressorImpl *_compressor;
150  size_t _compressedDataSize;
151  size_t _minBlockSize;
152 
153  size_t _writePos;
154  size_t _readPos;
155 
156  void compressBlock(size_t pos);
157 
158  services::SharedPtr<services::ErrorCollection> _errors;
159 };
160 
170 class DAAL_EXPORT DecompressionStream : public Base
171 {
172 public:
178  DecompressionStream(DecompressorImpl *decompr, size_t minSize = 1024 * 64);
179  virtual ~DecompressionStream();
184  virtual void push_back(DataBlock *inBlock);
189  virtual void operator << (DataBlock *inBlock)
190  {
191  push_back(inBlock);
192  }
197  virtual void operator << (DataBlock inBlock)
198  {
199  push_back(&inBlock);
200  }
205  virtual DataBlockCollectionPtr getDecompressedBlocksCollection();
210  virtual size_t getDecompressedDataSize();
217  virtual size_t copyDecompressedArray(byte *outPtr, size_t outSize);
223  virtual size_t copyDecompressedArray(DataBlock &outBlock)
224  {
225  return copyDecompressedArray(outBlock.getPtr(), outBlock.getSize());
226  }
227 
228  services::SharedPtr<services::ErrorCollection> getErrors()
229  {
230  return _errors;
231  }
232 
233 private:
234  void *_blocks;
235 
236  DecompressorImpl *_decompressor;
237  size_t _decompressedDataSize;
238  size_t _minBlockSize;
239 
240  size_t _writePos;
241  size_t _readPos;
242 
243  void decompressBlock(size_t pos);
244 
245  services::SharedPtr<services::ErrorCollection> _errors;
246 };
247 } // namespace interface1
248 using interface1::CompressionStream;
249 using interface1::DecompressionStream;
252 } //namespace data_management
253 } //namespace daal
254 
255 #endif // __COMPRESSION_STREAM_H
daal
Definition: algorithm_base_common.h:57
daal::data_management::interface1::CompressionStream::copyCompressedArray
virtual size_t copyCompressedArray(DataBlock &outBlock)
Definition: compression_stream.h:136
daal::data_management::DataBlockCollection
services::Collection< services::SharedPtr< DataBlock > > DataBlockCollection
Collection of DataBlock-type elements.
Definition: compression_stream.h:67
daal::data_management::interface1::DataBlock::getPtr
virtual byte * getPtr() const DAAL_C11_OVERRIDE
Definition: data_block.h:149
daal::data_management::interface1::DecompressionStream::copyDecompressedArray
virtual size_t copyDecompressedArray(DataBlock &outBlock)
Definition: compression_stream.h:223
daal::data_management::interface1::CompressorImpl
Base class for the Compressor.
Definition: compression.h:251
daal::services::interface1::SharedPtr
Shared pointer that retains shared ownership of an object through a pointer. Several SharedPtr object...
Definition: daal_shared_ptr.h:187
daal::data_management::interface1::DataBlock::getSize
virtual size_t getSize() const DAAL_C11_OVERRIDE
Definition: data_block.h:159
daal::data_management::interface1::CompressionStream
CompressionStream class compresses input raw data by blocks.
Definition: compression_stream.h:81
daal::Base
Base class for Intel(R) Data Analytics Acceleration Library objects
Definition: base.h:65
daal::data_management::interface1::DecompressorImpl
Base class for the Decompressor.
Definition: compression.h:277
daal::data_management::interface1::DecompressionStream
DecompressionStream class decompresses compressed input data by blocks.
Definition: compression_stream.h:170
daal::services::interface1::Collection
Class that implements functionality of the Collection container.
Definition: collection.h:69
daal::data_management::interface1::DataBlock
Class that stores a pointer to a byte array and its size. Not responsible for memory management...
Definition: data_block.h:109

For more complete information about compiler optimizations, see our Optimization Notice.