Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cli: Fix empty string as argument for `--output-dir-*` (#3220, @embg)
cli: Fix decompression memory usage reported by `-vv --long` (#3042, @u1f35c, and #3232, @zengyijing)
cli: Fix infinite loop when empty input is passed to trainer (#3081, @terrelln)
cli: Fix `--adapt` doesn't work when `--no-progress` is also set (#3354, @terrelln)
api: Support for External matchfinder (#3333, @embg)
api: Support for Block-Level Sequence Producer (#3333, @embg)
api: Support for in-place decompression (#3432, @terrelln)
api: New `ZSTD_CCtx_setCParams()` function, set all parameters defined in a `ZSTD_compressionParameters` structure (#3403, @Cyan4973)
api: Streaming decompression detects incorrect header ID sooner (#3175, @Cyan4973)
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ contrib: lib
$(MAKE) -C contrib/seekable_format/examples all
$(MAKE) -C contrib/seekable_format/tests test
$(MAKE) -C contrib/largeNbDicts all
$(MAKE) -C contrib/externalMatchfinder all
$(MAKE) -C contrib/externalSequenceProducer all
cd build/single_file_libs/ ; ./build_decoder_test.sh
cd build/single_file_libs/ ; ./build_library_test.sh

Expand All @@ -143,7 +143,7 @@ clean:
$(Q)$(MAKE) -C contrib/seekable_format/examples $@ > $(VOID)
$(Q)$(MAKE) -C contrib/seekable_format/tests $@ > $(VOID)
$(Q)$(MAKE) -C contrib/largeNbDicts $@ > $(VOID)
$(Q)$(MAKE) -C contrib/externalMatchfinder $@ > $(VOID)
$(Q)$(MAKE) -C contrib/externalSequenceProducer $@ > $(VOID)
$(Q)$(RM) zstd$(EXT) zstdmt$(EXT) tmp*
$(Q)$(RM) -r lz4
@echo Cleaning completed
Expand Down
2 changes: 0 additions & 2 deletions contrib/externalMatchfinder/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions contrib/externalMatchfinder/README.md

This file was deleted.

2 changes: 2 additions & 0 deletions contrib/externalSequenceProducer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# build artifacts
externalSequenceProducer
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
-Wredundant-decls
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)

default: externalMatchfinder
default: externalSequenceProducer

all: externalMatchfinder
all: externalSequenceProducer

externalMatchfinder: matchfinder.c main.c $(LIBZSTD)
externalSequenceProducer: sequence_producer.c main.c $(LIBZSTD)
$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@

.PHONY: $(LIBZSTD)
Expand All @@ -37,4 +37,4 @@ $(LIBZSTD):
clean:
$(RM) *.o
$(MAKE) -C $(LIBDIR) clean > /dev/null
$(RM) externalMatchfinder
$(RM) externalSequenceProducer
14 changes: 14 additions & 0 deletions contrib/externalSequenceProducer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
externalSequenceProducer
=====================

`externalSequenceProducer` is a test tool for the Block-Level Sequence Producer API.
It demonstrates how to use the API to perform a simple round-trip test.

A sample sequence producer is provided in sequence_producer.c, but the user can swap
this out with a different one if desired. The sample sequence producer implements
LZ parsing with a 1KB hashtable. Dictionary-based parsing is not currently supported.

Command line :
```
externalSequenceProducer filename
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define ZSTD_STATIC_LINKING_ONLY
#include "zstd.h"
#include "zstd_errors.h"
#include "matchfinder.h" // simpleExternalMatchFinder
#include "sequence_producer.h" // simpleSequenceProducer

#define CHECK(res) \
do { \
Expand All @@ -28,23 +28,23 @@ do { \

int main(int argc, char *argv[]) {
if (argc != 2) {
printf("Usage: exampleMatchfinder <file>\n");
printf("Usage: externalSequenceProducer <file>\n");
return 1;
}

ZSTD_CCtx* const zc = ZSTD_createCCtx();

int simpleExternalMatchState = 0xdeadbeef;
int simpleSequenceProducerState = 0xdeadbeef;

// Here is the crucial bit of code!
ZSTD_registerExternalMatchFinder(
ZSTD_registerSequenceProducer(
zc,
&simpleExternalMatchState,
simpleExternalMatchFinder
&simpleSequenceProducerState,
simpleSequenceProducer
);

{
size_t const res = ZSTD_CCtx_setParameter(zc, ZSTD_c_enableMatchFinderFallback, 1);
size_t const res = ZSTD_CCtx_setParameter(zc, ZSTD_c_enableSeqProducerFallback, 1);
CHECK(res);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
*/

#include "zstd_compress_internal.h"
#include "matchfinder.h"
#include "sequence_producer.h"

#define HSIZE 1024
static U32 const HLOG = 10;
static U32 const MLS = 4;
static U32 const BADIDX = 0xffffffff;

size_t simpleExternalMatchFinder(
void* externalMatchState,
size_t simpleSequenceProducer(
void* sequenceProducerState,
ZSTD_Sequence* outSeqs, size_t outSeqsCapacity,
const void* src, size_t srcSize,
const void* dict, size_t dictSize,
Expand All @@ -31,7 +31,7 @@ size_t simpleExternalMatchFinder(
size_t seqCount = 0;
U32 hashTable[HSIZE];

(void)externalMatchState;
(void)sequenceProducerState;
(void)dict;
(void)dictSize;
(void)outSeqsCapacity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#define ZSTD_STATIC_LINKING_ONLY
#include "zstd.h"

size_t simpleExternalMatchFinder(
void* externalMatchState,
size_t simpleSequenceProducer(
void* sequenceProducerState,
ZSTD_Sequence* outSeqs, size_t outSeqsCapacity,
const void* src, size_t srcSize,
const void* dict, size_t dictSize,
Expand Down
2 changes: 1 addition & 1 deletion lib/common/error_private.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const char* ERR_getErrorString(ERR_enum code)
case PREFIX(seekableIO): return "An I/O error occurred when reading/seeking";
case PREFIX(dstBuffer_wrong): return "Destination buffer is wrong";
case PREFIX(srcBuffer_wrong): return "Source buffer is wrong";
case PREFIX(externalMatchFinder_failed): return "External matchfinder returned an error code";
case PREFIX(sequenceProducer_failed): return "Block-level external sequence producer returned an error code";
case PREFIX(externalSequences_invalid): return "External sequences are not valid";
case PREFIX(maxCode):
default: return notErrorCode;
Expand Down
Loading