feat(compress): move MT overlap window policy to Rust
Move construction of the external-dictionary and active-prefix ranges into a narrow Rust ABI while retaining the C window and logging surface. Preserve byte-range half-open overlap semantics and leave the input-range overlap wrapper available to its other C caller. Test Plan: cargo test --manifest-path rust/Cargo.toml --no-default-features --features compression (180 passed); root and CLI clippy; make -B -C lib -j2 lib; make -C tests -j2 test-cli-tests (41 passed); make -B -C tests -j2 test-zstream (84 named tests plus 6,845 and 9,628 fuzz cases passed).
This commit is contained in:
@@ -141,6 +141,9 @@ size_t ZSTDMT_rust_computeOverlapSize(unsigned windowLog, unsigned chainLog,
|
||||
int strategy, int overlapLog, int enableLdm);
|
||||
int ZSTDMT_rust_isOverlapped(const void* bufferStart, size_t bufferCapacity,
|
||||
const void* rangeStart, size_t rangeSize);
|
||||
int ZSTDMT_rust_doesOverlapWindow(const void* bufferStart, size_t bufferCapacity,
|
||||
const void* nextSrc, const void* base,
|
||||
const void* dictBase, U32 dictLimit, U32 lowLimit);
|
||||
|
||||
typedef struct ZSTDMT_bufferPool_s {
|
||||
ZSTDMT_RustBufferPool* rustPool;
|
||||
@@ -1539,24 +1542,18 @@ static int ZSTDMT_isOverlapped(Buffer buffer, Range range)
|
||||
|
||||
static int ZSTDMT_doesOverlapWindow(Buffer buffer, ZSTD_window_t window)
|
||||
{
|
||||
Range extDict;
|
||||
Range prefix;
|
||||
|
||||
DEBUGLOG(5, "ZSTDMT_doesOverlapWindow");
|
||||
extDict.start = window.dictBase + window.lowLimit;
|
||||
extDict.size = window.dictLimit - window.lowLimit;
|
||||
|
||||
prefix.start = window.base + window.dictLimit;
|
||||
prefix.size = window.nextSrc - (window.base + window.dictLimit);
|
||||
DEBUGLOG(5, "extDict [0x%zx, 0x%zx)",
|
||||
(size_t)extDict.start,
|
||||
(size_t)extDict.start + extDict.size);
|
||||
(size_t)window.dictBase + window.lowLimit,
|
||||
(size_t)window.dictBase + window.dictLimit);
|
||||
DEBUGLOG(5, "prefix [0x%zx, 0x%zx)",
|
||||
(size_t)prefix.start,
|
||||
(size_t)prefix.start + prefix.size);
|
||||
(size_t)window.base + window.dictLimit,
|
||||
(size_t)window.nextSrc);
|
||||
|
||||
return ZSTDMT_isOverlapped(buffer, extDict)
|
||||
|| ZSTDMT_isOverlapped(buffer, prefix);
|
||||
return ZSTDMT_rust_doesOverlapWindow(buffer.start, buffer.capacity,
|
||||
window.nextSrc, window.base,
|
||||
window.dictBase, window.dictLimit,
|
||||
window.lowLimit);
|
||||
}
|
||||
|
||||
static void ZSTDMT_waitForLdmComplete(ZSTDMT_CCtx* mtctx, Buffer buffer)
|
||||
|
||||
Reference in New Issue
Block a user