source: thirdparty/blosc/internal-complibs/zstd-0.7.4/dictBuilder/zdict.h @ 8ebc79b

Revision 8ebc79b, 5.1 KB checked in by Hal Finkel <hfinkel@…>, 8 years ago (diff)

Add the other internal compression libraries from blocs

  • Property mode set to 100644
RevLine 
[8ebc79b]1/*
2    dictBuilder header file
3    Copyright (C) Yann Collet 2016
4
5    BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
6
7    Redistribution and use in source and binary forms, with or without
8    modification, are permitted provided that the following conditions are
9    met:
10
11    * Redistributions of source code must retain the above copyright
12    notice, this list of conditions and the following disclaimer.
13    * Redistributions in binary form must reproduce the above
14    copyright notice, this list of conditions and the following disclaimer
15    in the documentation and/or other materials provided with the
16    distribution.
17
18    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30    You can contact the author at :
31       - Zstd source repository : https://www.zstd.net
32*/
33
34#ifndef DICTBUILDER_H_001
35#define DICTBUILDER_H_001
36
37#if defined (__cplusplus)
38extern "C" {
39#endif
40
41/*-*************************************
42*  Public functions
43***************************************/
44/*! ZDICT_trainFromBuffer() :
45    Train a dictionary from a memory buffer `samplesBuffer`,
46    where `nbSamples` samples have been stored concatenated.
47    Each sample size is provided into an orderly table `samplesSizes`.
48    Resulting dictionary will be saved into `dictBuffer`.
49    @return : size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
50              or an error code, which can be tested by ZDICT_isError().
51*/
52size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCapacity,
53                             const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
54
55/*! ZDICT_addEntropyTablesFromBuffer() :
56
57    Given a content-only dictionary (built for example from common strings in
58    the input), add entropy tables computed from the memory buffer
59    `samplesBuffer`, where `nbSamples` samples have been stored concatenated.
60    Each sample size is provided into an orderly table `samplesSizes`.
61
62    The input dictionary is the last `dictContentSize` bytes of `dictBuffer`. The
63    resulting dictionary with added entropy tables will written back to
64    `dictBuffer`.
65    @return : size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`).
66*/
67size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity,
68                                        const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
69
70
71/*-*************************************
72*  Helper functions
73***************************************/
74unsigned ZDICT_isError(size_t errorCode);
75const char* ZDICT_getErrorName(size_t errorCode);
76
77
78#ifdef ZDICT_STATIC_LINKING_ONLY
79
80/* ====================================================================================
81 * The definitions in this section are considered experimental.
82 * They should never be used with a dynamic library, as they may change in the future.
83 * They are provided for advanced usages.
84 * Use them only in association with static linking.
85 * ==================================================================================== */
86
87typedef struct {
88    unsigned selectivityLevel;   /* 0 means default; larger => bigger selection => larger dictionary */
89    unsigned compressionLevel;   /* 0 means default; target a specific zstd compression level */
90    unsigned notificationLevel;  /* Write to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */
91    unsigned dictID;             /* 0 means auto mode (32-bits random value); other : force dictID value */
92    unsigned reserved[2];        /* space for future parameters */
93} ZDICT_params_t;
94
95
96/*! ZDICT_trainFromBuffer_advanced() :
97    Same as ZDICT_trainFromBuffer() with control over more parameters.
98    `parameters` is optional and can be provided with values set to 0 to mean "default".
99    @return : size of dictionary stored into `dictBuffer` (<= `dictBufferSize`)
100              or an error code, which can be tested by ZDICT_isError().
101    note : ZDICT_trainFromBuffer_advanced() will send notifications into stderr if instructed to, using ZDICT_setNotificationLevel()
102*/
103size_t ZDICT_trainFromBuffer_advanced(void* dictBuffer, size_t dictBufferCapacity,
104                             const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
105                             ZDICT_params_t parameters);
106
107#endif   /* ZDICT_STATIC_LINKING_ONLY */
108
109#if defined (__cplusplus)
110}
111#endif
112
113#endif   /* DICTBUILDER_H_001 */
Note: See TracBrowser for help on using the repository browser.